// JavaScript Document
//common  function
function checknum(val)
{
	var flag=0;
	var str ;
	
	str = val;
	var Chars = "0123456789";
	for (var i = 0; i < str.length; i++)
	{
		if (Chars.indexOf(str.charAt(i)) == -1)
		{
			flag=1;	          
		}
	}
	
	if(flag==1)
	{
		return false;
	}
	else
	{
		return true;
	}
}

function checkprice(val)
{
//alert(val);
	var flag=0;
	var str ;
	var k=0;
	str = val;
	var Chars = "0123456789.";
	for (var i = 0; i < str.length; i++)
	{
		if (Chars.indexOf(str.charAt(i)) == -1)
		{
			flag=1;	          
		}
		if (str.charAt(i)==".")
		{
		
			k++;	
			      
		}
	}
	if(k>1)
	{
	    flag=1;
	}
	return flag;
}


function validatephone(phoneVal)
{
if (checkInternationalPhone(trim(phoneVal))==false)
	{
		//alert("Please Enter a Valid Phone Number");
		//document.frmupdatefacilityb.mktphone.focus();
		return false;
	}


}


function checkInternationalPhone(strPhone)
{
var digits = "0123456789";
var phoneNumberDelimiters = "()- ";
var validWorldPhoneChars = phoneNumberDelimiters + "+";
var minDigitsInIPhoneNumber = 10;
  s=stripCharsInBag(strPhone,validWorldPhoneChars);
  return (checknum(s) && s.length >= minDigitsInIPhoneNumber);
}


function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    for (i = 0; i < s.length; i++)
    {
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}


//Ajax code 
var xhttp=createObj();

function createObj()
{
	var request = false;
   try 
   {
     request = new XMLHttpRequest();
   } 
   catch (trymicrosoft)
   {
     try
	 {
       request = new ActiveXObject("Msxml2.XMLHTTP");
     }
	 catch (othermicrosoft) 
	 {
       try 
	   {
         request = new ActiveXObject("Microsoft.XMLHTTP");
       } 
	   catch (failed) 
	   {
         request = false;
       }  
     }
   }
//alert(request);
	return request;
}


//-----------Dynamic paging, page moves ----------//

function pagemoves(formName,url)
{
  		str=url;
		frm1=eval("document."+formName);
		frm1.action=str;
		frm1.submit();
} 
//-------------------------------------//

//---------------------------------Left Menu -------------------------------//

function funListModel()
{
	mft=document.frmSearch.cmbManufacturer.value;
	tid=document.frmSearch.cmbType.value;
	if(mft!=0)
	{
		xhttp.open("GET","modelListing.php?mft_id="+mft+"&tid="+tid,true);
		xhttp.onreadystatechange=populateModel;
		xhttp.send(null);
	}
}
function populateModel()
{
	if(xhttp.readyState==4)
	{
		document.getElementById("spModel").innerHTML=xhttp.responseText;
	}
}


function funSearch()
{
	if(document.frmSearch.cmbType.value=="0" && document.frmSearch.cmbModel.value=="0")	
	{
		alert("Please select a type or model");
		document.frmSearch.cmbType.focus();
		return false;
	}
	
	// Added later, to remove the chacking
		document.frmSearch.action="models.php";
		document.frmSearch.submit();
	return true;
	if(document.frmSearch.cmbManufacturer.value=="0")	
	{
		alert("Please select a manufacturer.");
		document.frmSearch.cmbManufacturer.focus();
		return false;
	}
	if(document.frmSearch.cmbModel.value=="0" && document.frmSearch.cmb_Lprice.value=="0" && document.frmSearch.cmb_Hprice.value=="0")
	{
		document.frmSearch.action="models.php";
	}
	if(document.frmSearch.cmbModel.value!="0" && document.frmSearch.cmb_Lprice.value=="0" && document.frmSearch.cmb_Hprice.value=="0")
	{
		document.frmSearch.action="models.php";
	}
	if(document.frmSearch.cmb_Lprice.value!="0" )
	{
		if(document.frmSearch.cmbModel.value=="0")	
		{
			alert("Please select a model");
			document.frmSearch.cmbModel.focus();
			return false;
		}
		minPrice=parseInt(document.frmSearch.cmb_Lprice.value);
		maxPrice=parseInt(document.frmSearch.cmb_Hprice.value);
		if(maxPrice!="0")
		{
			if(minPrice >maxPrice )
			{
				alert("Please select a lower minimum price.");
				document.frmSearch.cmb_Lprice.focus();
				return false;
			}
		}
		document.frmSearch.action="productList.php?fr=2";	
	}
	document.frmSearch.submit();
}
//---------------------------------------------------------------------------//

function funModels(cNo)
{
	drp=eval("document.frmModels.cmbCategory"+cNo);
	catId=drp.value;
	//alert(catId);
	if(catId!=0)
	{
		document.frmModels.hidNo.value=cNo;
		xhttp.open("GET","subCatListing.php?cat_id="+catId+"&no="+cNo,true);
		xhttp.onreadystatechange=populateSubCat;
		xhttp.send(null);
	}
}
function populateSubCat()
{
	if(xhttp.readyState==4)
	{
		cNo=document.frmModels.hidNo.value;
		//alert(xhttp.responseText);
		//alert(document.getElementById("spSubCat"+cNo).innerHTML);
		document.getElementById("spSubCat"+cNo).innerHTML=xhttp.responseText;
		//alert(document.getElementById("spSubCat"+cNo).innerHTML);
	}
}

function funModelSubmit(no)
{
	cat=eval("document.frmModels.cmbCategory"+no);
	if(cat.value=="0")
	{
		alert("Please select a category for this model");	
		cat.focus();
		return false;
	}
	subCat=eval("document.frmModels.cmbSubCategory"+no);
	if(subCat.value=="0")
	{
		alert("Please select a sub category for this model");	
		subCat.focus();
		return false;
	}
	document.frmModels.action="model2.php?sid="+subCat.value;//alert(document.frmModels.action);
	document.frmModels.submit();
}

//------------------------------------modeltypes----//
function funModelTypes(cNo)
{
	drp=eval("document.frmModels.cmbCategory"+cNo);
	catId=drp.value;
	if(catId!=0)
	{
		document.frmModels.hidNo.value=cNo;
		xhttp.open("GET","subCatListingTypes.php?cat_id="+catId+"&no="+cNo,true);
		xhttp.onreadystatechange=populateSubCatType;
		xhttp.send(null);
	}
}
function populateSubCatType()
{
	if(xhttp.readyState==4)
	{
		cNo=document.frmModels.hidNo.value;
		document.getElementById("spSubCat"+cNo).innerHTML=xhttp.responseText;
	}
}

function funModelSubmitType(no)
{
	cat=eval("document.frmModels.cmbCategory"+no);
	if(cat.value=="0")
	{
		alert("Please select a category for this model");	
		cat.focus();
		return false;
	}
	subCat=eval("document.frmModels.cmbSubCategory"+no);
	if(subCat.value=="0")
	{
		alert("Please select a sub category for this model");	
		subCat.focus();
		return false;
	}
	document.frmModels.action="model2.php?sid="+subCat.value+"&tid="+document.frmModels.hidType.value+"&fr=mType";//alert(document.frmModels.action);
	document.frmModels.submit();
}
//---------------------------------Model2-----------------------//

function funModel2()
{
	/*for(k=1;k<7;k++)
	{
		combo=eval("document.frmModels.cmb_opt"+k);
		if(combo.value=="0")
		{
			alert("Please select option"+k);	
			combo.focus();
			return false;
		}
	}*/
	var selectedItem = "";
	var selectedtext = "";
	//var selectedValue = "";
	for(k=1;k<11;k++)
	{
		var cmb=document.getElementById("cmb_opt"+k);
		if(cmb!=null)
		{
			combo=eval("document.frmModels.cmb_opt"+k);
			hidOpt=eval("document.frmModels.hidOpt"+k);
			selectedItem = combo.selectedIndex;
			selectedtext = combo.options[selectedItem].text;
			//selectedValue = combo.options[selectedItem].value;
			hidOpt.value=selectedtext;
		}
	}
	
	if(document.frmModels.hidBread.value!="")
	{
		document.frmModels.action="productList.php?fr=1&br=1";	
	}
	else
	{
		document.frmModels.action="productList.php?fr=1";
	}
	document.frmModels.submit();
}

//--------------------------------Product List ------------------------//
function funProductList(pid)
{
	/*if(document.frmProducts.hidBread.value!="")
	{
		document.frmProducts.action="productDetails.php?no="+no+"&br=1";
	}
	else
	{*/
		document.frmProducts.action="productDetails.php?pid="+pid;
	//}
	document.frmProducts.submit();	
}

//--------------------------------Product Search ------------------------//
function funProductListSrch(no)
{
	document.frmProducts.action="productDetails.php?no="+no;
	document.frmProducts.submit();	
}
//--------------------------------accessories List ------------------------//
function funAccessoryList(no)
{
	document.frmAcc.action="accDetails.php?no="+no;
	document.frmAcc.submit();	
}
//--------------------------------Product Details -----------------------//
function funAcTotal(count)
{
	var total=0;
	for(i=0;i<count;i++)	
	{
		j=i+1;
		chk=eval("document.frmProduct.chk"+j);
		if(chk.checked)
		{
			hid=eval("document.frmProduct.hidAc"+j);
			total=parseFloat(total)+parseFloat(hid.value);
		}
	}
	xhttp.open("GET","accTotalPrice.php?tot="+total,true);
	xhttp.onreadystatechange=populateTotal;
	xhttp.send(null);
}
function populateTotal()
{
	if(xhttp.readyState==4)
	{
		document.getElementById("spTotal").innerHTML=xhttp.responseText;
	}
}

function funAssignImg(V,arrSize)
{
	if(V=='N')
	{
		hid=eval("document.frmProduct.hidImg"+document.frmProduct.hidImgN.value);
		if(hid.value!="")	
		{
			document.frmProduct.imgPr.src="products/"+hid.value;
			var next=parseInt(document.frmProduct.hidImgN.value)+parseInt(1);
			if(next >arrSize)
			{
				document.frmProduct.hidImgN.value=arrSize;
			}
			else
			{
				document.frmProduct.hidImgN.value=next;
			}
			
			document.frmProduct.hidImgP.value=next-2;
			document.frmProduct.imgNext.src="images/arrow2.gif";
		}
	}
	else
	{
		hid=eval("document.frmProduct.hidImg"+document.frmProduct.hidImgP.value);
		if(hid.value!="")	
		{
			document.frmProduct.imgPr.src="products/"+hid.value;
			var prev=parseInt(document.frmProduct.hidImgP.value)-parseInt(1);
			
			if(prev>0)
			{
				document.frmProduct.hidImgP.value=prev;
			}
			else
			{
				document.frmProduct.hidImgP.value=1;
			}
			
			document.frmProduct.hidImgN.value=prev+2;
			
		}
		if(document.frmProduct.hidImgP.value==1)
		{
			document.frmProduct.imgPrev.src="images/arrow3.gif";
		}
		else
		{
			document.frmProduct.imgPrev.src="images/arrow1.gif";	
		}
	}
}

function hidClear(src)
{
	if(src==1)
	{
		document.frmProduct.hidImgN.value="";
		document.frmProduct.hidImgP.value="";
	}
}

function funBuy(fr)
{
	document.frmProduct.action="cart1.php?fr="+fr;
	document.frmProduct.submit();
	
}

//-------------------------------member section---------------//
function validateMember(action)
{
	if(document.frmMember.txtFName.value=="")
	{
		alert("Please enter first name.");
		document.frmMember.txtFName.focus();
		return false;
	}
	if(document.frmMember.txtLName.value=="")
	{
		alert("Please enter last name.");
		document.frmMember.txtLName.focus();
		return false;
	}	
	if(document.frmMember.txtEmail.value=="")
	{
		alert("Please enter email address.");
		document.frmMember.txtEmail.focus();
		return false;
	}
	else
	{
	
		var email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;

		if(!email.test(document.frmMember.txtEmail.value))
			{
				alert("Enter valid E-mail ID");
				document.frmMember.txtEmail.value="";
				document.frmMember.txtEmail.focus();
				return false;
			}
	}
	
/*	if(document.frmMember.txtAdd1.value=="")
	{
		alert("Please enter address1.");
		document.frmMember.txtAdd1.focus();
		return false;
	}	
*/
	/*if(document.frmMember.txtAdd2.value=="")
	{
		alert("Please enter address2.");
		document.frmMember.txtAdd2.focus();
		return false;
	}*/	
/*	if(document.frmMember.txtCity.value=="")
	{
		alert("Please enter city.");
		document.frmMember.txtCity.focus();
		return false;
	}	
	if(document.frmMember.cmbState.value=="0")
	{
		alert("Please select a state.");
		document.frmMember.cmbState.focus();
		return false;
	}
	if(document.frmMember.txtZip.value=="")
	{
		alert("Please enter zip.");
		document.frmMember.txtZip.focus();
		return false;
	}
	if(checknum(document.frmMember.txtZip.value)==false)
	{
	alert("Please enter valid zip.");
	document.frmMember.txtZip.value="";
	document.frmMember.txtZip.focus();
	return false;
	}	
	else if(document.frmMember.txtZip.value.length!=5)
	{
		alert("Zip code must be of length 5.");
		document.frmMember.txtZip.value="";
		document.frmMember.txtZip.focus();
		return false;
	}	
*/	if(document.frmMember.txtPhone.value=="")
	{
		alert("Please enter phone number.");
		document.frmMember.txtPhone.focus();
		return false;
	}
	if (validatephone(document.frmMember.txtPhone.value)==false)
	{
		alert("Please enter phone number in correct format.");
		document.frmMember.txtPhone.focus();
		return false;
	}
	if(document.frmMember.txtPwd.value=="")
	{
		alert("Please enter password.");
		document.frmMember.txtPwd.focus();
		return false;
	}	
	if(document.frmMember.txtRpwd.value=="")
	{
		alert("Please retype password.");
		document.frmMember.txtRpwd.focus();
		return false;
	}
	if(document.frmMember.txtPwd.value!=document.frmMember.txtRpwd.value)
	{
		alert("Password Mismatch.");
		document.frmMember.txtRpwd.focus();
		return false;
	}
	if(action=='Add')
	{
		document.frmMember.action="register1.php";
	}
	else
	{
		document.frmMember.action="editProfile1.php";	
	}
	document.frmMember.submit();
}

//-----------------------------Login------------------------------------------//

function validateLogin(formName)
{
	
	frm1=eval("document."+formName);
	
	if(trim(frm1.txtUsername.value).length<1)
	{
		alert("Enter your email id.");
		frm1.txtUsername.value="";
		frm1.txtUsername.focus();
		return false;
	}
	else
	{
		var email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;
		if(!email.test(frm1.txtUsername.value))
		{
			alert("Enter valid E-mail ID");
			frm1.txtUsername.value="";
			frm1.txtUsername.focus();
			return false;
		}
	}
	if(trim(frm1.txtPwd.value).length<1)
	{
		alert("Enter Password.");	
		frm1.txtPwd.value="";
		frm1.txtPwd.focus();
		return false;
	}
	
		frm1.action="login1.php";
		frm1.submit();
	
}

function validateLoginKey(formName,e)
{
	if(e.keyCode==13)
	{
		frm1=eval("document."+formName);
		
		if(trim(frm1.txtUsername.value).length<1)
		{
			alert("Enter your email id.");
			frm1.txtUsername.value="";
			frm1.txtUsername.focus();
			return false;
		}
		else
		{
			var email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;
			if(!email.test(frm1.txtUsername.value))
			{
				alert("Enter valid E-mail ID");
				frm1.txtUsername.value="";
				frm1.txtUsername.focus();
				return false;
			}
		}
		if(trim(frm1.txtPwd.value).length<1)
		{
			alert("Enter Password.");	
			frm1.txtPwd.value="";
			frm1.txtPwd.focus();
			return false;
		}
		
			frm1.action="login1.php";
			frm1.submit();
	}
}

//-----------------------Forgot Password ----------------//

function funForgotPaswd()
{
	if(trim(document.frmForgot.txtEmail.value).length<1)
	{
		alert("Enter Email Address.");
		document.frmForgot.txtEmail.value="";
		document.frmForgot.txtEmail.focus();
		return false;
	}
	else
	{
		var email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;
		if(!email.test(document.frmForgot.txtEmail.value))
		{
			alert("Enter valid E-mail ID");
			document.frmForgot.txtEmail.value="";
			document.frmForgot.txtEmail.focus();
			return false;
		}
	}	
	document.frmForgot.action="forgotPassword1.php";
	document.frmForgot.submit();
}
//---------------------------------Order History ------------//

function funOrderHistory(oNo)
{
	document.frmOrder.action="orderDetails.php?oNo="+oNo;
	document.frmOrder.submit();
		
}

//---------------------------------Shoping Cart ---------------//

function funRemoveCart(id,from,tempId)
{
	document.frmShop.action="removeCart.php?id="+id+"&from="+from+"&tid="+tempId;
	document.frmShop.submit();
		
	/*xhttp.open("GET","removeCart.php?id="+id+"&from="+from+"&tid="+tempId,true);
	xhttp.onreadystatechange=populateShopCart;
	xhttp.send(null);*/
}
function populateShopCart()
{
	if(xhttp.readyState==4)
	{
		//alert(xhttp.responseText);
		document.getElementById("spShop").innerHTML="";
		document.getElementById("spShop").innerHTML=xhttp.responseText;
	}
}

function funUpdateCart(tempId,no)
{
	xhttp.open("GET","updateShopCart.php?tid="+tempId+"&no="+no,true);
	xhttp.onreadystatechange=populateUpdShopCart;
	xhttp.send(null);
}
function populateUpdShopCart()
{
	if(xhttp.readyState==4)
	{
		//alert(xhttp.responseText);
		document.getElementById("spShop").innerHTML="";
		document.getElementById("spShop").innerHTML=xhttp.responseText;
	}
}

function funShopCart(page)
{
	//alert(page);
	document.frmShop.action=page;
	document.frmShop.submit();
		
}

//--------------------------------------Memberdet.php---------//

function funCheckShip()
{
	if(document.frmAddress.chkSame.checked==true)	
	{
		funAssignShipToBill();	
	}
}

function funAssignShipToBill()
{
	document.frmAddress.txtBAdd1.value=document.frmAddress.txtSAdd1.value;
	document.frmAddress.txtBAdd2.value=document.frmAddress.txtSAdd2.value;
	document.frmAddress.txtBCity.value=document.frmAddress.txtSCity.value;
	document.frmAddress.cmbBState.value=document.frmAddress.cmbSState.value;
	document.frmAddress.txtBZip.value=document.frmAddress.txtSZip.value;
	document.frmAddress.txtBPhone.value=document.frmAddress.txtSPhone.value;
	document.frmAddress.txtBEmail.value=document.frmAddress.txtSEmail.value;
	
}

function funMemberDet()
{
	if(document.frmAddress.txtSAdd1.value=="")
	{
		alert("Please enter shipping address1.");
		document.frmAddress.txtSAdd1.focus();
		return false;
	}	
	/*if(document.frmAddress.txtSAdd2.value=="")
	{
		alert("Please enter shipping address2.");
		document.frmAddress.txtSAdd2.focus();
		return false;
	}	*/
	if(document.frmAddress.txtSCity.value=="")
	{
		alert("Please enter shipping city.");
		document.frmAddress.txtSCity.focus();
		return false;
	}	
	if(document.frmAddress.cmbSState.value=="0")
	{
		alert("Please select a shipping state.");
		document.frmAddress.cmbSState.focus();
		return false;
	}
	if(document.frmAddress.txtSZip.value=="")
	{
		alert("Please enter shipping zip.");
		document.frmAddress.txtSZip.focus();
		return false;
	}
	if(checknum(document.frmAddress.txtSZip.value)==false)
	{
	alert("Please enter valid shipping zip.");
	document.frmAddress.txtSZip.value="";
	document.frmAddress.txtSZip.focus();
	return false;
	}	
	else if(document.frmAddress.txtSZip.value.length!=5)
	{
		alert("Zip code must be of length 5.");
		document.frmAddress.txtSZip.value="";
		document.frmAddress.txtSZip.focus();
		return false;
	}	
	if(document.frmAddress.txtSPhone.value=="")
	{
		alert("Please enter shipping phone number.");
		document.frmAddress.txtSPhone.focus();
		return false;
	}
	if (validatephone(document.frmAddress.txtSPhone.value)==false)
	{
		alert("Please enter phone number in correct format.");
		document.frmAddress.txtSPhone.focus();
		return false;
	}
	if(document.frmAddress.txtSEmail.value=="")
	{
		alert("Please enter shipping email address.");
		document.frmAddress.txtSEmail.focus();
		return false;
	}
	else
	{
	
		var email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;

		if(!email.test(document.frmAddress.txtSEmail.value))
			{
				alert("Enter valid E-mail ID");
				document.frmAddress.txtSEmail.value="";
				document.frmAddress.txtSEmail.focus();
				return false;
			}
	}
	
	if(document.frmAddress.txtBAdd1.value=="")
	{
		alert("Please enter billing address1.");
		document.frmAddress.txtBAdd1.focus();
		return false;
	}	
	/*if(document.frmAddress.txtBAdd2.value=="")
	{
		alert("Please enter billing address2.");
		document.frmAddress.txtBAdd2.focus();
		return false;
	}	*/
	if(document.frmAddress.txtBCity.value=="")
	{
		alert("Please enter billing city.");
		document.frmAddress.txtBCity.focus();
		return false;
	}	
	if(document.frmAddress.cmbBState.value=="0")
	{
		alert("Please select a billing state.");
		document.frmAddress.cmbBState.focus();
		return false;
	}
	if(document.frmAddress.txtBZip.value=="")
	{
		alert("Please enter billing zip.");
		document.frmAddress.txtBZip.focus();
		return false;
	}
	if(checknum(document.frmAddress.txtBZip.value)==false)
	{
	alert("Please enter valid billing zip.");
	document.frmAddress.txtBZip.value="";
	document.frmAddress.txtBZip.focus();
	return false;
	}	
	else if(document.frmAddress.txtBZip.value.length!=5)
	{
		alert("Zip code must be of length 5.");
		document.frmAddress.txtBZip.value="";
		document.frmAddress.txtBZip.focus();
		return false;
	}	
	if(document.frmAddress.txtBPhone.value=="")
	{
		alert("Please enter billing phone number.");
		document.frmAddress.txtBPhone.focus();
		return false;
	}
	if (validatephone(document.frmAddress.txtBPhone.value)==false)
	{
		alert("Please enter phone number in correct format.");
		document.frmAddress.txtBPhone.focus();
		return false;
	}
	if(document.frmAddress.txtBEmail.value=="")
	{
		alert("Please enter billing email address.");
		document.frmAddress.txtBEmail.focus();
		return false;
	}
	else
	{
	
		var email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;

		if(!email.test(document.frmAddress.txtBEmail.value))
			{
				alert("Enter valid E-mail ID");
				document.frmAddress.txtBEmail.value="";
				document.frmAddress.txtBEmail.focus();
				return false;
			}
	}
	
	document.frmAddress.action="memberDet1.php";
	document.frmAddress.submit();
}

//----------------------------Order Summary ---------------------//

function funListShippingMode()
{
	if(document.frmOrderSummary.cmbProvider.value!="0")
	{
		xhttp.open("GET","listShippingMode.php?pid="+document.frmOrderSummary.cmbProvider.value,true);
		xhttp.onreadystatechange=populateListShipMode;
		xhttp.send(null);
	}
	funGetShipCharge();
}
function populateListShipMode()
{
	if(xhttp.readyState==4)
	{
		//alert(xhttp.responseText);
		document.getElementById("spShipMode").innerHTML="";
		document.getElementById("spShipMode").innerHTML=xhttp.responseText;
	}
}


function funGetShipCharge()
{
	if(document.frmOrderSummary.cmbProvider.value!="0")
	{
		//document.frmOrderSummary.actio="orderSummary.php";
		//document.frmOrderSummary.submit();
		//document.frmOrderSummary.hidBEmail.value=document.frmOrderSummary.hidBEmail.value+"</table>";
		//alert(document.frmOrderSummary.hidGT.value);
		xhttp.open("GET","listShippingRate.php?pid="+document.frmOrderSummary.cmbProvider.value+"&mid=1&state="+document.frmOrderSummary.hidState.value+"&noShip="+document.frmOrderSummary.hidNoShip.value+"&shipRate="+document.frmOrderSummary.hidShipRate.value+"&gt="+document.frmOrderSummary.hidGT.value+"&tax="+document.frmOrderSummary.hidTax.value+"&discount="+document.frmOrderSummary.hidDiscount.value,true);

		/*xhttp.open("GET","listShippingRate.php?pid="+document.frmOrderSummary.cmbProvider.value+"&mid="+document.frmOrderSummary.cmbMode.value+"&state="+document.frmOrderSummary.hidState.value+"&noShip="+document.frmOrderSummary.hidNoShip.value+"&shipRate="+document.frmOrderSummary.hidShipRate.value+"&gt="+document.frmOrderSummary.hidGT.value+"&tax="+document.frmOrderSummary.hidTax.value+"&discount="+document.frmOrderSummary.hidDiscount.value,true);//+"&body="+document.frmOrderSummary.hidBEmail.value*/
		xhttp.onreadystatechange=populateListShipRate;
		xhttp.send(null);
	}
}
function populateListShipRate()
{
	if(xhttp.readyState==4)
	{
		//alert(xhttp.responseText);
		document.getElementById("spShipRate").innerHTML="";
		document.getElementById("spShipRate").innerHTML=xhttp.responseText;
	}
}


function funOrderSummary()
{
	//alert("In progress");
	noShip=document.frmOrderSummary.hidNoShip.value;
	//alert(noShip);
	if(noShip>0)
	{
		if(document.frmOrderSummary.cmbProvider.value=="0")
		{
			alert("Please select a shipping provider");
			document.frmOrderSummary.cmbProvider.focus();
			return false;
		}
		/*
		if(document.frmOrderSummary.cmbMode.value=="0")
		{
			alert("Please select a shipping mode.");
			document.frmOrderSummary.cmbMode.focus();
			return false;
		}
		*/
	}
	
	if(document.frmOrderSummary.rdPay[0].checked==false && document.frmOrderSummary.rdPay[1].checked==false)
	{
		alert("Please select a payment mode.");	
		return false;
	}
	if(document.frmOrderSummary.rdPay[0].checked==true)
	{
		if(document.frmOrderSummary.txtCardNo.value=="")
		{
			alert("Please enter card number.");	
			document.frmOrderSummary.txtCardNo.focus();
			return false;
		}
		if(document.frmOrderSummary.txtCardVerNo.value=="")
		{
			alert("Please enter card verification number.");	
			document.frmOrderSummary.txtCardVerNo.focus();
			return false;
		}
	}
	
	document.frmOrderSummary.action="orderSummary1.php";	
	document.frmOrderSummary.submit();
}

//------------------------Header Search-------------------------------//

function funHeaderSrch()
{
	/*if(document.frmTypeSrch.txtSrch1.value=="")	
	{
		alert("Please enter a search criteria");	
		document.frmTypeSrch.txtSrch1.value
		return false;
	}*/
	//alert(document.frmTypeSrch.rdSrch.value)
	document.frmTypeSrch.action="headerSrch.php";
	document.frmTypeSrch.submit();
}
function funHeaderSrchKey(e)
{
	if(e.keyCode==13)
	{
		/*if(document.frmTypeSrch.txtSrch1.value=="")	
		{
			alert("Please enter a search criteria");	
			document.frmTypeSrch.txtSrch1.value
			return false;
		}*/
		//alert(document.frmTypeSrch.rdSrch.value)
		document.frmTypeSrch.action="headerSrch.php";
		document.frmTypeSrch.submit();
	}
}

//---------------------------------Contact Us---------------------------//

function funContactUs()
{
	if(document.frmContact.txtName.value=="")	
	{
		alert("Please enter your name.");	
		document.frmContact.txtName.focus();
		return false;
	}
	if(document.frmContact.txtEmail.value=="")	
	{
		alert("Please enter your email.");	
		document.frmContact.txtEmail.focus();
		return false;
	}
	else
	{
	
		var email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;

		if(!email.test(document.frmContact.txtEmail.value))
			{
				alert("Enter valid E-mail ID");
				document.frmContact.txtEmail.value="";
				document.frmContact.txtEmail.focus();
				return false;
			}
	}
	if(document.frmContact.txtComment.value=="")	
	{
		alert("Please enter your comments.");	
		document.frmContact.txtComment.value
		return false;
	}
	//alert(document.frmTypeSrch.rdSrch.value)
	document.frmContact.action="contactUs1.php";
	document.frmContact.submit();	
}

function paging(tmpurl)
{
    //window.location.replace(tmpurl);
    //window.location.href(tmpurl);
    //var bVer = integer(navigator.appVersion);  
    //if(navigator.appName == "Microsoft Internet Explorer")
    //{
    	document.frmProducts.action=tmpurl;
		document.frmProducts.submit();
		//window.location.href(tmpurl);
    //}
//    else if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion == 7)
//    {
//    	external.menuArguments.location.href=tmpurl;
//    }
//    else
    //if(navigator.appName !== "Microsoft Internet Explorer")
    //{
    //window.location.replace(tmpurl);
    //window.location=tmpurl;
    //}
}