var current_img = 0;
var letter_displayed=''
var old_large ='';
var total_rotate_images;
var max_thumb_scroll;
												
function rotateSponsors(){
	var old_img = current_img;
	current_img++;
	if(current_img > total_rotate_images){
		current_img=0;
	}
	
	Effect.Fade($('img_'+old_img));
	Effect.Appear($('img_'+current_img));
	//rotateSponsors();
	setTimeout("rotateSponsors()",5000)
}



function reveal(display_id) {
	$('categories_div').hide();
	$('map_div_parent').hide();
	$(display_id).show();
	$('map_div_store_name').update('');
}

function map_update(lot_num, store_name){
	$('map_div_store_name').update(store_name);
	if(lot_num.substring(0,1)=="n"){
		$('map_div').style.backgroundImage="url(/img/stores/map_stores/map_north.jpg)";
		$('map_div').style.width='545px';
		$('map_div').style.height='633px';
		$('map_div').update('<div id="map_div_store" style="width:544px; height:633px; background-image:url(img/stores/map_stores/'+lot_num+'.png)" class="fixpng"></div>');
		$('map_div_label').update('Concord Mall North Campus');
	}else if(lot_num.substring(0,1)=="s"){
		$('map_div').style.backgroundImage="url(/img/stores/map_stores/map_south.gif)";
		$('map_div').style.width='545px';
		$('map_div').style.height='633px';
		$('map_div').update('<div id="map_div_store" style="width:545px; height:633px; background-image:url(img/stores/map_stores/'+lot_num+'.png)" class="fixpng"></div>');
		$('map_div_label').update('Concord Mall South Campus');
	}else{
		$('map_div').style.backgroundImage="url(/img/stores/map_stores/map.jpg)";
		$('map_div').style.width='544px';
		$('map_div').style.height='817px';
		$('map_div').update('<div id="map_div_store" style="width:544px; height:817px; background-image:url(img/stores/map_stores/'+lot_num+'.png)" class="fixpng"></div>');
		$('map_div_label').update('Concord Mall Main Campus');
	}
	Effect.Pulsate($('map_div_store'), {pulses: 10, duration: 5});
}

function show_map_from_overlay(lot_num,store_name){
	reveal('map_div_parent');
	map_update(lot_num,store_name);
	Lightview.hide();
}

function letters_divs(letter){
	if(letter!=letter_displayed){
		if(letter_displayed!=''){
			Effect.BlindUp($(letter_displayed));
		}
		letter_displayed = letter;
		Effect.BlindDown($(letter_displayed));
	}
}

function events_list(month, year){
	var url = 'elkhart_indiana_mall_events.php?action=display_events&month='+month+'&year='+year;
	new Ajax.Request(url, {
		method: 'get',
		onSuccess: function(transport) {
			$('event_list').update(transport.responseText);
		}
	});

}

function thumb_scroll_up(max_val){
	var curtop = parseInt($('thumb_scroll').getStyle('top'));
	curtop = curtop-70;
	if(curtop<(-max_val)) curtop=(-max_val);
	$('thumb_scroll').style.top = curtop+'px';
}

function thumb_scroll_down(){
	var curtop = parseInt($('thumb_scroll').getStyle('top'));
	curtop = curtop+70;
	if(curtop>0) curtop=0;
	$('thumb_scroll').style.top = curtop+'px';
}


function thumb_scroll_right(){
	var curleft = parseInt($('thumb_scroll').getStyle('left'));
	curleft = curleft-85;
	if(curleft<=(-max_thumb_scroll)){
		curleft=(-max_thumb_scroll);
		$('scroll_right').update('<img src="/img/gallery_right_arrow_disabled.jpg" />');
	}
	$('scroll_left').update('<img src="/img/gallery_left_arrow.jpg"  style="cursor:pointer;" onclick="thumb_scroll_left()" />');
	$('thumb_scroll').style.left = curleft+'px';
}

function thumb_scroll_left(){
	var curleft = parseInt($('thumb_scroll').getStyle('left'));
	curleft = curleft+85;
	if(curleft>=0){
		curleft=0;
		$('scroll_left').update('<img src="/img/gallery_left_arrow_disabled.jpg" />');
	}
	$('scroll_right').update('<img src="/img/gallery_right_arrow.jpg" onclick="thumb_scroll_right()" style="cursor:pointer;"  />');
	$('thumb_scroll').style.left = curleft+'px';
}

function ThumbToLarge(id){
	if(old_large==id) return true;
	if(old_large!=''){
		Effect.Fade($(old_large),{duration:0.3});
	}
	Effect.Appear($(id),{duration:0.3});
	old_large=id;
}

function ThumbToLargeAjax(id){
	if(old_large==id) return true;
	if(old_large!=''){
		Effect.Fade($('img_holder_'+old_large),{duration:0.3});
		$('text_holder_'+old_large).hide();
	}
	Effect.Appear($('img_holder_'+id),{duration:0.3});
	$('text_holder_'+id).show();
	old_large=id;
	return;
	new Ajax.Request(url, {
		method: 'get',
		onSuccess: function(transport) {
			return_array = transport.responseText.split('||||||||');
			Effect.Fade($('img_holder'),{duration:0.2, afterFinish: function(obj)
				 {
					$('img_holder').update(return_array[0]);
					$('text_holder').update(return_array[1]);
					Effect.Appear($('img_holder'),{duration:0.2});		
				 }
			});
			
		}
	});


}