//New code added by Ranajoy Saha
//New code added by Ranajoy Saha


function SubmitData1(field, event)
{
  var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
  if (keyCode == 13)
  {
   validate();
   return false;
  }
  else
  {
	return true;
  }
}
function validate()
{
//alert ("test");
if (document.form1.make.value == "")
	{
	alert ("Please Select Make");
	document.form1.make.focus();
	return (false);
	}
if (document.form1.model.value == "")
	{
	alert ("Please Select Model");
	document.form1.model.focus();
	return (false);
	}	
if (document.form1.strZIP.value == "")
	{
	alert ("Please Enter ZIP");
	document.form1.strZIP.focus();
	return (false);
	}		
if (document.form1.strZIP.value != "")
	{
		//alert ("not null");
xmlhttp = createRequest();
if(xmlhttp != null)
{
//alert ("final");
var mid = document.form1.strZIP.value;
//alert (mid);
// call open with GET or POST, the URL, and true for asynchronous
xmlhttp.open("GET","ZIP_Details.php?zid="+mid+"&rand="+Math.random(1,10), true);
xmlhttp.onreadystatechange = callzip;
xmlhttp.send(null);
	}		
	}	
}


function createRequest()
{
	var reqObj = null;
	try {
	   reqObj = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (err)	{
	   try {
		reqObj = new ActiveXObject("Microsoft.XMLHTTP");
	   }
	   catch (err2) {
		try {
		   reqObj = new XMLHttpRequest();
		}
		catch (err3) {
		  reqObj = null;
		}
	   }
	}
	return reqObj;
}

function callback() 
{
//alert ("hello");
	if (xmlhttp.readyState == 4) {
	//alert(xmlhttp.readyState);
		//alert(xmlhttp.status);
	  if (xmlhttp.status == 200) {
	  var name = xmlhttp.responseText;
	  //alert (name);
	   var results = xmlhttp.responseText.split(",");
	//alert(results[0]);
	objLinkList 	= eval("document.form1.model");
	//objLinkList 	= eval("form1.model");
	objLinkList.length=1;
	//alert (objLinkList[0]);	
	//alert (results.length);
	document.getElementById('Layer1').innerHTML = "<ul>";
	for(i=1;i<=results[0];i++)
	{
		objLinkList.length++;
		objLinkList[i].text =results[i];
		objLinkList[i].value = results[i];
		// Chenges for right side for Particular Make - Apr - 06//
//<a class=newstxt href='+escape(document.form1.make.value)+'_'+escape(results[i])+'_det.html>'+results[i]+'</a>
	//alert(escape(document.form1.make.value)+'_'+escape(results[i])+'_det.html>'+results[i]);
  document.getElementById('Layer1').innerHTML +=  '<img src=images/ic.jpeg border=0/><a class=newstxt href='+escape(document.form1.make.value)+'_'+escape(results[i])+'_det.html>'+results[i]+'</a><br>';
	}
	
	document.getElementById('carModelContainer').style.visibility = 'visible';
	document.getElementById('Layer1').style.visibility = 'visible';
	document.getElementById('Layer1').innerHTML += '</ul>';	
	//alert(results);
	   }
      else {
         // an error occurred, handle it appropriately
      }
	}
}























// new code added //

function callbackk() 
{
    c_start=8;
    c_end=document.cookie.indexOf("/",c_start);
    mdlName=document.cookie.substring(c_start,c_end);
    //alert (mdlName);
  //alert ("hello");
  if (xmlhttp.readyState == 4) {
	//alert(xmlhttp.readyState);
		//alert(xmlhttp.status);
	  if (xmlhttp.status == 200) {
	  var name = xmlhttp.responseText;
	  //alert (name);
	   var results = xmlhttp.responseText.split(",");
	//alert(results[0]);
	objLinkList 	= eval("document.formquote.modell");
	//objLinkList 	= eval("form1.model");
	objLinkList.length=1;
	//alert (objLinkList[0]);	
	//alert (results.length);
	for(i=1;i<=results[0];i++)
	{
		objLinkList.length++;
		objLinkList[i].text =results[i];
		objLinkList[i].value = results[i];
		
		
		
		if (objLinkList[i].value==mdlName){objLinkList[i].selected=true;}
		}
    //objLinkList[2].selected=true;
	   }
      else {
         // an error occurred, handle it appropriately
      }
	}
	//return (name);
}

// new code added //




























function callzip() 
{
//alert ("hello");
	if (xmlhttp.readyState == 4)
	 {
	//alert(xmlhttp.readyState);
		//alert(xmlhttp.status);
	  if (xmlhttp.status == 200)
	   {
	  var name = xmlhttp.responseText;
	  if(name == "")
	  {
	  document.form1.action = "QuoteForm.php";
	  document.form1.method = "post";
	  document.form1.submit();
	  }
	  else
	  {
	  alert (name);
	  }
	   }
      else
	  {
	  //alert ("test");
      }
	}

}



///////////   new function added

function new_car_refresh()
{
  if (document.formquote.make2.value!="")
  {
  car_make =  document.formquote.make2.value;
  car_model = document.formquote.modell.value;
  
  setcookie();
  
  
  
  // ################## new code added ###############
  /*
  frst_name = document.formquote.strFirst.value;
  last_name = document.formquote.strLast.value;
  address = document.formquote.strAddress.value;
  zipcode = document.formquote.strZIP.value;
  ph_no1 = document.formquote.strPhone1.value;
  ph_no2 = document.formquote.strPhone2.value;
  ph_no3 = document.formquote.strPhone3.value;
  email = document.formquote.stremail.value;
  */
  // ################## new code added ###############
  
  
  
  
  //str_url = car_make+"_"+car_model+"_"+"det.html?mkCode="+car_make+"&mdlName="+car_model;
  
 str_url = car_make+"_"+car_model+"_"+"det.html?mkCode="+car_make+"&mdlName="+car_model+"&frst_name="+frst_name+"&last_name="+last_name+"&address="+address+"&zipcode="+zipcode+"&ph_no1="+ph_no1+"&ph_no2="+ph_no2+"&ph_no3="+ph_no3+"&email="+email;
// str_url = "/ecarsite_dev/Variant_Details.php?mkCode="+car_make+"&mdlName="+car_model+"&frst_name="+frst_name+"&last_name="+last_name+"&address="+address+"&zipcode="+zipcode+"&ph_no1="+ph_no1+"&ph_no2="+ph_no2+"&ph_no3="+ph_no3+"&email="+email;
 
 //str_url = car_make+"_"+car_model+"_"+"det.html?mkCode="+car_make+"&frst_name="+frst_name ;
  //alert(str_url);
  window.location=str_url;}
  
}


//################# new code added#####################

function setcookie()
{

  frst_name = document.formquote.strFirst.value;
  last_name = document.formquote.strLast.value;
  address = document.formquote.strAddress.value;
  zipcode = document.formquote.strZIP.value;
  ph_no1 = document.formquote.strPhone1.value;
  ph_no2 = document.formquote.strPhone2.value;
  ph_no3 = document.formquote.strPhone3.value;
  email = document.formquote.stremail.value;
  
  cookievalue="strFirst:"+frst_name+"/"+"strLast:"+last_name+"/"+"strAddress:"+address+"/"+"strZIP:"+zipcode+"/"+"strPhone1:"+ph_no1+"/"+"strPhone2:"+ph_no2+"/"+"strPhone3:"+ph_no3+"/"+"stremail:"+email+"/";
  
  strCookie="ecar="+cookievalue;
  
  //alert(strCookie);
  
  document.cookie=strCookie;

}


function callcookie()
{
 document.formquote.strFirst.value=getcookie("strFirst");
 document.formquote.strLast.value=getcookie("strLast");
 document.formquote.strAddress.value=getcookie("strAddress");
 document.formquote.strZIP.value=getcookie("strZIP");
 document.formquote.strPhone1.value=getcookie("strPhone1");
 document.formquote.strPhone2.value=getcookie("strPhone2");
 document.formquote.strPhone3.value=getcookie("strPhone3");
 document.formquote.stremail.value=getcookie("stremail");
 
  
 

}


function getcookie(string)
{
 //alert("testing getcookie");
 
  check=document.cookie.indexOf("ecar=");
  if (check!=-1)
  {
  start_pos=document.cookie.indexOf(string+":");
  start_pos+=(string.length)+1;
  end_pos=document.cookie.indexOf("/",start_pos);
  result=document.cookie.substring(start_pos,end_pos);
  return(result);
  }
  else
  {
    return("");
  }
 }
 
 
 //function for deleting the contents of the cookie


function delete_cookie(cookie_name)
{
  //alert("ne re ballll");
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime()-1 );
  strCookie=cookie_name +'= ; expires=' + cookie_date.toGMTString()+";";
  //alert(strCookie);
  document.cookie = strCookie;
  //document.cookie.expiration(0);
}


//################# new code added#####################
///////////////////////////////////
 
function callchange()
{
//alert ("test");
xmlhttp = createRequest();
//alert (" hi hi hi hi");
if(xmlhttp != null)
{
//alert ("final");
var mid = document.form1.make.value;
//alert (mid);
// call open with GET or POST, the URL, and true for asynchronous
xmlhttp.open("GET","Model_Details.php?mid="+mid+"&rand="+Math.random(1,10), true);
//alert("nfafhfafja");
xmlhttp.onreadystatechange = callback;
xmlhttp.send(null);
}

function focus1()
{
alert ("Focus");
}
}














/**** new code added ***************/
function callchange2(mdlname)
{
//alert (mdlname);

document.cookie="mdlname="+mdlname+"/";

xmlhttp = createRequest();
//alert (" hi hi hi hi");
if(xmlhttp != null)
{
var mid = document.formquote.make2.value;
//alert (mid);
// call open with GET or POST, the URL, and true for asynchronous
xmlhttp.open("GET","Model_Details.php?mid="+mid+"&rand="+Math.random(1,10), true);

xmlhttp.onreadystatechange =callbackk;

//callbackk(mdlname);
xmlhttp.send(null);
}

function focus1()
{
alert ("Focus");
}
// calling for the values


}
 /**********************************/







//#######################new code added#############################



function callchange21(mdlname)
{
//alert (mdlname);

document.cookie="mdlname="+mdlname+"/";

xmlhttp = createRequest();
//alert (" hi hi hi hi");
if(xmlhttp != null)
{
var mid = document.formquote.make2.value;
//alert (mid);
// call open with GET or POST, the URL, and true for asynchronous
xmlhttp.open("GET","Model_Details.php?mid="+mid+"&rand="+Math.random(1,10), true);

xmlhttp.onreadystatechange =callbackk;

//callbackk(mdlname);
xmlhttp.send(null);
}

function focus1()
{
alert ("Focus");
}
// calling for the values

callcookie();
}




function destroycookie()
{
  




//document.cookie="expires="+now();
//document.cookie.expire=now()-1;
}

function delete_cookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime()+10 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}













<!-- Newsletter part -->
function submitFinal()
{
	//alert ("test");
	/*if (document.subform2.fname.value == "")
	{
		alert ("First Name is Empty");
		document.subform2.fname.focus();
		return (false);
	}
	
	if (document.subform2.lname.value == "")
	{
		alert ("Last Name is Empty");
		document.subform2.lname.focus();
		return (false);
	}
	
	if (document.subform2.zip.value == "")
	{
		alert ("Zip Code is Empty");
		document.subform2.zip.focus();
		return (false);
	}*/
	//------------------
	if (document.subform2.emailid.value == "")
	{
		alert ("Email is Empty");
		document.subform2.emailid.focus();
		return (false);
	}
	if (document.subform2.emailid.value != "")
{
	var iChars = "!@#$%^&*()+=[]\\\;,/{}|\":<>?0123456789";
   	if (iChars.indexOf(document.subform2.emailid.value.charAt(1)) != -1)
    {
		alert ("Email Id should not start with an Numeric or special characters. \nThese are not allowed.\n Please remove them and try again.");
		document.subform2.emailid.focus();
		return false;
  	}
    if (document.subform2.emailid.value != "")
	{
		var at="@"
		var dot="."
		var str=document.subform2.emailid.value;
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)

		if (str.indexOf(at)==-1 || str.indexOf(dot)==-1)
		{
			   alert("Email-Id should have atleast one '@' and '.'")
			   document.subform2.emailid.focus();
			   return false
		}
		if (str.indexOf(at)==0 || str.indexOf(at)==lstr-1)
		{
			   alert("@ should be placed in correct postion")
			   document.subform2.emailid.focus();
			   return false
		}
		if (str.indexOf(dot)==0 || str.indexOf(dot)==lstr-1)
		{
 				alert("Please enter a valid emailid")
 				document.subform2.emailid.focus();
 				return false
		}
		if (str.indexOf(at,(lat+1))!=-1)
		{
 				alert("continous @ symbol is not allowed")
 				document.subform2.emailid.focus();
 				return false
		}
 		var varNextDot = ldot+1;
 		for(i=0; i<10; i++)
 		{
	 		if (str.indexOf(dot,(varNextDot))==varNextDot)
	 		{
		 	   alert("continuous . symbol is not allowed")
		 	   varNextDot=varNextDot+1;
		 	   document.subform2.emailid.focus();
		 	   return false
	 		 }
	 	 }

	 	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
 		 {
	 	    	alert("Please enter a valid emailid")
	 			document.subform2.emailid.focus();
	 			return false
		 }
	 	 if (str.indexOf(dot,(lat+2))==-1)
 		 {
	 			alert("Please enter a valid emailid")
	 			document.subform2.emailid.focus();
	 			return false
 		 }
		 else		 
		 {			
			//var chk = "<?= $checking ?>";
			//alert(chk);
			//return true;
			
		 }
	}

}
/*
	if (document.subform2.emailid.value != "")
	{
		alert ("not null");
		xmlhttp = createRequest();
			if(xmlhttp != null)
			{
				//alert ("final");
				var curemailid = document.subform2.emailid.value;
				//alert (mid);
				alert (curemailid);
				// call open with GET or POST, the URL, and true for asynchronous
				xmlhttp.open("GET","email_zip_validation.php?emailid="+curemailid+"&rand="+Math.random(1,10), true);
				xmlhttp.onreadystatechange = checkZipCode;
				xmlhttp.send(null);					
			}					
	}
	else
	{
					  //alert ("arun");
	}
}			
//------------------

	function createRequest()
	{
		var reqObj = null;
		try {
		   reqObj = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (err)	{
		   try {
			reqObj = new ActiveXObject("Microsoft.XMLHTTP");
		   }
		   catch (err2) {
			try {
			   reqObj = new XMLHttpRequest();
			}
			catch (err3) {
			   reqObj = null;
			}
		   }
		}
		return reqObj;
	}

	function checkZipCode() 
	{
		//alert(xmlhttp.readyState);
		if (xmlhttp.readyState == 4)
		 {
			// alert ("check");
			   if (xmlhttp.status == 200)
			   {
			// alert(xmlhttp.status);				   
				  var name = xmlhttp.responseText;
				  alert (name);
				  var result = xmlhttp.responseText.split(",");						
							
				alert("result 0 " + result[0]);
				alert("result 1 " + result[1]);
					if(result[1] == "1")
					{
						alert("Email Already exist");
					}				
					else
					{
						alert ("Thank you !!");
					}
				}
			   else
			   {
				  //alert ("xmlhttptest");
			   }
		 }	*/
	}
<!-- end of newsletter part -->		
////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////

function call_car()
{
	//alert ("test");
xmlhttp = createRequest();
if(xmlhttp != null)
{
	//alert ("done");
	var zzid = document.formquote.strZIP.value;	
	//alert (zzid);
	xmlhttp.open("GET","StateCity.php?zid="+zzid+"&rand="+Math.random(1,10), true);
	xmlhttp.onreadystatechange = callbackk3;
	xmlhttp.send(null);		
}
}
function callbackk3() 
{
//alert ("hello");
	if (xmlhttp.readyState == 4) {
	//alert(xmlhttp.readyState);
		//alert(xmlhttp.status);
	  if (xmlhttp.status == 200) {
	  var name = xmlhttp.responseText;
	  //alert (name);
	 if (name == "")
	 {
		 alert ("inavalid Zip Code");
	 }
	 
	   var results = xmlhttp.responseText.split(",");
	//alert(results[0]);
		//alert(results[1]);
			//alert(results[2]);
	objLinkList1 	= eval("document.formquote."+"strState");
	objLinkList 	= eval("document.formquote."+"strCity");
	//objLinkList 	= eval("formquote.strCity");
	objLinkList.length=1;
	//alert (objLinkList.length);	
	//alert (results.length);
	for(i=1;i<=results[0];i++)
	{
		objLinkList.length++;
		objLinkList.text =results[1];
		objLinkList.value = results[1];
	}
	for(i=2;i<=results[0];i++)
	{
		objLinkList.length++;
		objLinkList1.text =results[2];
		objLinkList1.value = results[2];		
	}	
	//alert(results);
	   }
      else {
         // an error occurred, handle it appropriately
      }
	}
}

////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////

<!--- ########### To show and Hide Signup part ############### --->
function ShowNewsSubFrm(value)
{

	if (document.getElementById('newstable').style.visibility=="" || document.getElementById('newstable').style.visibility=="hidden")
	{

			document.getElementById('newstable').style.visibility = 'visible'; 
			document.getElementById('newstable').style.position='static';
			document.getElementById('newstable1').style.visibility = 'visible'; 
			document.getElementById('newstable1').style.position='static';
	}
	else
	{
			document.getElementById('newstable').style.visibility = 'hidden';
			document.getElementById('newstable').style.position='absolute';
			document.getElementById('newstable1').style.visibility = 'hidden';
			document.getElementById('newstable1').style.position='absolute';
	}
}

<!--- ########### To show and Hide Signup part ############### --->

<!--- ########### To show and Hide Form Details part ############### --->
function showform()
{
	//alert ("test");
	if(document.getElementById('test1').style.visibility == "" || document.getElementById('test1').style.visibility == "hidden")
	{
		document.getElementById('test1').style.visibility = 'visible';
		document.getElementById('test1').style.position = 'static';
		document.getElementById('test').style.visibility = 'hidden';
		document.getElementById('test').style.position = 'static';
		
	}
	else
	{
		document.getElementById('test1').style.visibility = 'hidden';
		document.getElementById('test1').style.position = 'absolute';
		document.getElementById('test').style.visibility = 'visible';
		document.getElementById('test').style.position = 'static';
	}
}
<!--- ########### To show and Hide Form Details part ############### --->

<!--- ########### To show and Hide Form Details part ############### --->
function calltoshow()
{
	//alert ("test");
	if(document.getElementById('test1').style.visibility == "" || document.getElementById('test1').style.visibility == "hidden")
	{
		document.getElementById('test1').style.visibility = 'visible';
		document.getElementById('test1').style.position = 'static';
		document.getElementById('test').style.visibility = 'hidden';
		document.getElementById('test').style.position = 'static';
		
	}
	else
	{
		document.getElementById('test1').style.visibility = 'hidden';
		document.getElementById('test1').style.position = 'absolute';
		document.getElementById('test').style.visibility = 'visible';
		document.getElementById('test').style.position = 'static';
	}
}
<!--- ########### To show and Hide Form Details part ############### --->


function openfnc(pth)
        {
          //pth="http://" + pth +"/";
          pth="http://" + pth ;
          window.open(pth,'Editor','width=800,height=600,scrollbars=1,status=1,location=1,toolbar=1,menubar=1,left=0,top=0,resizable=1');
        }
