// JavaScript Document
var t;
var sec=0;

function counter(){
sec--;
document.getElementById("redirectinfo").innerHTML="You have not verified your age yet. So you will be redirected for age <br>validation after 3 seconds. <span style='color:#ff0000'>"+sec+" Second(s) left.</span>";
   if(sec<=0){
    clearInterval(t);
    window.location.replace("landingpage.html");
   }
}
function checkCookie()
{
	var cookies = ""+document.cookie.split(';');
	//alert(document.cookie+","+cookies.length);
if(cookies.length!=0)
	{
		for (var i=0; i<cookies.length; i++)
		{
		  var cookie = cookies[i];
		  cookie=cookie.split("=");
         // alert(cookie[0]+","+cookie[1]);
		  if (cookie[0]=="allow"&&cookie[1]=="yes")
		  {
		  	break;
		  }
		}
        }
	 else{
          document.getElementById("redirectinfo").innerHTML="You have not verified your age yet. So you will be redirected for age <br>validation after 3 seconds. <span style='color:#ff0000'>3 Second(s) left.</span>";
		   t=setInterval(counter,0);
	 	}
}
//===============Set cookie and form validation========================
function setcookiedata(){
	//alert(document.getElementById("no").checked);
	//alert(document.form1.pass_remb.value);
msg="";
ctr=0;

if(document.form1.age.value==""){
  ctr++;
  msg+=ctr+") You have not choosen your country. Please select one then proceed.\n";
}

if(ctr==0){	
	if(document.getElementById("no").checked){	
	  window.location.replace("prevent.html");
	  return false;
	}
	if(document.form1.pass_remb.value=="yes"){
			var name="allow";
			var value="yes";
			var days="3650";
			createCookie(name,value,days);
			//document.cookie = "allow=yes";
			window.location.replace("index.html");
			//document.getElementById("setinfo").innerHTML="Now you are permissible to go anywhere";
		}
		else{
			var name="allow";
			var value="yes";
			var days="0";
			createCookie(name,value,days);
			//document.cookie = "allow=yes";
			window.location.replace("index.html");
			//document.getElementById("setinfo").innerHTML="Now you are permissible to go anywhere";
		}
	}
 else{
   alert(msg);
}
}

function createCookie(name,value,days) {
	if (days>0) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";

}




function setAge(cntry){
  if(cntry==""){
  document.getElementById("age").value="";
  }
 cntry=cntry.split(":");
 document.getElementById("age").value=cntry[0];
}