var errorFlag=false;
var isAlt = false;
function _document_onclick(e)
{var event = e ? e : window.event;
 var target = e ? event.target : event.srcElement;
 if(target.id=="download_btn")
 {
	 window.open("downloads/indianPOS.ppt");
 }
 if(target.id=="product_accom")
  	{
		document.location = "accompaniments.cfm";
  	}
  if(target.id=="product_pastes")
  	{
		document.location = "pastes.cfm";
  	}
  if(target.id=="product_sauces")
  {
	  document.location = "sauces.cfm";
  }
  if(target.id == "addLink")
   {
	   window.open("http://www.unileverfoodsolutions.co.uk");
   }
   if(target.id == "play_btn")
   {
	   document.location = "play.cfm";
   }
   if(target.id == "recipes_btn")
   {
	   document.location = "loverecipes.cfm";
   }
   if(target.id == "share_btn")
   {
	   document.location = "sharethelove.cfm";
   }
   if(target.id == "food_btn")
   {
	   document.location = "whyindianfood.cfm";
   }
   if(target.id == "video1_btn")
   {
	   document.location = "whyindianfood.cfm";
   }
   if(target.id == "video2_btn")
   {
	   document.location = "whyindianfood.cfm";
   }
   if(target.id == "easy_btn")
   {
	   document.location = "waystomake.cfm";
   }
   if(target.id == "regional_btn")
   {
	   document.location = "regional.cfm";
   }
    if(target.id == "playterms_btn")
   {
	  window.open("terms.cfm");
   }
   if(target.id == "playSub_btn")
   {
	   
	   errorFlag=false;
	   var errorMsg = "";
	   if(document.playVal.isName_in.value == "")
	   {
		 
		  document.getElementById("playNames1").className = "redText";
		 // document.getElementById("isName_in").style.backgroundColor ="#f00";
		  errorMsg +="Please enter a name";
		  
	   }
	   if(document.playVal.isEmail_in.value == "")
	   {
		 
		  document.getElementById("playNames2").className = "redText";
		  //document.getElementById("isEmail_in").style.backgroundColor ="#f00";
		  errorMsg +="<br/> Please enter an email";
		  
	   }
	   if(document.playVal.isMobile1.value == ""||document.playVal.isMobile2.value == ""||document.playVal.isMobile3.value == ""||document.playVal.isMobile4.value == ""||document.playVal.isMobile5.value == ""||document.playVal.isMobile6.value == ""||document.playVal.isMobile7.value == ""||document.playVal.isMobile8.value == ""||document.playVal.isMobile9.value == ""||document.playVal.isMobile10.value == "")
	   {
		 
		  document.getElementById("playNames3").className = "redText";
		 // document.getElementById("isEmail_in").style.backgroundColor ="#f00";
		  errorMsg +="<br/> Please enter a mobile number";
	   }
	   if(document.playVal.isBatch_in.value == "")
	   {
		 
		  document.getElementById("playNames4").className = "redText";
		 // document.getElementById("isEmail_in").style.backgroundColor ="#f00";
		  errorMsg +="<br/> Please enter a batch code";
		  
	   }
	   if(document.playVal.isCap_in.value == "" || document.playVal.isCap_in.value.length != 6 )
	   {
		 
		  
		  errorMsg +="<br/> incorrect security code";
		  
	   }
	   if(document.playVal.isterms_in.checked==false)
	   {
		 
		  
		  errorMsg +="<br/> Please accept terms and conditions";
		  
	   }
	   if(errorMsg !=""){
		   errorFlag =true;
		document.getElementById("playError").innerHTML = errorMsg;
	   }else{
		document.getElementById("mobileNum").value = "7"+document.getElementById("isMobile3").value+document.getElementById("isMobile4").value+document.getElementById("isMobile5").value+document.getElementById("isMobile6").value+document.getElementById("isMobile7").value+document.getElementById("isMobile8").value+document.getElementById("isMobile9").value+document.getElementById("isMobile10").value+document.getElementById("isMobile11").value;
		document.forms.playVal.submit();
		//document.getElementsByName("")[0].submit();	
	   }
	  
   }
   if(target.id=="goSearch")
   	{if(document.getElementById("searchTxt").value!=""){window.location="search.cfm?sWord="+document.getElementById("searchTxt").value;}
	}
   if (target.id.indexOf("page_") !=-1)
   	{window.location="search.cfm?cpage="+target.id.split("page_")[1]+"&sWord="+theSWord;}
}
function goBack()
{window.history.back();}
function _document_onmouseover(e)
{var event = e ? e : window.event;
 var target = e ? event.target : event.srcElement;
  
 if(target.id == "addLink"|| target.id=="play_btn"|| target.id=="recipes_btn"|| target.id=="share_btn"|| target.id=="food_btn"|| target.id=="video1_btn"|| target.id=="video2_btn"|| target.id=="easy_btn"|| target.id=="regional_btn"|| target.id=="download_btn" || target.id=="product_pastes"|| target.id=="product_sauces"|| target.id=="product_accom")
 {
	 document.getElementById(target.id).className ="changeCursor";
 }
}

function _document_onmouseout(e)
{var event = e ? e : window.event;
 var target = e ? event.target : event.srcElement;
 
}
function _document_onkeydown(e)
{var event = e ? e : window.event;
 var target = e ? event.target : event.srcElement;
 theCode = event.which ? event.which : event.keyCode;
 if(theCode == 18){ isAlt = true;}
	
}
function _document_onkeyup(e)
{var event = e ? e : window.event;
 var target = e ? event.target : event.srcElement;
 theCode = event.which ? event.which : event.keyCode;
 if(isAlt==true && theCode==48)
  {
  	  document.location = "accessibility-statement.cfm";
  	  isAlt = false;
  }else{
	  isAlt = false;
	  
  }
  if(theCode==8 || theCode==9 || theCode==16 || theCode <= 47){theFlag=false}else{theFlag=true}
   if(target.id.indexOf("isMobile") >= 0 && theFlag==true)
	  {for (var i=1;i <= 11;i++)
		  {var elem = "isMobile"+i.toString(10);
		   if(target.id==elem){i++;break;}
		  }
	   if(i<=11){elem = "isMobile"+i.toString(10);}else{elem = "isBatch_in"}
	   document.getElementById(elem).focus();
	  }
}

function _document_onkeypress(e)
{var event = e ? e : window.event;
 var target = e ? event.target : event.srcElement;
 if(target.id=="isBatch_in" || target.id=="isMobile1" || target.id=="isMobile2" || target.id=="isMobile3"|| target.id=="isMobile4"|| target.id=="isMobile5"|| target.id=="isMobile6"|| target.id=="isMobile7"|| target.id=="isMobile8"|| target.id=="isMobile9"|| target.id=="isMobile10"|| target.id=="isMobile11")	/* These are the elements to check the keypress in*/
 	{theCode = event.which ? event.which : event.keyCode;
 	 if((theCode < 48 || theCode > 57) && theCode!=8 && theCode!=9)	/* These are the characters/range of characters to refuse */
 		{event.cancelBubble=true;
	 	 if(event.stopPropagation) {event.stopPropagation()}
		 return false;
		}
	}
	if(errorFlag==true){
		
		
		if(document.getElementById("playNames1").className == "redText" && target.id =="isName_in")
		{
			document.getElementById("playNames1").className = "playText";
		}
		if(document.getElementById("playNames2").className == "redText" && target.id =="isEmail_in")
		{
			document.getElementById("playNames2").className = "playText";
		}
		if(document.getElementById("playNames3").className == "redText")
		{
			if(target.id=="isMobile1"||target.id=="isMobile2"||target.id=="isMobile3"||target.id=="isMobile4"||target.id=="isMobile5"||target.id=="isMobile6"||target.id=="isMobile7"||target.id=="isMobile8"||target.id=="isMobile9"||target.id=="isMobile10"||target.id=="isMobile11")
			{
			document.getElementById("playNames3").className = "playText";
			}
		}
		if(document.getElementById("playNames4").className == "redText" && target.id=="isBatch_in")
		{
			document.getElementById("playNames4").className = "playText";
		}
		
		document.getElementById("playError").innerHTML = "";
	}
	return true;
}




/*============================================================Event handlers=================================================*/
if (document.layers) document.captureEvents(Event.ONCLICK);
	document.onclick = _document_onclick;

if (document.layers) document.captureEvents(Event.ONMOUSEOVER);
document.onmouseover = _document_onmouseover;

if (document.layers) document.captureEvents(Event.ONMOUSEOUT);
document.onmouseout = _document_onmouseout;

if (document.layers) document.captureEvents(Event.ONKEYUP);
document.onkeyup = _document_onkeyup;

if (document.layers) document.captureEvents(Event.ONKEYPRESS);
document.onkeypress = _document_onkeypress;

if (document.layers) document.captureEvents(Event.ONKEYDOWN);
document.onkeydown = _document_onkeydown;
