$(document).ready(function(){
	$('#home_middle_left').supersleight();
	$('#broadway_container').scrollable({
		'onBeforeSeek': function( ev, key ) {
			$('#banner_pager img' ).each(function(key,img){
				img.src=base_url+'images/grey-point.jpg';
			});
			$('#img'+key).attr( 'src', base_url+'images/red-point.jpg' );
		}
	});
	$('#offbroadway_container').scrollable({
		'onBeforeSeek': function( ev, key ) {
			$('#offbanner_pager img' ).each(function(key,img){
				img.src=base_url+'images/grey-point.jpg';
			});
			$('#offimg'+key).attr( 'src', base_url+'images/red-point.jpg' );
		}
	});
	addons = Array( '', 'off' );
	for( i = 0; i < addons.length; i++ ) {
		addon = addons[i];
		$('#'+addon+'broadway_btn img').click(function(){
			addon = '';
			other = 'off';
			if( $(this).attr('src').match( /offbroadway/ ) ) {
				addon = 'off';
				other = '';
			}
			$('#'+other+'broadway_container').hide();
			$('#'+addon+'broadway_container').show();
			$('#'+other+'banner_pager').hide();
			$('#'+addon+'banner_pager').show();
			$(this).attr('src',base_url+'images/button-'+addon+'broadway-shows-green.jpg');
			$('#'+other+'broadway_btn img').attr('src',base_url+'images/button-'+other+'broadway-shows-grey.jpg');
		});
	}
	$("#our_theater").scrollable({
		'onBeforeSeek': function( ev, key ) {
			$('#pagenum').text( parseInt( key ) + 1 );
		}
	});
});

function slideTo( id, addon ) {
	if( !addon )
		addon = '';
	$('#'+addon+'broadway_container').data('scrollable').seekTo( parseInt( id ) );
}

function t_begin( id ) {
	$('#our_theater').data('scrollable').begin();
}
function t_next() {
	$('#our_theater').data('scrollable').next();
}
function t_prev() {
	$('#our_theater').data('scrollable').prev();
}
function t_end() {
	$('#our_theater').data('scrollable').end();
}


function load_div( el, url ) {
	return $('#'+el).load( url );
	//var au = new Ajax.Updater( el, url, {asynchronous:true, evalScripts:true} );
	return au;
}

function show_popup( el ) {
	showopacity();
	//opera Netscape 6 Netscape 4x Mozilla 
	if (window.innerWidth || window.innerHeight){ 
		docwidth = window.innerWidth; 
	} else 
	//IE Mozilla 
	if (document.body.clientWidth || document.body.clientHeight){ 
		docwidth = document.body.clientWidth; 
	} else
		docwidth = 640;
	t = document.body.parentNode.scrollTop + 110;
	l = document.body.parentNode.scrollLeft + docwidth / 2 - 320;
	$('#'+el).css( 'top', t );
	$('#'+el).css( 'left', l );
	$('#'+el).show();
	showopacity();
}

function hide_popup( el ) {
	$('#'+el).hide();
	hideopacity();
}

function showopacity() {
	$('#screen_opacity').height( document.body.parentNode.scrollHeight );
	$('#screen_opacity').width( document.body.parentNode.scrollWidth );
	$('#screen_opacity').show();
}

function hideopacity() {
	$('#screen_opacity').hide();
}

function in_array( el, arr ) {
	for( j = 0; j < arr.length; j++ )
		if( arr[j] == el )
			return true;
	return false;
}

function please_wait() {
	d = $('#please_wait_div');
	d.width( 640 );
	d.height( 200 );
	show_popup( d.id );
	setTimeout( 'alternate_dots()', 400 );
}

function alternate_dots() {
	$('#blinking_dots').toggle();
	setTimeout( 'alternate_dots()', 400 );
}
