/*****************************************************************************************************************************/
/* page load */
//window.onload = function(){
//
//}



/*****************************************************************************************************************************/
/* ajax requests */
/*****************************************************************************************************************************/


function validateAgeRequest(lang){
	
	
	allNodes = Form.serialize("frmAge");
	
	new Ajax.Request("libs/age_verification.php?lang=" + lang,
	{
		method:"post",
		postBody:allNodes,
		onComplete:showResponse,
		onFailure:ajaxError
	});
	
}





/*****************************************************************************************************************************/
/* ajax responses */
/*****************************************************************************************************************************/

/*****************************************************************************************************************************/
function showResponse(req){

//	if(req.responseText == "UserIsOfAgeEn"){
//		window.location = "en/index.php";
//	}else if(req.responseText == "UserIsOfAgeFr"){
//		window.location = "coming_soon_fr.shtml";
	if(req.responseText == "You&#39;re address already exists in our list." || req.responseText == "Thank-you, you&#39;ve been added to the list."){
		$("txtEmail").value = "";
		$("divStatus").innerHTML = req.responseText;
		$("btnSubmit").disabled = false;
	}else if(req.responseText == "adminLoginRequest"){
		window.location = "index.php";
	
	}else if(req.responseText == "/en" || req.responseText == "//en"){
		// loader english
		var path = document.location.pathname;
		var cur_root = path.substring(0, path.lastIndexOf('/'));
		window.location = cur_root + "/en";

	}else if(req.responseText == "/fr" || req.responseText == "//fr"){
		// loader english
		var path = document.location.pathname;
		var cur_root = path.substring(0, path.lastIndexOf('/'));
		window.location = cur_root + "/fr";
	
	}else if(req.responseText == "/havemore/en" || req.responseText == "/havemore//en"){
		// havemore english
		var path = document.location.pathname;
		var cur_root = path.substring(0, path.lastIndexOf('/'));
		window.location = cur_root + "/havemore/en";

	}else if(req.responseText == "/havemore/fr" || req.responseText == "/havemore//fr"){
		// havemore french
		var path = document.location.pathname;
		var cur_root = path.substring(0, path.lastIndexOf('/'));
		window.location = cur_root + "/havemore/fr";
		
	}else if(req.responseText == "/play/en" || req.responseText == "/play//en"){
		// play english
		var path = document.location.pathname;
		var cur_root = path.substring(0, path.lastIndexOf('/'));
		window.location = cur_root + "/play/en";
		
	}else if(req.responseText == "/play/fr" || req.responseText == "/play//fr"){
		// play french
		var path = document.location.pathname;
		var cur_root = path.substring(0, path.lastIndexOf('/'));
		window.location = cur_root + "/play/fr";
		
	}else if(req.responseText == "/thin/en" || req.responseText == "/thin//en"){
		// play french
		var path = document.location.pathname;
		var cur_root = path.substring(0, path.lastIndexOf('/'));
		window.location = cur_root + "/thin/en";
		
	}else if(req.responseText == "/thin/fr" || req.responseText == "/thin//fr"){
		// play french
		var path = document.location.pathname;
		var cur_root = path.substring(0, path.lastIndexOf('/'));
		window.location = cur_root + "/thin/fr";
		
	}else if(req.responseText == "/warmuptour/en" || req.responseText == "/warmuptour//en"){
		// play french
		var path = document.location.pathname;
		var cur_root = path.substring(0, path.lastIndexOf('/'));
		window.location = cur_root + "/warmuptour/en";
		
	}else if(req.responseText == "/warmuptour/fr" || req.responseText == "/warmuptour//fr"){
		// play french
		var path = document.location.pathname;
		var cur_root = path.substring(0, path.lastIndexOf('/'));
		window.location = cur_root + "/warmuptour/fr";		
		
	}else{
		$("divStatus").innerHTML = req.responseText;
		$("btnSubmit").disabled = false;
		$("imgAjaxLoader").toggle();
	}
}





/*********************************************************************************************************/
function ajaxError(){
	$("divStatus").innerHTML = "There was a problem processing the Ajax Request";
}





/*********************************************************************************************************/
/* cookie check */
function cookieCheck(){
	//set test cookie
	setCookie("cookieCheck", "cookietest", 5);
	//check if cookie was accepted
	if(readCookie("cookieCheck") != "cookietest"){
		Effect.BlindDown('cookieCheck');
		$('wrapper').className = 'hide';
		//alert('enable cookies');
	}
	//delete cookie
	setCookie("cookieCheck", "", -1);
}//cookieCheck

function setCookie(cookieName,cookieValue,nDays) {
	var today = new Date();
	var expire = new Date();
	if (nDays==null || nDays==0) nDays=1;
	expire.setTime(today.getTime() + 3600000*24*nDays);
	document.cookie = cookieName+"="+escape(cookieValue)
					 + ";expires="+expire.toGMTString();
}//setCookie

function readCookie(cookieName) {
	var theCookie=""+document.cookie;
	var ind=theCookie.indexOf(cookieName);
	if (ind==-1 || cookieName=="") return ""; 
	var ind1=theCookie.indexOf(';',ind);
	if (ind1==-1) ind1=theCookie.length; 
	return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}

