/*function setCookie(c_name)
{
document.cookie=c_name+ "=test";
}*/
function checkexit()
{	
var popwin=window.open('exitpopup.php' ,'ExitPopup','width=500,height=600,resizable=1,status=0,scrollbars=1,menubar=0');
/*setCookie(c_name);
if(document.cookie.c_name=="test")
{
var popwin=window.open('exitpopup.php' ,'ExitPopup','width=500,height=600,resizable=1,status=0,scrollbars=1,menubar=0');
}*/
}
/*
var page = "exitpopup.php";
var windowprops = "width=500,height=600,resizable=1,status=0,scrollbars=1,menubar=0";

function GetCookie (name) {  
var arg = name + "=";  
var alen = arg.length;  
var clen = document.cookie.length;  
var i = 0;  
while (i < clen) {    
var j = i + alen;    
if (document.cookie.substring(i, j) == arg)      
return getCookieVal (j);    
i = document.cookie.indexOf(" ", i) + 1;    
if (i == 0) break;   
}  
return null;
}
function SetCookie (name, value) {  
var argv = SetCookie.arguments;  
var argc = SetCookie.arguments.length;  
var expires = (argc > 2) ? argv[2] : null;  
var path = (argc > 3) ? argv[3] : null;  
var domain = (argc > 4) ? argv[4] : null;  
var secure = (argc > 5) ? argv[5] : false;  
document.cookie = name + "=" + escape (value) + 
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
((path == null) ? "" : ("; path=" + path)) +  
((domain == null) ? "" : ("; domain=" + domain)) +    
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {  
var exp = new Date();  
exp.setTime (exp.getTime() - 1);  
var cval = GetCookie (name);  
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
var exp = new Date(); 
exp.setTime(exp.getTime() + (60*60*1000));
function amt(){
var count = GetCookie('count')
if(count == null) {
SetCookie('count','1')
return 1
}
else {
var newcount = parseInt(count) + 1;
DeleteCookie('count')
SetCookie('count',newcount,exp)
return count
   }
}
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

function checkexit() {
var count = GetCookie('count');
if (count == null) {
count=1;
SetCookie('count', count, exp);

window.open(page, "", windowprops);

}
else {
count++;
SetCookie('count', count, exp);
   }
}*/
function emailcheck(str) {

var at="@"

var dot="."

var lat=str.indexOf(at)

var lstr=str.length

var ldot=str.indexOf(dot)

if (str.indexOf(at)==-1){
alert("Invalid E-mail ID")
return false
}



if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){

alert("Invalid E-mail ID")

return false

}



if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){

alert("Invalid E-mail ID")

return false

}



if (str.indexOf(at,(lat+1))!=-1){

alert("Invalid E-mail ID")

return false

}



if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){

alert("Invalid E-mail ID")

return false

}



if (str.indexOf(dot,(lat+2))==-1){

alert("Invalid E-mail ID")

return false

}



if (str.indexOf(" ")!=-1){

alert("Invalid E-mail ID")

return false

}
return true 
}





function formvalidation()

{	

if((document.registration.freedvd1.checked==false)&&(document.registration.freedvd2.checked==false))
{
alert ( "Please select a FREE Consultation or DVD" );
document.registration.freedvd1.focus();
//checkexit();
return false;

}

if(document.registration.freedvd2.checked==true)

{

if (document.registration.scheduling_period.selectedIndex==0)

{

alert ( "Please select Preferred time for an appointment" );

document.registration.scheduling_period.focus();

return false;

}

if (document.registration.scheduling_day.selectedIndex==0)

{

alert ( "Please Select Day of Week" );

document.registration.scheduling_day.focus();

return false;

}

if (document.registration.scheduling_time.selectedIndex==0)

{

alert ( "Please Select Time" );

document.registration.scheduling_time.focus();

return false;

}

if (document.registration.consultation_office.selectedIndex==0)

{

alert ( "Please select a Consultation Office" );

document.registration.consultation_office.focus();

return false;

}

}




if (document.registration.title.selectedIndex==0)

 {

alert ( "Please select a title" );

document.registration.title.focus();

return false;

}

if(document.registration.firstname.value=="")

	{

	alert("Enter First Name");

	document.registration.firstname.focus();

	return false;

	}

if(document.registration.lastname.value=="")

	{

	alert("Enter Last Name");

	document.registration.lastname.focus();

	return false;

	}



if(document.registration.streetaddress.value=="") 

	{

	alert("Enter Street Address");

	document.registration.streetaddress.focus();

	return false;

	}

if(document.registration.streetaddress.value.length<6)

	{

	alert("Enter Valid Street Address");

	document.registration.streetaddress.focus();

	return false;

	}



if(document.registration.city.value=="")

	{

	alert("Enter City");

	document.registration.city.focus();

	return false;

	}

if(document.registration.city.value.length<4)

	{

	alert("Enter Valid City Name");

	document.registration.scity.focus();

	return false;

	}	

if(document.registration.state.selectedIndex==0)

 	{

	alert ( "Please select State" );

	document.registration.state.focus();

	return false;

	}

if(document.registration.zipcode.value=="")

	{

	alert("Enter Zip Code");

	document.registration.zipcode.focus();

	return false;

	}

if(document.registration.zipcode.value.length<5)

	{

	alert("Enter Valid Zip Code");

	document.registration.zipcode.focus();

	return false;

	}

	if(document.registration.homephone.value=="")

	{

	alert("Enter Phone number");

	document.registration.homephone.focus();

	return false;

	}

    if(document.registration.workphone.value=="")

	{

	alert("Enter Work/Mobile Phone number");

	document.registration.workphone.focus();

	return false;

	}	

	 if(document.registration.emailaddress.value=="")

	{

	alert("Enter E-mail Address");

	document.registration.emailaddress.focus();

	return false;

	}

	var emailID=document.registration.emailaddress;

	if ((emailID.value==null)||(emailID.value==""))

	{

		alert("Please Enter your Email ID")

		emailID.focus()

		return false;

	}

	if (emailcheck(emailID.value)==false)

	{

		emailID.value=""

		emailID.focus()

		return false;

	}
	
if(document.registration.Code.value=="")

	{

	alert("Enter Captcha Code");

	document.registration.Code.focus();

	return false;

	}
 		 return true;

}



function numbersonly(e){

var unicode=e.charCode? e.charCode : e.keyCode

if(unicode==9 || unicode==46 || unicode==127)

{

return true;

}

if (unicode!=8){ 

if (unicode<48||unicode>57) 

return false 

}

return true;

}



function Validate()

{

var x = document.registration.workphone.value;

if(isNaN(x)|| x.indexOf(" ")!=-1){

alert("Enter numeric value");return false; }

if (x.length > 10 || x.length > 8 ){

alert("enter 10 or 8 characters"); return false;

}

if (x.charAt(0)!="9" || x.charAt(0)!="2"){

alert("it should start with 9 or 2 ");

return false

}

return true

}

function Validatehome()

{

var x = document.registration.homephone.value;

if(isNaN(x)|| x.indexOf(" ")!=-1){

alert("Enter numeric value");return false; }

if (x.length > 10 || x.length > 8 ){

alert("enter 10 or 8 characters"); return false;

}

if (x.charAt(0)!="9" || x.charAt(0)!="2"){

alert("it should start with 9 or 2 ");

return false

}

return true

}

function Validatemobile()

{

var x = document.registration.mobilephone.value;

if(isNaN(x)|| x.indexOf(" ")!=-1){

alert("Enter numeric value");return false; }

if (x.length > 10 || x.length > 8 ){

alert("enter 10 or 8 characters"); return false;

}

if (x.charAt(0)!="9" || x.charAt(0)!="2"){

alert("it should start with 9 or 2 ");

return false

}

return true

}



function checkpopup()

{

if(document.popup.username.value=="")

	{

	alert("Enter Your Name");

	document.popup.username.focus();

	return false;

	}



if(document.popup.email.value=="")

	{

	alert("Enter E-mail Address");

	document.popup.email.focus();

	return false;

	}

	var emailID=document.popup.email;

	if ((emailID.value==null)||(emailID.value==""))

	{

		alert("Please Enter your Email ID")

		emailID.focus()

		return false;

	}

	if (emailcheck(emailID.value)==false)

	{

		emailID.value=""

		emailID.focus()

		return false;

	}	

	return true;

}

//Thank you form validation
function formvalidation1()

{	

/*if((document.registration.freedvd1.checked==false)&&(document.registration.freedvd2.checked==false))
{
alert ( "Please select atleast one offer" );
document.registration.freedvd1.focus();
//checkexit();
return false;

}*/

//if(document.registration.freedvd2.checked==true)

//{

if (document.registration.scheduling_period.selectedIndex==0)

{

alert ( "Please select Preferred time for an appointment" );

document.registration.scheduling_period.focus();

return false;

}

if (document.registration.scheduling_day.selectedIndex==0)

{

alert ( "Please Select Day of Week" );

document.registration.scheduling_day.focus();

return false;

}

if (document.registration.scheduling_time.selectedIndex==0)

{

alert ( "Please Select Time" );

document.registration.scheduling_time.focus();

return false;

}

if (document.registration.consultation_office.selectedIndex==0)

{

alert ( "Please select a Consultation Office" );

document.registration.consultation_office.focus();

return false;

}

//}




if (document.registration.title.selectedIndex==0)

 {

alert ( "Please select a title" );

document.registration.title.focus();

return false;

}

if(document.registration.firstname.value=="")

	{

	alert("Enter First Name");

	document.registration.firstname.focus();

	return false;

	}

if(document.registration.lastname.value=="")

	{

	alert("Enter Last Name");

	document.registration.lastname.focus();

	return false;

	}



if(document.registration.streetaddress.value=="") 

	{

	alert("Enter Street Address");

	document.registration.streetaddress.focus();

	return false;

	}

if(document.registration.streetaddress.value.length<6)

	{

	alert("Enter Valid Street Address");

	document.registration.streetaddress.focus();

	return false;

	}



if(document.registration.city.value=="")

	{

	alert("Enter City");

	document.registration.city.focus();

	return false;

	}

if(document.registration.city.value.length<4)

	{

	alert("Enter Valid City Name");

	document.registration.scity.focus();

	return false;

	}	

if(document.registration.state.selectedIndex==0)

 	{

	alert ( "Please select State" );

	document.registration.state.focus();

	return false;

	}

if(document.registration.zipcode.value=="")

	{

	alert("Enter Zip Code");

	document.registration.zipcode.focus();

	return false;

	}

if(document.registration.zipcode.value.length<5)

	{

	alert("Enter Valid Zip Code");

	document.registration.zipcode.focus();

	return false;

	}

	if(document.registration.homephone.value=="")

	{

	alert("Enter Phone number");

	document.registration.homephone.focus();

	return false;

	}

    if(document.registration.workphone.value=="")

	{

	alert("Enter Work/Mobile Phone number");

	document.registration.workphone.focus();

	return false;

	}	

	 if(document.registration.emailaddress.value=="")

	{

	alert("Enter E-mail Address");

	document.registration.emailaddress.focus();

	return false;

	}

	var emailID=document.registration.emailaddress;

	if ((emailID.value==null)||(emailID.value==""))

	{

		alert("Please Enter your Email ID")

		emailID.focus()

		return false;

	}

	if (emailcheck(emailID.value)==false)

	{

		emailID.value=""

		emailID.focus()

		return false;

	}
	
if(document.registration.Code.value=="")

	{

	alert("Enter Captcha Code");

	document.registration.Code.focus();

	return false;

	}
 		 return true;

}
