var currentArea = 'about';
var menuAreas = Array('about','food','news','twitter','facebook','reservations');
function menuOver(value){
	document.getElementById('menu_'+value).src = '/imgs/menu/'+value+'_down.png';
}

function menuOut(value){
	if(currentArea!=value) document.getElementById('menu_'+value).src = '/imgs/menu/'+value+'.png';
}

function menuClick(value){
	currentArea = value;
	for(var menu in menuAreas){ document.getElementById('menu_'+menuAreas[menu]).src = '/imgs/menu/'+menuAreas[menu]+'.png'; }
	document.getElementById('menu_'+currentArea).src = '/imgs/menu/'+currentArea+'_down.png';
	
	var bgColor = '#f2f8d2';
	if(currentArea=="about") bgColor = '#f2f8d2';
	else if(currentArea=="food") bgColor = '#e6f3fc';
	else if(currentArea=="news") bgColor = '#e9edea';
	else if(currentArea=="twitter") bgColor = '#ccd4cd';
	else if(currentArea=="facebook") bgColor = '#ccd4cd';
	else if(currentArea=="reservations") bgColor = '#eaebd7';
	document.getElementById('headerContentBackground').style.backgroundColor = bgColor;
	document.getElementById('footerBackground').style.backgroundColor = bgColor;
	document.getElementById('pageHeader').className = 'page_header_'+currentArea;
	document.getElementById('headerContentRight').className = 'header_content_right_'+currentArea;
	$('body').css('background','url(/imgs/backs/back_'+bgColor.substr(1)+'.png) repeat-y #ffffff');
}

function getSubMenu(area, subArea){
	$("#page_header_menu_items").load(area+'/menu', {sub_area:subArea});
}

function getContent(area){
	$("#page_content").load(area);
}



function getPage(hash){
	var content = "";
	var menu_item=hash.split("/");
	menuClick(menu_item[0]);
	if(!menu_item[1]) menu_item[1]="index";
	getContent(hash);
	getSubMenu(menu_item[0],menu_item[1]);
}


function submitForm(){
	var errorItem = "";
	var formGood = true;
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

	
	var bday = $("#birthday").val();
	if(bday.substr(2,1)=="/" && bday.length==5){
		$("#cm-f-jtgit").val(bday.substr(3,2));
		$("#cm-f-jtgij").val(bday.substr(0,2));
	} else {
		formGood = false;
		errorItem+= '\r\nValid Birthday (dd/mm)';
	}
	
	if($("#fullname").val().length<3){ formGood = false; errorItem+= '\r\nValid Name'; }
	
	var email = $("#email").val();	
	if(reg.test(email)==false){ formGood = false; errorItem+= '\r\nValid Email'; }
	
	if($("#zip").val().length<5 || isNaN($("#zip").val())==true){ formGood = false; errorItem+= '\r\nValid Zip Code'; }
	
	if(formGood==false) alert("The Following items were needed:\r\n"+errorItem);
	else $("#form_subscribe").submit();
		
}
