var response;
exrtaContentLoaded = false;

function doAjaxSubmitGetContent(){
			//	alert("get");
					new Ajax.Request('/open_heart_page_content.do',
					  {
					    method:'get',
					    onSuccess: function(transport){
			//			alert("sucess gotten");
					      response = transport.responseText || "no response text";					     
					    
					     },
					    onFailure: function(){ alert('Something went wrong with connecting to the Server. Please refresh this webpage.') }
					  });
}


function checkContentArrived(){
	if(response.length==0){
		
		doAjaxSubmitGetContent();
		for(var x = 0;response.length==0;x++){
			
			pausecomp(500);
			if(x=4)return;
		}				
	}
}


function resetPageAnchorsLinks(){
	//alert("removing");
	$("barlong1anchor").removeAttribute("href");
	$('barmedium2anchor').removeAttribute("href");
	$('barmedium4anchor').removeAttribute("href");
	$('barmedium5anchor').removeAttribute("href");
	$('barmedium6anchor').removeAttribute("href");
	$('barmedium7anchor').removeAttribute("href");
	$('barmedium8anchor').removeAttribute("href");
	$('barmedium9anchor').removeAttribute("href");
	$('barshort1anchor').removeAttribute("href");
	$('barshort2anchor').removeAttribute("href");
	$('barshort3anchor').removeAttribute("href");
	$('barshort4anchor').removeAttribute("href");
	$('barshort5anchor').removeAttribute("href");
	$('barshort6anchor').removeAttribute("href");
	$('barshort7anchor').removeAttribute("href");

	if(exrtaContentLoaded == true){
	
		var i=0;
		var link = 'link';
		for(i=1;i<=29;i++){
			var newlink = link+i.toString();
			$(newlink).removeAttribute("href");
		}
	}
		
}


	function setMenu(){		
	  
				
		if(window.location.hash=="#find_out_how"){
		   setLongMenu('barlong1');
		   window.location.hash="#next";
		}
		else{
			setLongMenu('barlong1');			
		}
		
	}


	function setMenuToLocation(menuitem,menuregion){
		setMediumMenu(menuitem);
		moveToPageAnchor(menuregion)
		//window.location.hash=menuregion;
	}


	function resetMenus(){
		
			checkContentArrived();	
		
			if(exrtaContentLoaded==false){ 
				$("content").innerHTML=response;
				exrtaContentLoaded = true;
			
			}
		 	
		//	resetPageAnchorsLinks();
				
			document.getElementById('barlong1').className = 'barlong';
			
	
			document.getElementById('barmedium2').className = 'barmedium';
		//	document.getElementById('barmedium3').className = 'barmedium';
			document.getElementById('barmedium4').className = 'barmedium';
			document.getElementById('barmedium5').className = 'barmedium';
			document.getElementById('barmedium6').className = 'barmedium';
			document.getElementById('barmedium7').className = 'barmedium';
			document.getElementById('barmedium8').className = 'barmedium';
			document.getElementById('barmedium9').className = 'barmedium';
		


			document.getElementById('barshort1').className = 'barshort';
			document.getElementById('barshort2').className = 'barshort';
			document.getElementById('barshort3').className = 'barshort';
			document.getElementById('barshort4').className = 'barshort';
			document.getElementById('barshort5').className = 'barshort';
			document.getElementById('barshort6').className = 'barshort';
			document.getElementById('barshort7').className = 'barshort';


			document.getElementById('barlong1').style.color = '#4F4F4F';
			
		
			document.getElementById('barmedium2').style.color = '#4F4F4F';
		//	document.getElementById('barmedium3').style.color = '#4F4F4F';
			document.getElementById('barmedium4').style.color = '#4F4F4F';
			document.getElementById('barmedium5').style.color = '#4F4F4F';
			document.getElementById('barmedium6').style.color = '#4F4F4F';
			document.getElementById('barmedium7').style.color = '#4F4F4F';
			document.getElementById('barmedium8').style.color = '#4F4F4F';
			document.getElementById('barmedium9').style.color = '#4F4F4F';
			
	
			document.getElementById('barshort1').style.color = '#4F4F4F';
			document.getElementById('barshort2').style.color = '#4F4F4F';
			document.getElementById('barshort3').style.color = '#4F4F4F';
			document.getElementById('barshort4').style.color = '#4F4F4F';
			document.getElementById('barshort5').style.color = '#4F4F4F';
			document.getElementById('barshort6').style.color = '#4F4F4F';
			document.getElementById('barshort7').style.color = '#4F4F4F';	


	}

	function setLongMenu(menuitem){
	
		resetMenus();
	    resizeContentArea(menuitem+'content');  	 	
		Effect.divSwap(menuitem+'content','content');
	
	
	
	
		// Collapse all sub menus
	     document.getElementById('holder1').className = 'hidelist';
	//	 document.getElementById('holder2').className = 'hidelist';
		
		document.getElementById(menuitem).className = 'arrowlong';	
		document.getElementById(menuitem).style.color = "#2F2F2F";	
		
		return false;
		
	}

	function setMediumMenu(menuitem){
	
		resetMenus();
	    
	    // Collapse all sub menus
	     document.getElementById('holder1').className = 'hidelist';
		// document.getElementById('holder2').className = 'hidelist';
		
	
		// Open Sub Menus
		if(menuitem == "barmedium9"){
			document.getElementById('nav').style.height="auto";
			document.getElementById('holder1').className = 'showlist';
					
		}

		/*if(menuitem == "barmedium9"){
			document.getElementById('nav').style.height="auto";	
			document.getElementById('holder2').className = 'showlist';
	    }*/
		
	
		
		// *************** CHANGE HERE ****
		// show selected 
		
		
		
	    resizeContentArea(menuitem+'content');  	 	
		Effect.divSwap(menuitem+'content','content');
		
		// Set menu to display
		document.getElementById(menuitem).className = 'arrowmedium';
		document.getElementById(menuitem).style.color = "#2F2F2F";
		
		
		return false;

	}

	
	function initLongMenu(menuitem){
		document.getElementById(menuitem).className = 'arrowlong';
		document.getElementById(menuitem).style.color = "#2F2F2F";
	}
	
	function initMediumMenu(menuitem){
		document.getElementById(menuitem).className = 'arrowmedium';
		document.getElementById(menuitem).style.color = "#2F2F2F";
	}
	
	function initShortMenu(menuitem){
		document.getElementById('nav').style.height="auto";
		document.getElementById('holder1').className = 'showlist';
		document.getElementById(menuitem).className = 'arrowshort';
		document.getElementById(menuitem).style.color = "#2F2F2F";
	}


	

 

