$(document).ready(function() {
	hideAllHistory();
	$('#history_1 .scroll_down').click(function() {
			var sub_1_height = $('#history_sub_1').height();
			var currentTop = $('#history_sub_1').css("top");
			var parsed_currentTop = parseFloat(currentTop);	
			var abs_parsed_currentTop = Math.abs(parsed_currentTop);
			if(abs_parsed_currentTop < (sub_1_height-100)) {
			$('#history_sub_1').animate({top: (parsed_currentTop-40)},500, "linear");
			}
	})
	
	$('#history_1 .scroll_up').click(function() {
			var sub_1_height = $('#history_sub_1').height();
			var currentTop = $('#history_sub_1').css("top");
			var parsed_currentTop = parseFloat(currentTop);	
			var abs_parsed_currentTop = Math.abs(parsed_currentTop);
			if(abs_parsed_currentTop >= 20) {
			$('#history_sub_1').animate({top: (parsed_currentTop+40)},500, "linear");
			}
	})
	$('#history_2 .scroll_down').click(function() {
			var sub_2_height = $('#history_sub_2').height();
			var currentTop = $('#history_sub_2').css("top");
			var parsed_currentTop = parseFloat(currentTop);	
			var abs_parsed_currentTop = Math.abs(parsed_currentTop);
			if(abs_parsed_currentTop < (sub_2_height-100)) {
			$('#history_sub_2').animate({top: (parsed_currentTop-40)},500, "linear");
			}
	})
	
	$('#history_2 .scroll_up').click(function() {
			var sub_2_height = $('#history_sub_2').height();
			var currentTop = $('#history_sub_2').css("top");
			var parsed_currentTop = parseFloat(currentTop);	
			var abs_parsed_currentTop = Math.abs(parsed_currentTop);
			if(abs_parsed_currentTop >= 20) {
			$('#history_sub_2').animate({top: (parsed_currentTop+40)},500, "linear");
			}
	})
	$('#history_3 .scroll_down').click(function() {
			var sub_3_height = $('#history_sub_3').height();
			var currentTop = $('#history_sub_3').css("top");
			var parsed_currentTop = parseFloat(currentTop);	
			var abs_parsed_currentTop = Math.abs(parsed_currentTop);
			if(abs_parsed_currentTop < (sub_3_height-100)) {
			$('#history_sub_3').animate({top: (parsed_currentTop-40)},500, "linear");
			}
	})
	
	$('#history_3 .scroll_up').click(function() {
			var sub_3_height = $('#history_sub_3').height();
			var currentTop = $('#history_sub_3').css("top");
			var parsed_currentTop = parseFloat(currentTop);	
			var abs_parsed_currentTop = Math.abs(parsed_currentTop);
			if(abs_parsed_currentTop >= 20) {
			$('#history_sub_3').animate({top: (parsed_currentTop+40)},500, "linear");
			}
	})
	$('#history_4 .scroll_down').click(function() {
			var sub_4_height = $('#history_sub_4').height();
			var currentTop = $('#history_sub_4').css("top");
			var parsed_currentTop = parseFloat(currentTop);	
			var abs_parsed_currentTop = Math.abs(parsed_currentTop);
			if(abs_parsed_currentTop < (sub_4_height-100)) {
			$('#history_sub_4').animate({top: (parsed_currentTop-40)},500, "linear");
			}
	})
	
	$('#history_4 .scroll_up').click(function() {
			var sub_4_height = $('#history_sub_4').height();
			var currentTop = $('#history_sub_4').css("top");
			var parsed_currentTop = parseFloat(currentTop);	
			var abs_parsed_currentTop = Math.abs(parsed_currentTop);
			if(abs_parsed_currentTop >= 20) {
			$('#history_sub_4').animate({top: (parsed_currentTop+40)},500, "linear");
			}
	})
	
	$('#history_5 .scroll_down').click(function() {
			var sub_5_height = $('#history_sub_5').height();
			var currentTop = $('#history_sub_5').css("top");
			var parsed_currentTop = parseFloat(currentTop);	
			var abs_parsed_currentTop = Math.abs(parsed_currentTop);
			if(abs_parsed_currentTop < (sub_5_height-100)) {
			$('#history_sub_5').animate({top: (parsed_currentTop-40)},500, "linear");
			}
	})
	
	$('#history_5 .scroll_up').click(function() {
			var sub_5_height = $('#history_sub_5').height();
			var currentTop = $('#history_sub_5').css("top");
			var parsed_currentTop = parseFloat(currentTop);	
			var abs_parsed_currentTop = Math.abs(parsed_currentTop);
			if(abs_parsed_currentTop >= 20) {
			$('#history_sub_5').animate({top: (parsed_currentTop+40)},500, "linear");
			}
	})
	
 })

function init_toggle(start,num){
	for(x = start; x<= num; x++){
        document.getElementById('deets_' + x).style.display = 'none';
        //document.getElementById('title_' + x).style.background = 'url(/_images/html/arrow1.gif) no-repeat 0 5px';
        document.body.style.height = 'auto';
     }
}


function toggle_deets(id){
	if(document.getElementById('deets_' + id).style.display == 'none'){
		hideAllDeets();
		$('#deets_' + id).toggle(500);
		
        //document.getElementById('title_' + id).style.background = 'url(/_images/html/arrow1_down.gif) no-repeat 0 5px';
     } else {
        document.getElementById('deets_' + id).style.display = 'none';
        //document.getElementById('title_' + id).style.background = 'url(/_images/html/arrow1.gif) no-repeat 0 5px';
	}
}

function toggle_history(id){
	if(document.getElementById('history_sub_' + id).style.display == 'none'){
		hideAllHistory();
		$('#history_' + id).css({'height':'120px'});
		$('#history_sub_' + id).toggle(500);
		
        //document.getElementById('title_' + id).style.background = 'url(/_images/html/arrow1_down.gif) no-repeat 0 5px';
     } else {
		$('#history_sub_' + id).hide(500)
		$('#history_' + id).css({'height':'12px'});
        //document.getElementById('title_' + id).style.background = 'url(/_images/html/arrow1.gif) no-repeat 0 5px';
	}
}

function toggleMap(){
		document.getElementById('storeMap').style.display = 'block';
}

function hideAllDeets() {
	$('#deets_1').hide();	
	$('#deets_2').hide();
	$('#deets_3').hide();
	$('#deets_4').hide();
	$('#deets_5').hide();
	$('#deets_6').hide();
}

function hideAllHistory() {
	$('#history_sub_1').hide();	
	$('#history_1').css({'height':'12px'});
	if(($('#history_sub_1').height()) < 130) {
		$('#history_1 .scroll_up').hide();
	}
	if(($('#history_sub_1').height()) < 130) {
		$('#history_1 .scroll_down').hide();
	}
	$('#history_sub_2').hide();
	$('#history_2').css({'height':'12px'});
	if(($('#history_sub_2').height()) < 130) {
		$('#history_2 .scroll_down').hide();
		$('#history_2 .scroll_up').hide();
	}
	$('#history_sub_3').hide();
	$('#history_3').css({'height':'12px'});
	if(($('#history_sub_3').height()) < 130) {
		$('#history_3 .scroll_down').hide();
		$('#history_3 .scroll_up').hide();
	}
	$('#history_sub_4').hide();
	$('#history_4').css({'height':'12px'});
	if(($('#history_sub_4').height()) < 130) {
		$('#history_4 .scroll_down').hide();
		$('#history_4 .scroll_up').hide();
	}
	$('#history_sub_5').hide();
	$('#history_5').css({'height':'12px'});
	if(($('#history_sub_5').height()) < 130) {
		$('#history_5 .scroll_down').hide();
		$('#history_5 .scroll_up').hide();
	}
}