/* function for opening popup window */
/*function openpopup(url,popup_name,height,width,other_properties)
{
	var win_url=url;
	var win_height=height;
	var win_width=width;
	var popup_name=popup_name;
	var other_properties=other_properties;
	
	win_options="height="+win_height+",width="+win_width;
	if(other_properties!="")
	{
		win_options=win_options+","+other_properties;
	}
	win_option +=  ',resize=yes,scroll=yes';
	alert(win_options);
	window.open(win_url,popup_name,win_options);
}*/
//this function created by bhavin
function CreateBookmarkLink() {
       title="<?php echo SITE_URL.$_SERVER['REQUEST_URI'];?>";
       url = "<?php echo SITE_URL.$_SERVER['REQUEST_URI'];?>";
		
		
		if (window.sidebar) { // Mozilla Firefox Bookmark 

			window.sidebar.addPanel(title,url,""); 
			return false;
			
		}else if( window.external ) { // IE Favorite
			
			window.external.AddFavorite(url,title); 
			
		}
		else if(window.opera && window.print) { // Opera Hotlist 
			
			return true; 
		
		}
}





function FavoriteCalling(){
	
	if (window.sidebar) { // Mozilla Firefox Bookmark
	window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
	window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
	return true; }

}
function checkvalidemail(formname,fieldname,message)
{ 
	 var emails=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
	var membermailid = eval("document."+formname+"."+fieldname+".value");
			
	result1=membermailid.search(emails);
	if(result1==-1)
	{
		alert(message);
		eval("document."+formname+"."+fieldname+".focus()");
		eval("document."+formname+"."+fieldname+".value"+"=''");
		return false;
	}
	return true;
}

function Mycheckvalidemail(id,message)
{ 
	 var emails=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
	var membermailid = document.getElementById(id).value;
			
	result1=membermailid.search(emails);
	if(result1==-1)
	{
		alert(message);
		document.getElementById(id).focus();
		document.getElementById(id).value='';
		return false;
	}
	return true;
}

function CheckingNull(formname,fieldname,message)

{
	var fieldval = eval("document."+formname+"."+fieldname+".value");
	
	fieldval= fieldval.replace(/^\s+|\s+$/g, "");
	
	if( fieldval == '')
	 {
	  	alert(message);
	  	
	  	eval("document."+formname+"."+fieldname+".value"+"=''");
	  	eval("document."+formname+"."+fieldname+".focus()");
	 	return false;
	 }
	 return true;
}

function MyCheckingNull(id,message)
{
	

	var fieldval = document.getElementById(id).value;
	
	fieldval= fieldval.replace(/^\s+|\s+$/g, "");
	
	if( fieldval == '')
	 {
	  	alert(message);
	  	document.getElementById(id).value='';
	  	document.getElementById(id).focus();
	 	return false;
	 }
	 return true;
}
function Trim(Value)
{
		return Value.replace(/^\s+|\s+$/g, "");
}
function chksearchpara() {

	if(document.searchbyproductname.productname.value == '') {
		alert("Please Enter The Name of Product");
		document.searchbyproductname.productname.focus;
		return false;
	}
	else {
		document.searchbyproductname.productname.value = Trim(document.searchbyproductname.productname.value);
		
	}
}
function Check_search() 
{
	var productname;
	//var ueresultnull;
	
	productname = CheckingNull("searchbyproductname","productname","Enter Valid Product Name");
	if(productname == false)
	{
		return false;
	}
//	else
//	{
//		ueresult = checkvalidemail("frmdiscountpage","txt_newsletter","Enter Valid Email Address");
//		if(ueresult == false)
//		{
//			return false;
//		}	
//	}
}
function openpopup(url,popup_name,height,width,other_properties)
{	
	var left		= parseInt((screen.width-350)/2);
	var top			= parseInt((screen.height-300)/2)	
	var win_options = 'height='+height+',width='+width+',resizable=no,' 
	+ 'scrollbars=no,left=' + left + ',top=' + top;
	window.open(url,popup_name,win_options); 
}



function Check_email_the_lowest_price() 
{
	/*var uname;
	
	uname = CheckingNull("frm_email_the_lowest_price","uname","Enter Your Name.");
	if(uname == false)
	{
		return false;
	} */
	
	var ueresult;
	var ueresultnull;
	var feresultnull;
	var feresult;
	
	ueresultnull = CheckingNull("frm_email_the_lowest_price","uemail","Enter Valid Your Email");
	if(ueresultnull == false)
	{
		return false;
	}
	
	ueresult = checkvalidemail("frm_email_the_lowest_price","uemail","Enter Valid Your Email");
	if(ueresult == false)
	{
		return false;
	}
}
function frmordervalidate()
{
	if (document.frmordertracking.orderid.value=="")
	{
		document.frmordertracking.orderid.focus();
		alert("Enter Valid Sales Receipt No or Order No !");
		return false;
	}
	if (document.frmordertracking.zipcode.value=="")
	{
		document.frmordertracking.zipcode.focus();
		alert("Enter Valid Billing Zip Code !");
		return false;
	}
	
	return true;
}
function Check_Customer_Servey() 
{
	var ueresult;
	var rdemail;
	var ueresultnull;
	
	if(document.frm_servey.rd_email_confirm[0].checked)
	{
		ueresultnull = CheckingNull("frm_servey","email_address","Enter Valid Email Address");
		if(ueresultnull == false)
		{
			return false;
		}
		else
		{
			ueresult = checkvalidemail("frm_servey","email_address","Enter Valid Email Address");
			if(ueresult == false)
			{
				return false;
			}	
		}
	}	
}

function Check_Left_Discount() 
{
	var ueresult;
	var ueresultnull;
	ueresultnull = CheckingNull("frmdiscount","txt_newsletter","Enter Valid Email Address");
	if(ueresultnull == false){
		return false;
	}
	else{
		ueresult = checkvalidemail("frmdiscount","txt_newsletter","Enter Valid Email Address");
		if(ueresult == false)
		{
			return false;
		}	
	}
}	

function Check_Discount_Club() 
{
	var ueresult;
	var ueresultnull;
	
	ueresultnull = CheckingNull("frmdiscountpage","txt_newsletter","Enter Valid Email Address");
	if(ueresultnull == false)
	{
		return false;
	}
	else
	{
		ueresult = checkvalidemail("frmdiscountpage","txt_newsletter","Enter Valid Email Address");
		if(ueresult == false)
		{
			return false;
		}	
	}
}


//added by ashini
//this function is use for pricematch
function pricematch_validate(){
	var name;
	var phone;
	var email;
	var mobility;
	var model;
	var cprice;
	var dprice;
	var cname;
	var url;
	 
	name=CheckingNull("frm_pricematch","brand","Enter Valid Name");
	if(name == false){
		return false;
	}

	
	phone=CheckingNull("frm_pricematch","serial","Enter Valid Phone Number");
	if(phone == false){
		return false;
	}
	if (isNaN(document.frm_pricematch.serial.value))
			{
				alert("Enter Valid Phone Number");
				document.frm_pricematch.serial.value = '';
				document.frm_pricematch.serial.focus();
				return false;
			}
	email=CheckingNull("frm_pricematch","serial2","Enter Valid Email Address");
	if(email == false){
		return false;
	}
	email = checkvalidemail("frm_pricematch","serial2","Enter Valid Email Address");
			if(email == false)
			{
				return false;
			}
	
	if (document.frm_pricematch.serial2.value != document.frm_pricematch.serial2.value)	
				{
					alert("Email & Confirm Email should be same.");
					document.frm_contactus.txt_cemail.value = '';
					document.frm_contactus.txt_cemail.focus();
					return false;
				}
	mobility=CheckingNull("frm_pricematch","serial3","Enter Valid Mobility Product");
	if(mobility == false){
		return false;
	}
	model=CheckingNull("frm_pricematch","serial4","Enter Valid Model");
	if(model == false){
		return false;
	}
	cprice=CheckingNull("frm_pricematch","serial5","Enter Valid Competetior's Price");
	if(cprice == false){
		return false;
	}
	dprice=CheckingNull("frm_pricematch","serial7","Enter Valid TopMobility.com Price");
	if(dprice == false){
		return false;
	}
	cname=CheckingNull("frm_pricematch","serial8","Enter Valid Competitor Business Name");
	if(cname == false){
		return false;
	}
	url=CheckingNull("frm_pricematch","serial9","Enter Valid Exact URL of product on Competitor's site");
	if(url == false){
		return false;
	}
}






// Added By Yogesh
// This Function is used for contact us form
function Check_Contact_Us() 
{
	
	var firstname;
	var lastname;
	var phone;
	var email;
	var message;
	
	firstname = MyCheckingNull("txt_fname","Enter Valid First Name");
	if(firstname == false)
	{
		return false;
	}

	lastname = MyCheckingNull("txt_lname","Enter Valid Last Name");
	if(lastname == false)
	{
		return false;
	}
	
	var optobj =document.getElementById("rd_contact");

	if (optobj[0].checked)
	{
		phone = MyCheckingNull("txt_ph_no","Enter Valid Phone Number");
		if(phone == false)
		{
			return false;
		}
		else
		{
			if (isNaN(document.getElementById("txt_ph_no").value))
			{
				alert("Enter Valid Phone Number");
				document.getElementById("txt_ph_no").value = '';
				document.getElementById("txt_ph_no").focus();
				return false;
			}
		}
	}

//	if (optobj[1].checked)
//	{
		email = MyCheckingNull("txt_email","Enter Valid Email Address");

		if(email == false)
		{
			return false;
		}
		else
		{
			email = checkvalidemail("txt_email","Enter Valid Email Address");
			if(email == false)
			{
				return false;
			}
		}
		cemail = checkvalidemail("txt_cemail","Enter Valid Confirm Email Address");
		if(cemail == false)
		{
			return false;
		}
		else
		{
			if (document.getElementById("txt_email").value != document.getElementById("txt_cemail").value)	
			{
				alert("Email & Confirm Email should be same.");
				document.getElementById("txt_cemail").value = '';
				document.getElementById("txt_cemail").focus();
				return false;
			}
		}
		//}
	//}

	if (document.getElementById("txt_zip").value != "")
	{
		if (isNaN(document.frm_contactus.txt_zip.value))
		{
			alert("Enter Valid Zip Code");
			document.getElementById("txt_zip").value = '';
			document.getElementById("txt_zip").focus();
			return false;
		}
	}
	
	message = MyCheckingNull("txt_message","Enter Message");
	if(message == false)
	{
		return false;
	}
}


// This Function is used for the update customer information
function Check_Cust_Update_Billing() 
{
	var bill_firstname;
	var bill_midname;
	var bill_lastname;
	var bill_address1;
	var bill_address2;
	var bill_city;
	var bill_state;
	var bill_zip;
	var bill_email;
	var bill_veri_email;
	var bill_homecode;
	var bill_homephone;
	

	bill_firstname = CheckingNull("frmshopcart","billingfirstname","Enter Billing First Name");
	if(bill_firstname == false)
	{
		return false;
	}
	
	/*bill_midname = CheckingNull("frmshopcart","BillingMiddleInitial","Enter Billing Middle Name");
	if(bill_midname == false)
	{
		return false;
	}*/
	
	bill_lastname = CheckingNull("frmshopcart","billinglastname","Enter Billing Last Name");
	if(bill_lastname == false)
	{
		return false;
	}
	
	/*bill_compname = CheckingNull("frmshopcart","billingcompany","Enter Company Name");
	if(bill_compname == false)
	{
		return false;
	}*/
	
	bill_address1 = CheckingNull("frmshopcart","billingaddress1","Enter Billing Address");
	if(bill_address1 == false)
	{
		return false;
	}
/*
	bill_address2 = CheckingNull("frmshopcart","billingaddress2","Enter Billing Address");
	if(bill_address2 == false)
	{
		return false;
	}
*/
	bill_city = CheckingNull("frmshopcart","billingcity","Enter Billing City");
	if(bill_city == false)
	{
		return false;
	}

	bill_state = CheckingNull("frmshopcart","billingstate","Select Billing State");
	if(bill_state == false)
	{
		return false;
	}

	bill_zip = CheckingNull("frmshopcart","billingzip","Enter Billing Zip code");
	if(bill_zip == false)
	{
		return false;
	}

	if (document.frmshopcart.billingzip.value != "")
	{
		if (isNaN(document.frmshopcart.billingzip.value))
		{
			alert("Enter Valid Zip Code");
			document.frmshopcart.billingzip.value = '';
			document.frmshopcart.billingzip.focus();
			return false;
		}
	}
	
	bill_email = checkvalidemail("frmshopcart","billingemail","Enter Billing Email Address");
	if(bill_email == false)
	{
		return false;
	}
	bill_email = checkvalidemail("frmshopcart","billingemail","Enter Valid Email Address");
	if(bill_email == false)
	{
		return false;
	}

	bill_veri_email = checkvalidemail("frmshopcart","billingveriemail","Enter Billing Verify Email Address");
	if(bill_veri_email == false)
	{
		return false;
	}
	else
	{
		if (document.frmshopcart.billingemail.value != document.frmshopcart.billingveriemail.value)	
		{
			alert("Billing Email & Billing Verify Email should be same.");
			document.frmshopcart.billingveriemail.value='';
			document.frmshopcart.billingveriemail.focus();
			return false;
		}
	}
	bill_veri_email = checkvalidemail("frmshopcart","billingveriemail","Enter Billing Verify Email Address");
	if(bill_veri_email == false)
	{
		return false;
	}
	

	bill_homecode = CheckingNull("frmshopcart","Billing_Home_Code","Enter Billing Home Phone");
	if(bill_homecode == false)
	{
		return false;
	}
	if (document.frmshopcart.Billing_Home_Code.value != "")
	{
		if (isNaN(document.frmshopcart.Billing_Home_Code.value))
		{
			alert("Enter Valid Billing Home Phone Code");
			document.frmshopcart.Billing_Home_Code.value = '';
			document.frmshopcart.Billing_Home_Code.focus();
			return false;
		}
	}


	bill_homephone = CheckingNull("frmshopcart","Billing_Home_Phone","Enter Billing Home Phone");
	if(bill_homephone == false)
	{
		return false;
	}
	if (document.frmshopcart.Billing_Home_Phone.value != "")
	{
		if (isNaN(document.frmshopcart.Billing_Home_Phone.value))
		{
			alert("Enter Valid Billing Home Phone Number");
			document.frmshopcart.Billing_Home_Phone.value = '';
			document.frmshopcart.Billing_Home_Phone.focus();
			return false;
		}
	}
	
	if (document.frmshopcart.Billing_Work_Code.value != "")
	{
		if (isNaN(document.frmshopcart.Billing_Work_Code.value))
		{
			alert("Enter Valid Billing Work Phone Code");
			document.frmshopcart.Billing_Work_Code.value = '';
			document.frmshopcart.Billing_Work_Code.focus();
			return false;
		}
	}
	
	if (document.frmshopcart.Billing_Work_Phone.value != "")
	{
		if (isNaN(document.frmshopcart.Billing_Work_Phone.value))
		{
			alert("Enter Valid Billing Work Phone Number");
			document.frmshopcart.Billing_Work_Phone.value = '';
			document.frmshopcart.Billing_Work_Phone.focus();
			return false;
		}
	}
	
	if (document.frmshopcart.Billing_Fax_Code.value != "")
	{
		if (isNaN(document.frmshopcart.Billing_Fax_Code.value))
		{
			alert("Enter Valid Billing Fax Code");
			document.frmshopcart.Billing_Fax_Code.value = '';
			document.frmshopcart.Billing_Fax_Code.focus();
			return false;
		}
	}
	
	if (document.frmshopcart.Billing_Fax_Phone.value != "")
	{
		if (isNaN(document.frmshopcart.Billing_Fax_Phone.value))
		{
			alert("Enter Valid Billing Fax Number");
			document.frmshopcart.Billing_Fax_Phone.value = '';
			document.frmshopcart.Billing_Fax_Phone.focus();
			return false;
		}
	}
	


	return true;	
}

function Check_Cust_Update_Shipping() 
{
	
	var ship_firstname;
	var ship_midname;
	var ship_lastname;
	var ship_address1;
	var ship_address2;
	var ship_city;
	var ship_state;
	var ship_zip;
	var ship_email;
	var ship_homecode;
	var ship_homephone;

	
	ship_firstname = MyCheckingNull("shippingfirstname","Enter Shipping First Name");
	if(ship_firstname == false)
	{
		return false;
	}
	
	/*ship_midname = MyCheckingNull("ShippingMiddleInitial","Enter Shipping Middle Name");
	if(ship_midname == false)
	{
		return false;
	}
*/


	ship_lastname = MyCheckingNull("shippinglastname","Enter Shipping Last Name");
	if(ship_lastname == false)
	{
		return false;
	}

	ship_address1 = MyCheckingNull("shippingaddress1","Enter Shipping Address");
	if(ship_address1 == false)
	{
		return false;
	}

	ship_city = MyCheckingNull("shippingcity","Enter Shipping City");
	if(ship_city == false)
	{
		return false;
	}

	ship_state = MyCheckingNull("shippingstate","Select Shipping State");
	if(ship_state == false)
	{
		return false;
	}

	ship_zip = MyCheckingNull("shippingzip","Enter Shipping Postal Code");
	if(ship_zip == false)
	{
		return false;
	}

	/*if (document.getElementById("shippingzip").value != "")
	{
		if (isNaN(document.getElementById("shippingzip").value))
		{
			alert("Enter Valid Postal Code");
			document.getElementById("shippingzip").value = '';
			document.getElementById("shippingzip").focus();
			return false;
		}
	}*/
	
	ship_email = checkvalidemail("frmshopcart","shippingemail","Enter Shipping Email Address");
	if(ship_email == false)
	{
		return false;
	}
	bill_email = checkvalidemail("frmshopcart","shippingemail","Enter Valid Email Address");
	if(ship_email == false)
	{
		return false;
	}
	
	ship_homecode = MyCheckingNull("Shipping_Home_Code","Enter Shipping Home Phone");
	if(ship_homecode == false)
	{
		return false;
	}
	if (document.getElementById("Shipping_Home_Code").value != "")
	{
		if (isNaN(document.getElementById("Shipping_Home_Code").value))
		{
			alert("Enter Valid Shopping Home Phone Code");
			document.getElementById("Shipping_Home_Code").value = '';
			document.getElementById("Shipping_Home_Code").focus();
			return false;
		}
	}


	ship_homephone = MyCheckingNull("Shipping_Home_Phone","Enter Shipping Home Phone");
	if(ship_homephone == false)
	{
		return false;
	}
	if (document.getElementById("Shipping_Home_Phone").value != "")
	{
		if (isNaN(document.getElementById("Shipping_Home_Phone").value))
		{
			alert("Enter Valid Shopping Home Phone Number");
			document.getElementById("Shipping_Home_Phone").value = '';
			document.getElementById("Shipping_Home_Phone").focus();
			return false;
		}
	}

	if (document.getElementById("Shipping_Work_Code").value != "")
	{
		if (isNaN(document.getElementById("Shipping_Work_Code").value))
		{
			alert("Enter Valid Shopping Work Phone Code");
			document.getElementById("Shipping_Work_Code").value = '';
			document.getElementById("Shipping_Work_Code").focus();
			return false;
		}
	}

	if (document.getElementById("Shipping_Work_Phone").value != "")
	{
		if (isNaN(document.getElementById("Shipping_Work_Phone").value))
		{
			alert("Enter Valid Shopping Work Phone Number");
			document.getElementById("Shipping_Work_Phone").value = '';
			document.getElementById("Shipping_Work_Phone").focus();
			return false;
		}
	}

	if (document.getElementById("Shipping_Fax_Code").value != "")
	{
		if (isNaN(document.getElementById("Shipping_Fax_Code").value))
		{
			alert("Enter Valid Shopping Fax Code");
			document.getElementById("Shipping_Fax_Code").value = '';
			document.getElementById("Shipping_Fax_Code").focus();
			return false;
		}
	}

	if (document.getElementById("Shipping_Fax_Phone").value != "")
	{
		if (isNaN(document.getElementById("Shipping_Fax_Phone").value))
		{
			alert("Enter Valid Shopping Fax Number");
			document.getElementById("Shipping_Fax_Phone").value = '';
			document.getElementById("Shipping_Fax_Phone").focus();
			return false;
		}
	}

	return true;	
}

function addtracking_validate(){
	var orderno;
	var salesno;
	var billinglast;
	var billingzip;
	var phone;
	var trackingno;
	var email;
	var orderdate;

	orderdate = CheckingNull("frmtracking","orderdate","Enter Valid Order Date");
	if(orderdate == false)
	{
		return false;
	}

	if(document.frmtracking.iOrderMasterId.value ==''){
		if(document.frmtracking.Sales_Receipt_No.value == ''){
			orderno=CheckingNull("frmtracking","iOrderMasterId","Enter Valid Order Number / Sales Receipt Number");
			if(orderno == false){
				return false;	
			}
		}
	}	
//	if(document.frmtracking.Sales_Receipt_No.value ==''){
//		if(document.frmtracking.iOrderMasterId.value == ''){
//			salesno=CheckingNull("frmtracking","Sales_Receipt_No","Enter Valid Order Number / Sales Receipt Number");
//			if(salesno == false){
//				return false;	
//			}
//		}
//	}	
	billinglast = CheckingNull("frmtracking","Billing_Last_Name","Enter Valid BillingLastName");
			if(billinglast == false)
			{
				return false;
			}
	billingzip = CheckingNull("frmtracking","Billing_Zip_Code","Enter Valid BillingZipCode");
			if(billingzip == false)
			{
				return false;
			}
			/*if(isNaN(document.frmtracking.Billing_Zip_Code.value))
			{
				alert("Enter Valid BillingZipCode");
				document.frmtracking.Billing_Zip_Code.value = '';
				document.frmtracking.Billing_Zip_Code.focus();
				return false;
			}*/
/*
	phone = CheckingNull("frmtracking","Phone_No","Enter Valid Phone No");
			if(phone == false)
			{
				return false;
			}
			if (isNaN(document.frmtracking.Phone_No.value))
			{
				alert("Enter Valid PhoneNo");
				document.frmtracking.Phone_No.value = '';
				document.frmtracking.Phone_No.focus();
				return false;
			}
*/
	trackingno = CheckingNull("frmtracking","tracking_no","Enter Valid tracking no");
			if(trackingno == false)
			{
				return false;
			}
//			if (isNaN(document.frmtracking.tracking_no.value))
//			{
//				alert("Enter Valid tracking no");
//				document.frmtracking.tracking_no.value = '';
//				document.frmtracking.tracking_no.focus();
//				return false;
//			}
	
	email=CheckingNull("frmtracking","Email","Enter Valid Email Address");
	if(email == false){
		return false;
	}
	email = checkvalidemail("frmtracking","Email","Enter Valid Email Address");
	if(email == false)
	{
		return false;
	}
}


// This Function is used for the change password
function Check_ChgPasswd() 
{
	var old_passwd;
	var new_passwd;
	var conf_passwd;

	old_passwd = CheckingNull("frmchgpass","old_passwd","Enter Valid Old Password");
	if(old_passwd == false)
	{
		return false;
	}

	new_passwd = CheckingNull("frmchgpass","new_passwd","Enter Valid New Password");
	if(new_passwd == false)
	{
		return false;
	}

	conf_passwd = CheckingNull("frmchgpass","conf_passwd","Enter Valid Confirm Password");
	if(conf_passwd == false)
	{
		return false;
	}
	else
	{
		if (document.frmchgpass.new_passwd.value != document.frmchgpass.conf_passwd.value)	
		{
			alert("New Password & Confirm Password should be same.");
			document.frmchgpass.conf_passwd.value = '';
			document.frmchgpass.conf_passwd.focus();
			return false;
		}
	}
}
// This is for the click on the same for billing and shipping
function filldata()
{
	/*document.frmshopcart.shippingfirstname.value=document.frmshopcart.billingfirstname.value;
	document.frmshopcart.ShippingMiddleInitial.value=document.frmshopcart.BillingMiddleInitial.value;
	document.frmshopcart.shippinglastname.value=document.frmshopcart.billinglastname.value;
	document.frmshopcart.shippingcompany.value=document.frmshopcart.billingcompany.value;
	document.frmshopcart.shippingaddress1.value=document.frmshopcart.billingaddress1.value;
	document.frmshopcart.shippingaddress2.value=document.frmshopcart.billingaddress2.value;
	document.frmshopcart.shippingcity.value=document.frmshopcart.billingcity.value;
	document.frmshopcart.shippingstate.value=document.frmshopcart.billingstate.value;
	document.frmshopcart.shippingzip.value=document.frmshopcart.billingzip.value;
	document.frmshopcart.Shipping_Home_Code.value=document.frmshopcart.Billing_Home_Code.value;
	document.frmshopcart.Shipping_Home_Phone.value=document.frmshopcart.Billing_Home_Phone.value;
	document.frmshopcart.Shipping_Work_Code.value=document.frmshopcart.Billing_Work_Code.value;
	document.frmshopcart.Shipping_Work_Phone.value=document.frmshopcart.Billing_Work_Phone.value;
	document.frmshopcart.Shipping_Fax_Code.value=document.frmshopcart.Billing_Fax_Code.value;
	document.frmshopcart.Shipping_Fax_Phone.value=document.frmshopcart.Billing_Fax_Phone.value;*/
	
	if(document.getElementById("checkbox").checked==true){
	   document.getElementById('shippingfirstname').value=document.getElementById('billingfirstname').value;
	   document.getElementById('ShippingMiddleInitial').value =	document.getElementById('BillingMiddleInitial').value;
	   document.getElementById('shippinglastname').value = document.getElementById('billinglastname').value;
	   document.getElementById('shippingcompany').value=document.getElementById('billingcompany').value;
	   document.getElementById('shippingaddress1').value = document.getElementById('billingaddress1').value;
	   document.getElementById('shippingaddress2').value = document.getElementById('billingaddress2').value;
	   document.getElementById('shippingcity').value = document.getElementById('billingcity').value;
	   document.getElementById('shippingstate').value = document.getElementById('billingstate').value;
	   document.getElementById('shippingzip').value=document.getElementById('billingzip').value;
	   document.getElementById('Shipping_Home_Code').value=document.getElementById('Billing_Home_Code').value; 	   	
	   document.getElementById('Shipping_Work_Code').value=document.getElementById('Billing_Work_Code').value;
	   document.getElementById('Shipping_Fax_Code').value= document.getElementById('Billing_Fax_Code').value;
	   document.getElementById('Shipping_Home_Phone').value=document.getElementById('Billing_Home_Phone').value;
	   document.getElementById('Shipping_Work_Phone').value=document.getElementById('Billing_Work_Phone').value;
	   document.getElementById('Shipping_Fax_Phone').value= document.getElementById('Billing_Fax_Phone').value;
	}else{
	   document.getElementById('shippingfirstname').value='';
	   document.getElementById('ShippingMiddleInitial').value =	'';
	   document.getElementById('shippinglastname').value = '';
	   document.getElementById('shippingcompany').value='';
	   document.getElementById('shippingaddress1').value = '';
	   document.getElementById('shippingaddress2').value = '';
	   document.getElementById('shippingcity').value = '';
	   document.getElementById('shippingstate').value = '';
	   document.getElementById('shippingzip').value='';
	   document.getElementById('Shipping_Home_Code').value=''; 	   	
	   document.getElementById('Shipping_Work_Code').value='';
	   document.getElementById('Shipping_Fax_Code').value= '';
	   document.getElementById('Shipping_Home_Phone').value='';
	   document.getElementById('Shipping_Work_Phone').value='';
	   document.getElementById('Shipping_Fax_Phone').value= '';
	}
	
}
// End Added By Yogesh


function Check_User_Login() 
{
	var ueresult;
	var ueresultnull;
	
	ueresultnull = MyCheckingNull("txt_log_email","Enter Valid Email Address");
	
	if(ueresultnull == false)
	{
		return false;
	}
	else
	{
		ueresult = Mycheckvalidemail("txt_log_email","Enter Valid Email Address");
		if(ueresult == false)
		{
			return false;
		}	
	}
	
	var chkpasswordnull;
	chkpasswordnull = MyCheckingNull("txt_log_password","Enter Password");
	
	if(chkpasswordnull == false)
	{
		return false;
	}
	return true;	
}


function Check_Account_Create() 
{
	var ueresult;
	var ueresultnull;
	
	ueresultnull = CheckingNull("frm_login","txt_email","Enter Valid Email Address");
	
	if(ueresultnull == false)
	{
		return false;
	}
	else
	{
		ueresult = checkvalidemail("frm_login","txt_email","Enter Valid Email Address");
		if(ueresult == false)
		{
			return false;
		}	
	}
	
	var chkfname;
	chkfname = CheckingNull("frm_login","txt_fname","Enter First Name");
	
	if(chkfname == false)
	{
		return false;
	}
	
	var chklname;
	chklname = CheckingNull("frm_login","txt_lname","Enter Last Name");
	
	if(chklname == false)
	{
		return false;
	}
	
	var chkpasswordnull;
	chkpasswordnull = CheckingNull("frm_login","txt_password","Enter Password");
	
	if(chkpasswordnull == false)
	{
		return false;
	}
	
	var chkcpasswordnull;
	chkcpasswordnull = CheckingNull("frm_login","txt_cpassword","Enter Confirm Password");
	
	if(chkcpasswordnull == false)
	{
		return false;
	}
	
	/*var chkreminder;
	chkreminder = CheckingNull("frm_login","txt_reminder","Enter Password Reminder");
	
	if(chkreminder == false)
	{
		return false;
	}*/
	
	if(document.frm_login.txt_password.value != document.frm_login.txt_cpassword.value)
	{
		alert("Password & Confirm Password should be same.");
		return false;
	}	
}

function MyCheck_Account_Create() 
{
	var ueresult;
	var ueresultnull;
	
	ueresultnull = MyCheckingNull("txt_email","Enter Valid Email Address");
	
	if(ueresultnull == false)
	{
		return false;
	}
	else
	{
		ueresult = Mycheckvalidemail("txt_email","Enter Valid Email Address");
		if(ueresult == false)
		{
			return false;
		}	
	}
	
	var chkfname;
	chkfname = MyCheckingNull("txt_fname","Enter First Name");
	
	if(chkfname == false)
	{
		return false;
	}
	
	var chklname;
	chklname = MyCheckingNull("txt_lname","Enter Last Name");
	
	if(chklname == false)
	{
		return false;
	}
	
	var chkpasswordnull;
	chkpasswordnull = MyCheckingNull("txt_password","Enter Password");
	
	if(chkpasswordnull == false)
	{
		return false;
	}
	
	var chkcpasswordnull;
	chkcpasswordnull = MyCheckingNull("txt_cpassword","Enter Confirm Password");
	
	if(chkcpasswordnull == false)
	{
		return false;
	}
	
	/*var chkreminder;
	chkreminder = CheckingNull("frm_login","txt_reminder","Enter Password Reminder");
	
	if(chkreminder == false)
	{
		return false;
	}*/
	
	if(document.getElementById("txt_password").value != document.getElementById("txt_cpassword").value)
	{
		alert("Password & Confirm Password should be same.");
		return false;
	}
	return true;	
}


function Check_Service() 
{
	var chkreceiptno;
	chkreceiptno = CheckingNull("frm_service","txt_receipt_no","Enter Valid Sales Receipt NO.");
	
	if(chkreceiptno == false)
	{
		return false;
	}
	
	var chkcustname;
	chkcustname = CheckingNull("frm_service","txt_cust_name","Enter Customer Name");
	
	if(chkcustname == false)
	{
		return false;
	}	
	
	var chkpurdate;
	chkpurdate = CheckingNull("frm_service","txt_pur_date","Enter Date of Purchase");
	
	if(chkpurdate == false)
	{
		return false;
	}
	var chkbmodel;
	chkbmodel = CheckingNull("frm_service","txt_bmodel","Enter Brand and Model of Product");
	
	if(chkbmodel == false)
	{
		return false;
	}
	
	var ueresult;
	var ueresultnull;
	
	ueresultnull = CheckingNull("frm_service","txt_email","Enter Valid Email Address");
	
	if(ueresultnull == false)
	{
		return false;
	}
	else
	{
		ueresult = checkvalidemail("frm_service","txt_email","Enter Valid Email Address");
		if(ueresult == false)
		{
			return false;
		}	
	}
	
	
	
	
	
	var chkreason;
	chkreason = CheckingNull("frm_service","txt_reason","Enter Reason for service Request");
	
	if(chkreason == false)
	{
		return false;
	}

}

function Check_search_Service_center() 
{
	var chkreceiptno;
	chkreceiptno = CheckingNull("frm_search_service","txt_zipcode","Enter Zip Code Number.");
	
	if(chkreceiptno == false)
	{
		return false;
	}
}

function doSubmit() 
{
	var usermail;
	var useremail;

	usermail = CheckingNull("frm_login","txt_log_email","Enter Valid Email Address");
	
	if(usermail == false)
	{
		return false;
	}
	else
	{
		useremail = checkvalidemail("frm_login","txt_log_email","Enter Valid Email Address");
		if(useremail == false)
		{
			return false;
		}	
	}

	document.frm_login.submit();
}

function chkpaymentmethod() 
{
	
	var selected=false;
	for(i=0;i<3;i++) 
	{
			
		var val = eval("document.form3.Paymethods["+i+"].checked");		
		if(val== true) {
			var selected = true;
			break;
		}
	}
	if(selected) {
		return true;
	} 
	else {
		alert("Please select any one Payment Method.");
		return false;
	}
}


function uncheckedforAll(frm,index)
{
	with(frm)
	{
		var subchk = document.getElementById("subcount["+index+"]");
		
		if(subchk.value > 0)
		{
			
			var i;
			for(i= 1; i<= parseInt(subchk.value); i++)
			{
				var subcat = document.getElementById("Subcat["+index+"]["+i+"]");
				if(subcat.checked)
				{
					subcat.checked = false;
				}
			}
		}
		
	}
}
function uncheckedforOthers(frm,index)
{
	with(frm)
	{
		var allcat = document.getElementById("Cat["+index+"]");
		if(allcat.checked)
		{
			allcat.checked = false;
		}
 	}
}
function getCatsubCat(frm){
	
	with(frm)
	{
		var totalelements = frm.elements.length;
		//alert(totalelements);
		var i=0;
		for(i=1; i< totalelements; i++)
		{
			if(elements[i].type == "checkbox")
			{
				if(elements[i].checked)
				{
					if(elements[i].adjacentText == "All")
					{
						alert(elements[i].adjacentText);
					}
					else{alert(elements[i].AdjacentText);}
					
					
				}	//	End of if checked.
			}	//	End of checkbox.
			
		}	//	End of for.
		return false;
		var subchk = document.getElementById("count");
	}
}
function uncheckedAll(){
	
	//alert(document.frmscooterselect.allbrandname.checked);return false;
	if(document.frmscooterselect.allbrandname.checked==true)
		{
			
			document.frmscooterselect.allbrandname.checked = false;
			
		}
	
}
function uncheckedOthers(){
	//flag = 0;
	
	var comp="";
	// count the no of elements in a form
	var num_elements = document.frmscooterselect.elements.length;
	//
	if(document.frmscooterselect.allbrandname.checked == true) {
		
		for(i=0;i<num_elements;i++) {
			
			
		if (document.frmscooterselect.elements[i].type == 'checkbox' && document.frmscooterselect.elements[i].name != "allbrandname" )
		{	
			if(document.frmscooterselect.elements[i].checked==true)
			{
				document.frmscooterselect.elements[i].checked=false;
			}
		}
	}
	
	}
}
function selectcategory() {
	flag = 0;
	var comp="";
	// count the no of elements in a form
	var num_elements = document.frmscooterselect.elements.length;
	
	for(i=0;i<num_elements;i++) {

	if (document.frmscooterselect.elements[i].type == 'checkbox')
	{
		if(document.frmscooterselect.elements[i].checked==true)
		{
			if (comp != "")
				comp = comp+"_"+document.frmscooterselect.elements[i].value;
			else
				comp = document.frmscooterselect.elements[i].value;
		}
	}
		
		// check weather any formfield is selected
		if(document.frmscooterselect.elements[i].name == "brandname[]" || document.frmscooterselect.elements[i].name == "category" || document.frmscooterselect.elements[i].name == "pricerange" ||
	       document.frmscooterselect.elements[i].name == "maxweight" || document.frmscooterselect.elements[i].name == "topspeed" || document.frmscooterselect.elements[i].name == "heaviestscooter" || document.frmscooterselect.elements[i].name == "drivingrange" ) {
		
			if(document.frmscooterselect.elements[i].checked) {
				flag = 1;
			}
		}
	}
	document.frmscooterselect.companyid.value = comp;
	if(flag != 1) {
		alert("please select the any one item.");
		return false;
	}
}



function Conversion_Inches2Foot() {
	
	var inches = trimAll(document.frmrampcalculator.verticleriseininches.value);

	// check weather it is empty
	if((inches.length) <= 0) {
		alert("Please Enter the Inches");
		document.frmrampcalculator.verticleriseininches.value = '';
		document.frmrampcalculator.verticleriseininches.focus();
		return false;
	}
	else {
		// check weather it is not a number
		if(isNaN(inches)) { 
			alert("Inches must be a Number.");
			document.frmrampcalculator.verticleriseininches.value = '';
			document.frmrampcalculator.verticleriseininches.focus();
			return false;	
		} 
		else {
//			alert(inches);
			var foot = eval(inches/3);
			document.frmrampcalculator.verticleriseinfoot.value = foot;
			return false;
		}
	}
}

function ResetText() {
	document.frmrampcalculator.verticleriseininches.value = '';
	document.frmrampcalculator.verticleriseinfoot.value = '';
	document.frmrampcalculator.verticleriseininches.focus;
}

function trimAll(sString) 
{
	while (sString.substring(0,1) == ' ')
	{
	sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
	sString = sString.substring(0,sString.length-1);
	
	}
	return sString;
		
} //End Function

function EditForm(){
	
	if(!document.frm.Billing_vFirstName.value)
	{
		alert("Please Enter Customer First Name For Billing !");
		document.frm.Billing_vFirstName.focus();	
		return false;
 	}
 	if(!document.frm.Billing_vLastName.value)
	{
		alert("Please Enter Customer Last Name For Billing  !");
		document.frm.Billing_vLastName.focus();	
		return false;
 	}
 	if(!document.frm.Billing_vAddress1.value)
	{
		alert("Please Enter Address1 For Billing !");
		document.frm.Billing_vAddress1.focus();	
		return false;
 	}
 	if(!document.frm.Billing_vCity.value)
	{
		alert("Please Enter City For Billing  !");
		document.frm.Billing_vCity.focus();	
		return false;
 	}
 	if(!document.frm.Billing_vState.value)
	{
		alert("Please Enter State For Billing !");
		document.frm.Billing_vState.focus();	
		return false;
 	}
 	if(!document.frm.Billing_vZipCode.value)
	{
		alert("Please Enter Postal Code For Billing !");
		document.frm.Billing_vZipCode.focus();	
		return false;
 	}
 	
 	if(!document.frm.Billing_Home_Phone.value)
	{
		alert("Please Enter Phone No For Billing !");
		document.frm.Billing_Home_Phone.focus();	
		return false;
 	}
 	if(!document.frm.Billing_vEmail.value)
	{
		alert("Please Enter Email For Billing !");
		document.frm.Billing_vEmail.focus();	
		return false;
 	}
 	
 	
 	if(!document.frm.Shipping_vFirstName.value)
	{
		alert("Please Enter Customer First Name For Shipping !");
		document.frm.Shipping_vFirstName.focus();	
		return false;
 	}
 	if(!document.frm.Shipping_vLastName.value)
	{
		alert("Please Enter Customer Last Name For Shipping  !");
		document.frmr.Shipping_vLastName.focus();	
		return false;
 	}
 	if(!document.frm.Shipping_vAddress1.value)
	{
		alert("Please Enter Address1 For Shipping !");
		document.frm.Shipping_vAddress1.focus();	
		return false;
 	}
 	if(!document.frm.Shipping_vCity.value)
	{
		alert("Please Enter City For Shipping  !");
		document.frm.Shipping_vCity.focus();	
		return false;
 	}
 	if(!document.frm.Shipping_vState.value)
	{
		alert("Please Enter State For Shipping !");
		document.frm.Shipping_vState.focus();	
		return false;
 	}
 	if(!document.frm.Shipping_vZipCode.value)
	{
		alert("Please Enter Postal Code For Shipping !");
		document.frm.Shipping_vZipCode.focus();	
		return false;
 	}
 	if(!document.frm.Shipping_Home_Phone.value)
	{
		alert("Please Enter Phone No For Shipping !");
		document.frm.Shipping_Home_Phone.focus();	
		return false;
 	}
 	if(!document.frm.Shipping_vEmail.value)
	{
		alert("Please Enter Email For Shipping !");
		document.frm.Shipping_vEmail.focus();	
		return false;
 	}
 }
 
 function IsValidateServiceCenter(){
	
	/*var formName 
	formName = document.addservicecenter
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?_" ;
	Lenfirstname = formName.txt_first_name.value.length;
	if (!(validateString(formName.txt_first_name, "Please Enter Name")))
		return false
		
	if(Lenfirstname > 255)
	{
		alert("First Name should not be more then 255 characters");
		formName.txt_first_name.focus();
		return false;
	}	
	var iChars1 = "0123456789!@#$%^&*()+=-[]\\\';,./{}|\":<>?_" ;
	for (var i = 0; i < formName.txt_first_name.value.length; i++) {
		if (iChars1.indexOf(eval("formName.txt_first_name.value.charAt("+i+")")) != -1) {
			alert("First Name: Only a to z , A to Z and space is allowed.");
			formName.txt_first_name.focus();
		  	formName.txt_first_name.value = '';
		  	return false;
	  	}
	}*/
	/*Lenlastname = formName.txt_last_name.value.length;
	if (!(validateString(formName.txt_last_name, "Please Enter Last Name")))
		return false

	if(Lenlastname > 255)
	{
		alert("Last Name should not be more then 255 characters");
		formName.txt_last_name.focus();
		return false;
	}
	
	for (var i = 0; i < formName.txt_last_name.value.length; i++) {
		if (iChars1.indexOf(eval("formName.txt_last_name.value.charAt("+i+")")) != -1) {
			alert("Last Name : Only a to z , A to Z and space is allowed.");
			formName.txt_last_name.focus();
		  	formName.txt_last_name.value = '';
		  	return false;
	  	}
	}*/
	
	/*Lencompname = formName.txt_comp_name.value.length;
	if (!(validateString(formName.txt_comp_name, "Please Enter Company Name")))
		return false
		
	if(Lencompname > 255)
	{
		alert("Company Name should not be more then 255 characters");
		formName.txt_comp_name.focus();
		return false;
	}	
	
	if (!(validateString(formName.txt_phone, "Please Enter Phone")))
		return false
	
	var iChars = "";
	Lenphone = formName.txt_phone.value.length;
	
	if(Lenphone > 12)
	{
		alert("Phone number should not be more then 12 digits");
		formName.txt_phone.focus();
		return false;
	}
	result1 = formName.txt_phone.value.search(iChars);
	if (result1 == -1) 
	   	{
			alert("Please enter valid phone number(###-###-####).");
			formName.txt_phone.focus();
	   		return false;
		}
	
	if (!(validateString(formName.txt_phone, "Please Enter Phone")))
		return false
	
	var iChars = "";
	Lenphone = formName.txt_phone.value.length;
	
	if(Lenphone > 12)
	{
		alert("Phone number should not be more then 12 digits");
		formName.txt_phone.focus();
		return false;
	}
	result1 = formName.txt_phone.value.search(iChars);
	if (result1 == -1) 
	   	{
			alert("Please enter valid phone number(###-###-####).");
			formName.txt_phone.focus();
	   		return false;
		}	*/
	/*----------------------------------------------------------------------------*/
	/*if (!(validateString(formName.txt_toll_free, "Please Enter Toll Free Number")))
		return false
	
	var iChars = "";
	Lenphone = formName.txt_toll_free.value.length;
	
	if(Lenphone > 12)
	{
		alert("Phone number should not be more then 12 digits");
		formName.txt_toll_free.focus();
		return false;
	}
	result1 = formName.txt_toll_free.value.search(iChars);
	if (result1 == -1) 
	   	{
			alert("Please enter valid toll freephone number(###-###-####).");
			formName.txt_toll_free.focus();
	   		return false;
		}
		
	if (!(validateString(formName.txt_add1, "Please Enter Address1")))
		return false	
	if (!(validateString(formName.txt_city, "Please Enter City")))
		return false
	if (!(validateString(formName.txt_state, "Please Select State")))
		return false	
	if (!(validateString(formName.txt_zipcode, "Please Enter ZipCode")))
		return false
		
	Lenzipcode = formName.txt_zipcode.value.length;
	
	if(Lenzipcode < 5)
	{
		alert("Zipcode should not be less then 5 digits");
		formName.txt_zipcode.focus();
		return false;
	}
	if(Lenzipcode > 10)
	{
		alert("Zipcode should not be more then 10 digits");
		formName.txt_zipcode.focus();
		return false;
	}
	
	if (isNaN(formName.txt_zipcode.value))
	{
		alert("Enter Valid ZipCode");
		formName.txt_zipcode.value = '';
		formName.txt_zipcode.focus();
		return false;
	}*/
	if(document.addservicecenter.txt_email.value != '')
	{
		res = checkvalidemail("addservicecenter","txt_email","Please Enter Valid Email Address")
		if(res==false)
		{
			return false;
		}
	}
	
	/*if(document.addservicecenter.txt_url.value != '')
	{	
		var urlregex = new RegExp("^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([0-9A-Za-z]+\.)");
		if(!(urlregex.test(formName.txt_url.value)))
		{
			alert("Please Enter valid URL");
			formName.txt_url.value = '';
			formName.txt_url.focus();
			return false;
		}
	}*/

	/*if (!(validateString(formName.txt_service, "Please Enter Service")))
		return false*/
/*
	if (!(validateString(formName.txt_paymentoption, "Please Enter Payment Option")))
		return false
	if (!(validateString(formName.txt_brand, "Please Enter Brand")))
		return false
	if (!(validateString(formName.txt_comment, "Please Enter Comment")))
		return false*/
}

function largeImage(image_name)
 {  
  	 var html=" <img class='4' src='../images/products/ImageMore/"+image_name+"'  name='"+image_name+"' id='"+image_name+"'  />";
 	document.getElementById('show_large_image').innerHTML = html;		
 }

function showProducts(tr_num) {	
	var str = tr_num;
	var str2 = document.getElementById('current_id').value;	
	var temp = 'Pre_'+str
	var temp2 = 'Pre_'+str2;
	document.getElementById(temp2).style.display = 'none';
	document.getElementById(temp).style.display = 'block';
	document.getElementById('current_id').value = str;
	showProductsDeliveryPickup(str,str2);	
}

function showProductsDeliveryPickup(tr_num,str2) {	
	var str = tr_num;
	var temp = 'DelPickup_'+str
	var temp2 = 'DelPickup_'+str2;
	document.getElementById(temp2).style.display = 'none';
	document.getElementById(temp).style.display = 'block';	
}

function selectProducts(pro_val) {		
	document.getElementById('iProductId').value = pro_val;	
	showProducts(pro_val);
}
