// this function gets the cookie, if it exists
function Get_Cookie( name ) {
	
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}
	

function AW_setCookie(name, value, days) {     
	millisecs = 1000 * 60 * 60 * 24 * eval(days)     
	expire = new Date();     
 	expire.setTime (expire.getTime() + millisecs);     
   document.cookie = name + "=" + escape(value) +  "; expires=" + expire.toGMTString()    
}

function checkCookies(){
	var cookies = new Array("personalMenu","personalBanking","personalLoans","personalConveniences","businessMenu","businessBanking","businessLoans","businessConveniences","loansMenu","retirementMenu","communityMenu","communityLocal","communityCommunities");
	
	for(i=0;i<cookies.length;i++){
		if(Get_Cookie(cookies[i])=="true"){
			swap(cookies[i]);
			
		}
	}
}

function swap(targetId){
  
  if (document.getElementById)
        {
        target = document.getElementById(targetId);
        
            if (target.style.display == "none")
                {
				 target.style.display = "block";
				 //set cookie to true for the target
				 AW_setCookie(target.id, true, 30);
                } 
            
            else 
                {
                target.style.display = "none";
				//set cookie to false for the target	
				AW_setCookie(target.id, false, 30);
                }
                
        }
}

