
function GetXmlHttpObject()
{
	
	var xmlHttp=null;
	try
	{
	 // Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
 }
return xmlHttp;
}

// Check user availability

	function CheckAvail()
	{
		var rand_no = Math.ceil(1000*Math.random())
		
		xmlHttp=GetXmlHttpObject()
		// if browser not found
		if (xmlHttp==null)
		{
			 alert ("Browser does not support HTTP Request")
			 return
		 } 
		 // Server Url
		var url="include/userchk.php"
		// Query string variable
		document.getElementById("divAvail").style.display='block';
		url=url+"?username="+document.getElementById("email").value+"&show="+rand_no;//+"&fname="+document.getElementById("txtFirstName").value+"&lname="+document.getElementById("txtLastName").value;
		// Call back function for check response state.
		xmlHttp.onreadystatechange=usernamechk 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
		
	}
	function usernamechk() 
	{ 
		document.getElementById("divAvail").innerHTML="<img src=images/loading.gif />";
		
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			// Assign server reponse to div.
			 document.getElementById("divAvail").innerHTML=xmlHttp.responseText 
		 } 
	}
	
		// Check Model List Change Search

	function ModelIdChangeSearch()
	{
		var rand_no = Math.ceil(1000*Math.random())
		var getModelId = document.getElementById("VMakeSearch").value;
		//var getModelId = carModelIdz.split("||");
		xmlHttp=GetXmlHttpObject()
		// if browser not found
		if (xmlHttp==null)
		{
			 alert ("Browser does not support HTTP Request")
			 return
		 } 
		 // Server Url
		var url="include/comp_mode_chg.php"
		// Query string variable
		//document.getElementById("divAvail").style.display='block';
		//url=url+"?CompIdz="+carModelIdz[0]+"&show="+rand_no;
		url=url+"?CompIdz="+getModelId+"&show="+rand_no;
		xmlHttp.onreadystatechange=ModelResultChkSearch 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
		
	}
	function ModelResultChkSearch() 
	{ 
		document.getElementById("SearchModelResult").innerHTML="<label>Model:</label><select name='model'><option value=''>-- Vehicle Model --</option></select><span>*</span>";
		
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			// Assign server reponse to div.
			 document.getElementById("SearchModelResult").innerHTML=xmlHttp.responseText 
		 } 
	}

	
	
	
	
// Check Model List Change

	function ModelIdChange()
	{
		var rand_no = Math.ceil(1000*Math.random())
		var getModelId = document.getElementById("VMake").value;
		//var getModelId = carModelId.split("||");
		xmlHttp=GetXmlHttpObject()
		// if browser not found
		if (xmlHttp==null)
		{
			 alert ("Browser does not support HTTP Request")
			 return
		 } 
		 // Server Url
		var url="include/comp_mode_chg.php"
		// Query string variable
		//document.getElementById("divAvail").style.display='block';
		url=url+"?CompId="+getModelId+"&show="+rand_no;
		xmlHttp.onreadystatechange=ModelResultChk 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
		
	}
	function ModelResultChk() 
	{ 
		document.getElementById("ModelResult").innerHTML="<label>Model:</label><select name='model'><option value=''>-- Vehicle Model --</option></select><span>*</span>";
		
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			// Assign server reponse to div.
			 document.getElementById("ModelResult").innerHTML=xmlHttp.responseText 
		 } 
	}
////////////////////////////////
function passwordStrength(password)
{
	var desc = new Array();
	desc[0] = "Very Weak";
	desc[1] = "Weak";
	desc[2] = "Better";
	desc[3] = "Medium";
	desc[4] = "Strong";
	desc[5] = "Strongest";

	var score   = 0;
	
	document.getElementById("passbar").style.display='block';
	document.getElementById("passbar").focus();
	
	//if password bigger than 6 give 1 point
	if (password.length > 6) score++;

	//if password has both lower and uppercase characters give 1 point	
	if ( ( password.match(/[a-z]/) ) && ( password.match(/[A-Z]/) ) ) score++;

	//if password has at least one number give 1 point
	if (password.match(/\d+/)) score++;

	//if password has at least one special caracther give 1 point
	if ( password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) )	score++;

	//if password bigger than 12 give another 1 point
	if (password.length > 12) score++;

	 document.getElementById("passwordDescription").innerHTML = desc[score];
	 document.getElementById("passwordStrength").className = "strength" + score;
}
///////////////////////////////////////////////////////////////////
				function checkIt(evt) 
				{
					evt = (evt) ? evt : window.event
					var charCode = (evt.which) ? evt.which : evt.keyCode
					if (charCode > 31 && (charCode < 48 || charCode > 57)) 
					{
						//alert("Mobile number can only be numbers.");
						return false
					}
					return true
				}
				function checkItCharac(evt) 
				{
					evt = (evt) ? evt : window.event
					var charCode = (evt.which) ? evt.which : evt.keyCode
					if (charCode > 31 && (charCode >= 65 || charCode <= 90) || (charCode >= 97 || charCode <= 122)) 
					{
						//alert("Mobile number can only be numbers.");
						return false
					}
					return true
				}
///////////////////////////////////////////////////////////////////

////////---------------------- New User Page
function checkform(){
	var error =0;
	var name="";
	var email ="";
	var address ="";
	var city ="";
	var state ="";
	var postcode ="";
	var country ="";
	var phno ="";
	var mobno ="";

	var pass ="";
	var code ="";


	if (document.FrmNewAccount.name.value=="") {
			document.FrmNewAccount.name.style.borderColor='#9E0101';
			name = "<li>Enter Your Name!</li>";
			error =1;			
	}else{
		//document.FrmNewAccount.name.style.background='#FFF';
		document.FrmNewAccount.name.style.borderColor='#C4C3C4';
	}
		var emailchk = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	if (!emailchk.test(document.FrmNewAccount.email.value)) {
			document.FrmNewAccount.email.style.borderColor='#9E0101';
			email = "<li>Please provide a valid email address!</li>";
			error =1;			
	}else{
		document.FrmNewAccount.email.style.borderColor='#C4C3C4';
	}
	if (document.FrmNewAccount.pass.value!=document.FrmNewAccount.repass.value) {
			document.FrmNewAccount.pass.style.borderColor='#9E0101';
			document.FrmNewAccount.repass.style.borderColor='#9E0101';
			pass = "<li>Password Not Match!</li>";
			error =1;			
	}else{
		document.FrmNewAccount.pass.style.borderColor='#C4C3C4';
		document.FrmNewAccount.repass.style.borderColor='#C4C3C4';
	}
	if (document.FrmNewAccount.pass.value.length<6) {
			document.FrmNewAccount.pass.style.borderColor='#9E0101';
			document.FrmNewAccount.repass.style.borderColor='#9E0101';
			pass = "<li>InValid Passowrd!</li>";
			error =1;			
	}else{
		document.FrmNewAccount.pass.style.borderColor='#C4C3C4';
		document.FrmNewAccount.repass.style.borderColor='#C4C3C4';
	}
	if (document.FrmNewAccount.contact.value=="") {
			document.FrmNewAccount.contact.style.borderColor='#9E0101';
			mobno = "<li>Enter Your Contact No. (Exp: 03331234567)!</li>";
			error =1;			
	}else{
		document.FrmNewAccount.contact.style.borderColor='#C4C3C4';
	}
	if (document.FrmNewAccount.city.value=="") {
			document.FrmNewAccount.city.style.borderColor='#9E0101';
			city = "<li>Enter Your City Name!</li>";
			error =1;			
	}else{
		document.FrmNewAccount.city.style.borderColor='#C4C3C4';
	}
	if (document.FrmNewAccount.vercode.value.length<6) {
			document.FrmNewAccount.vercode.style.borderColor='#9E0101';
			code = "<li>Security Code</li>";
			error =1;			
	}else{
		document.FrmNewAccount.vercode.style.borderColor='#C4C3C4';
	}

	
	if(error==1){
	document.getElementById("error").style.display='block';
	document.getElementById("error").focus();
	document.getElementById("error").innerHTML="<ul>" + name + email + pass + mobno +city +code + "</ul>";
	
	return false;
	}

return true;	

}
////////---------------------- Login Frm
function checkFrmLogin(){
	var error =0;
	var email ="";
	var pass ="";
	
	var emailchk = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	if (!emailchk.test(document.frmlogin.user.value)) {
			document.frmlogin.user.style.borderColor='#9E0101';
			email = "<li>Please provide a valid email address!</li>";
			error =1;			
	}else{
		document.frmlogin.user.style.borderColor='#C4C3C4';
	}
	if (document.frmlogin.pass.value.length<6) {
			document.frmlogin.pass.style.borderColor='#9E0101';
			pass = "<li>Enter Valid Password</li>";
			error =1;			
	}else{
		document.frmlogin.pass.style.borderColor='#C4C3C4';
	}
	
	if(error==1){
	document.getElementById("error1").style.display='block';
	document.getElementById("error1").focus();
	document.getElementById("error1").innerHTML="<ul>" + email +pass +"</ul>";
	
	return false;
	}

return true;	
}
////////---------------------- Tell Friend Frm
function checkFrmTellFrnd(){
	var error =0;
	var uname ="";
	var uemail ="";
	var fname ="";
	var femail ="";
	var meassage ="";
	var vercode ="";
	
	var emailchk = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	
	if (document.tellafrd.uname.value=="") {
			document.tellafrd.uname.style.borderColor='#9E0101';
			uname = "<li>Enter Your Name!</li>";
			error =1;			
	}else{
		document.tellafrd.uname.style.borderColor='#C4C3C4';
	}

	if (!emailchk.test(document.tellafrd.uemail.value)) {
			document.tellafrd.uemail.style.borderColor='#9E0101';
			uemail = "<li>Provide Your valid email address!</li>";
			error =1;			
	}else{
		document.tellafrd.uemail.style.borderColor='#C4C3C4';
	}
	
	if (document.tellafrd.fname.value=="") {
			document.tellafrd.fname.style.borderColor='#9E0101';
			fname = "<li>Enter Your Friend Name!</li>";
			error =1;			
	}else{
		document.tellafrd.fname.style.borderColor='#C4C3C4';
	}
	if (!emailchk.test(document.tellafrd.femail.value)) {
			document.tellafrd.femail.style.borderColor='#9E0101';
			femail = "<li>Please provide Your Friend valid email address!</li>";
			error =1;			
	}else{
		document.tellafrd.femail.style.borderColor='#C4C3C4';
	}
	if (document.tellafrd.meassage.value=="") {
			document.tellafrd.meassage.style.borderColor='#9E0101';
			meassage = "<li>Enter Your Meassage!</li>";
			error =1;			
	}else{
		document.tellafrd.meassage.style.borderColor='#C4C3C4';
	}
	if (document.tellafrd.vercode.value.length<6) {
			document.tellafrd.vercode.style.borderColor='#9E0101';
			vercode = "<li>Security Code</li>";
			error =1;			
	}else{
		document.tellafrd.vercode.style.borderColor='#C4C3C4';
	}

	if(error==1){
	document.getElementById("error").style.display='block';
	document.getElementById("error").focus();
	document.getElementById("error").innerHTML="<ul>" + uname +uemail + fname +femail+meassage +vercode+ "</ul>";
	
	return false;
	}

return true;	
}
////////---------------------- Subscribe Email Frm
function checkFrmSubEmail(){
	var error =0;
	var email ="";
	
	var emailchk = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;

	if (!emailchk.test(document.SubscribeEmail.email.value)) {
			document.SubscribeEmail.email.style.borderColor='#9E0101';
			email = "<li>Invalid email address!</li>";
			error =1;			
	}else{
		document.SubscribeEmail.email.style.borderColor='#C4C3C4';
	}


	if(error==1){
	document.getElementById("errorSub").style.display='block';
	document.getElementById("errorSub").focus();
	document.getElementById("errorSub").innerHTML="<ul>" + email + "</ul>";
	
	return false;
	}

return true;	
}
////////---------------------- Forget Password Frm
function chkFrm4GetPass(){
	var error =0;
	var email ="";
	var code ="";
	
	var emailchk = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	if (!emailchk.test(document.pass4get.email.value)) {
			document.pass4get.email.style.borderColor='#9E0101';
			email = "<li>Please provide a valid email address!</li>";
			error =1;			
	}else{
		document.pass4get.email.style.borderColor='#C4C3C4';
	}
	if (document.pass4get.vercode.value.length<6) {
			document.pass4get.vercode.style.borderColor='#9E0101';
			code = "<li>Security Code</li>";
			error =1;			
	}else{
		document.pass4get.vercode.style.borderColor='#C4C3C4';
	}
	
	if(error==1){
	document.getElementById("error").style.display='block';
	document.getElementById("error").focus();
	document.getElementById("error").innerHTML="<ul>" + email +code+"</ul>";
	
	return false;
	}

return true;	
}
////////---------------------- Products Info change
function ProFtsSepc(ide){
	if(ide==1){
		document.getElementById("features").style.display='block';
		document.getElementById("specification").style.display='none';
		}
	if(ide==2){
		document.getElementById("features").style.display='none';
		document.getElementById("specification").style.display='block';
		}
	
}
////////---------------------- Change Currency
function ChgCurrency(int){
	if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("currencychange").innerHTML=xmlhttp.responseText;
    }
  }
  var rand_no = Math.ceil(1000*Math.random())
  document.getElementById("currencychange").innerHTML="<?php $_SESSION['Currency']="+int+"; ?>";
xmlhttp.open("GET","include/chgcurrency.php?c="+int+"&code"+rand_no,true);
xmlhttp.send();
	//setTimeout("window.location.reload()",1000); 
	location.reload(true);
	//document.getElementById("currencychange").innerHTML="<?php session_start(); $_SESSION['Currency']="+int+"; ?> "+int+"";


	//document.write('<s'+'cript type="text/javascript" src="javascript.php"></s'+'cript>');
	//document.getElementById("currencychange").innerHTML="Hello "+int+":";
	
	//document.getElementById("currencychange").innerHTML="<meta http-equiv='refresh' content='0';URL='#"+int+"'>"+int+":";
	}
////////---------------------- Change Currency Get Option 2
function ChgCurrencyGet(int){
	//var rand_no = Math.ceil(1000*Math.random())
	location.href="currency.html?currency="+int+"&mode=change";
}
///////////////////////////////////////////////////////////////////
// Popup window function
	function basicPopup(url) {
popupWindow = window.open(url,'popUpWindow','height=650,width=850,left=50,top=10,resizable=yes,scrollbars=yes,toolbar=no,menubar=yes,location=no,directories=no, status=no');
	}
///////////////////////////////////////
// Remove Alert function
function deleteAlert(name,id){
	var conBox = confirm("Are you sure you want to delete: " + name);
	if(conBox){ 
		location.href="?del="+ id + "&mode=remove";
	}else{
		return;
	}
}
