
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: This function checks whether the entered qty is correct or not.
//  @   Pages Affected  : Index,Items, searchresult,Psearchresult
//  @		Function Name		: preproc(frm,index,code,type)									
//	@		Input Parameters: frm = Form Name, index = Index value, code = Item Code, type = Item Type
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function preproc(frm,index,code,type,eqCode,iWishList, iUnits)
{ var element, retval, qty, iItemqty, iTotalqty;

	element = "document." + frm + ".qty" + index + ".value";
	qty = eval(element);
	retval=IsNumeric(qty)
	
	if(retval == 1)
	{
		alert(getMessage("iValidQuantity"));
		eval("document." + frm + ".qty" + index + ".value=iUnits");
		eval("document." + frm + ".qty" + index + ".focus()");
		return;
	}
	
	
	if (iWishList == 0){
		iItemqty = qty*1
		if ((iMaxCount != "") && (bMaxItem.toLowerCase()=="true")){
			iTotalqty = parseInt(sCartItems)
			if((iItemqty + iTotalqty)>parseInt(iMaxCount)){
				alert(getMessage("iTotalQtyExceed") +" "+ iMaxCount);
				eval("document." + frm + ".qty" + index + ".value=iUnits");
				//eval("document." + frm + ".qty" + index + ".focus()");
				return;
			}
		}
	document.frmAdditem.qty.value = qty;
	document.frmAdditem.ic.value = code;
	document.frmAdditem.type.value=type;
	document.frmAdditem.EqCode.value=eqCode;
	document.frmAdditem.action = sNonSecurePath + "includes/add_item.asp?Tp=" + sTpCatalog
	document.frmAdditem.submit();
	}
	else{
	document.frmAdditem.qty.value = qty;
	document.frmAdditem.ic.value = code;
	document.frmAdditem.EqCode.value=eqCode;
	document.frmAdditem.action = sNonSecurePath + "includes/AddWishitem.asp?Tp=" + sTpCatalog
	document.frmAdditem.submit();
	}
}
// End of the function preproc(frm,index,code,type)


//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: Function IsNumeric checks whether the entered value is a 
//	@											numeric and greater than Zero
//  @		Function Name		: IsNumeric(value)									
//	@		Input Parameters: value to be tested
//	@		Return Value		: 0 - Success	  1 - Failure			
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function IsNumeric(value)
{
	var validate=/(^\d+$)/
	if ((validate.test(value)) && (value > 0))
		return 0; 
	else
		return 1; 
}
// End of the function IsNumeric(value)

//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: This function used to format the contents in the field.
//	@		                	If value is 100.0 , this funciton will change it to 100.00.
//	@		Pages Affected  : Shipcalculator.asp
//  @		Function Name		: setFormat(field)									
//	@		Input Parameters: field = name of the form and fieldto be formatted
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function setFormat(field){
		var i, idiff,strval;
		var m_Field = eval("document." + field);
  	if(m_Field.value.indexOf(".") < 0)
			m_Field.value = m_Field.value + ".00";
		if(m_Field.value.length-m_Field.value.indexOf(".") == 2)
			m_Field.value = m_Field.value + "0";
		else if(m_Field.value.length-m_Field.value.indexOf(".") > 3){
			m_Field.value=m_Field.value.substring(0,m_Field.value.indexOf(".") +3)		
		}
		
	  idiff=10-m_Field.value.length	
		strval=""
		for(i=0;i< 10;i++)	{
			strval=strval+ " "  
			if (i==idiff-1){
				strval=strval+m_Field.value;
				break;
			}
		}
		m_Field.value=strval;
}

// End of the function setFormat(field)

//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: This function used to format numbers.
//	@		                	If we pass 100 , this funciton will return 100.00.
//	@	  Pages Affected  : Shipcalculator.asp
//  @		Function Name		: formatValue(value)									
//	@		Input Parameters: value = then number to be formatted
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
function formatValue(value){
	return Math.round(value*100)/100;
}
// End of the function formatValue(value)

//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: This function is called to choose the Catalog from the list.
//  @   Pages Affected  : PowerSearch
//  @		Function Name		: ChangeCatalog()									
//	@		Input Parameters: null							
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function ChangeCatalog()
{
  strURL = sNonSecurePath + "powersearch.asp?Tp=" + document.frmPSearch.shop.options[document.frmPSearch.shop.selectedIndex].value;
  window.location.href = strURL;
}
// End of the function ChangeCatalog()
	
	
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: This function is used to delete a particular item from cart.
//  @   Pages Affected  : Viewcart
//  @		Function Name		: DeleteFromCart(itemcode, itemtype, tpcode)									
//	@		Input Parameters: itemcode = Item Code, itemtype = Item Type, tpcode = TpCode									
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function DeleteFromCart(itemcode, itemtype, tpcode, eqCode)
{
	if(confirm(getMessage("iRemoveItemFromCart")))
	{
	document.frmDelete.itemcode.value = itemcode;
	document.frmDelete.itemtype.value = itemtype;
	document.frmDelete.tpcode.value = tpcode;
	document.frmDelete.EqCode.value = eqCode;
	document.frmDelete.submit();
	}
}
// End of the function DeleteFromCart(itemcode, itemtype, tpcode)



//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: This function is used to empty the cart.
//  @   Pages Affected  : Viewcart
//  @		Function Name		: EmptyCart()									
//	@		Input Parameters: Null									
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function EmptyCart()
{
	if(confirm(getMessage("iEmptyCart")))
	{
	document.frmDelete.todo.value = "empty";
	document.frmDelete.submit();
	}
}
// End of the function EmptyCart()


//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: This function is used to update the cart contents, as changed 
//	@											by the user.
//  @   Pages Affected  : Viewcart
//  @		Function Name		: UpdateCart(Index)									
//	@		Input Parameters: Index = Total no. of items									
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


function UpdateCart(Index)
{
	var count,qty,retval,iItemqty;
	iItemqty=0
	
	for(count = 1;count<=Index;count++)
	{		
		qty = eval("document.frmCartContents.qty" + count + ".value")
		var validate=/(^\d+$)/
		if (validate.test(qty) == false)
		{
			alert(getMessage("iValidQuantity"));
			eval("document.frmCartContents.qty" + count + ".focus()");
			return;
		}
		qty=qty*1
		iItemqty=iItemqty+qty
	}
	if ((iMaxCount != "") && (bMaxItem.toLowerCase()=="true")){
		if(iItemqty > parseInt(iMaxCount)){
			alert(getMessage("iTotalQtyExceed") + " " + iMaxCount);
			return;
		}
	}
	document.frmCartContents.submit();
}
// End of the function UpdateCart(Index)



//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: This function is called before submiting page, to validate
//	@											the min & max price.
//  @   Pages Affected  : PowerSearch
//  @		Function Name		: PowerSearchVal()									
//	@		Input Parameters: null							
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function PowerSearchVal(sCustTypeInt, sCustTypeDate){
	var len,iIndex,bCriteria,fMinval,fMaxval,value ;
	
	var validate=/(^\d+$)/
	
	//The hidden variables are being reset to blank when user comes back to page using back button.
	document.frmPSearch.sManDesc.value  = "";
	document.frmPSearch.sBrandDesc.value = "";
	document.frmPSearch.sCatDesc.value  =  "";
	
	if(sCustTypeInt!=""){
		sCustTypeInt = sCustTypeInt.substring(0,sCustTypeInt.length-1) 
		arr = sCustTypeInt.split(",");
		for(iIndex=0;iIndex<=arr.length-1;iIndex++){
			objField=eval("document.frmPSearch." + arr[iIndex]) 
			if(objField.value!=""){
				if(!(validate.test(objField.value)))  {
						alert(getMessage("iValidInteger"));
						objField.focus();
						objField.select();
						return false;
				}
			}	
		}	
	}
	if(sCustTypeDate!=""){
		sCustTypeDate = sCustTypeDate.substring(0,sCustTypeDate.length-1) 
		arr = sCustTypeDate.split(",");
		for(iIndex=0;iIndex<=arr.length-1;iIndex++){
			smonth=eval("document.frmPSearch." + arr[iIndex]+ "month.options[document.frmPSearch." + arr[iIndex]+ "month.selectedIndex].value")
			sday=eval("document.frmPSearch." + arr[iIndex]+ "day.options[document.frmPSearch." + arr[iIndex]+ "day.selectedIndex].value")
			syear=eval("document.frmPSearch." + arr[iIndex]+ "year.options[document.frmPSearch." + arr[iIndex]+ "year.selectedIndex].value")
			var sdate=new Date(syear, smonth ,sday)
			var sDefaultDate=new Date(1995,1,1)
			if((sdate-sDefaultDate)!=0)
				eval("document.frmPSearch.Txt" + arr[iIndex] + ".value=smonth+'/'+sday+'/'+syear")
			else
				eval("document.frmPSearch.Txt" + arr[iIndex] + ".value=''")
		}
	}
	
	bCriteria=false;
	len = document.frmPSearch.elements.length;
	for(iIndex=0;iIndex<=parseInt(len)-1;iIndex++){	
		if(document.frmPSearch.elements[iIndex].type == "text"){
			if(document.frmPSearch.elements[iIndex].value != ""){
				if(document.frmPSearch.elements[iIndex].value.charAt(0)==" "){
					alert(getMessage("iSearchNoStartSpace"));
					document.frmPSearch.elements[iIndex].focus();
					return false;
				}
				bCriteria = true;
			}
		}
		
		if(document.frmPSearch.elements[iIndex].type == "hidden"){
			if(document.frmPSearch.elements[iIndex].value != "")
				bCriteria = true;
		}
		if(document.frmPSearch.elements[iIndex].type == "checkbox"){
			if(document.frmPSearch.elements[iIndex].checked)
				bCriteria = true;
		}
		sFldname=document.frmPSearch.elements[iIndex].name
		if((sFldname == "selCategory")||(sFldname == "selBrand")||(sFldname == "selManufacturer")){
			if(document.frmPSearch.elements[iIndex].options[document.frmPSearch.elements[iIndex].selectedIndex].value != "")
				bCriteria = true;
		}
		if(bCriteria) break;
	}
	
	if(! bCriteria)	{
		alert(getMessage("iEnterSearchText"));
		document.frmPSearch.txtKey.focus();
		return false;
	}
	
	fMinval=document.frmPSearch.txtMin.value
	fMaxval=document.frmPSearch.txtMax.value
	
	if(document.frmPSearch.txtMin.value.length > 0)
	{ 
		 retval=IsFloat(fMinval);
		
		if(! retval)
		{
				alert(getMessage("iValidPrice"));
				document.frmPSearch.txtMin.focus();
				document.frmPSearch.txtMin.select();
				return false;
		}
		
			fMinval=parseFloat(fMinval);
		
		
	}
	if(document.frmPSearch.txtMax.value.length > 0)
	{   
	  
		 retval=IsFloat(fMaxval);
		if(! retval)
		{
			alert(getMessage("iValidPrice"));
			document.frmPSearch.txtMax.focus();
			document.frmPSearch.txtMax.select();
			return false;
		}
		
			fMaxval=parseFloat(fMaxval);
	
		
	}
	if(fMaxval < fMinval)
	{
		alert(getMessage("iMaxPriceGTMinPrice"));
		document.frmPSearch.txtMax.focus();
		document.frmPSearch.txtMax.select();
		return false;
		
	}
	document.frmPSearch.sManDesc.value  = document.frmPSearch.selManufacturer.options[document.frmPSearch.selManufacturer.selectedIndex].text;
	document.frmPSearch.sBrandDesc.value = document.frmPSearch.selBrand.options[document.frmPSearch.selBrand.selectedIndex].text;
	document.frmPSearch.sCatDesc.value  =  document.frmPSearch.selCategory.options[document.frmPSearch.selCategory.selectedIndex].text;
	document.frmPSearch.submit();
	
}

// End of the function powersearchval()

//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: This function is called before submiting page, to validate
//	@											float value.
//  @   Pages Affected  : PowerSearch
//  @		Function Name		: IsFloat()									
//	@		Input Parameters: price value(Minimum or Maximum)							
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


function IsFloat(value)
{
	var pattern1 = /^(\d+)(\.){0,1}(\d*)$/
	var pattern2 = /^(\d*)(\.){0,1}(\d+)$/
	return pattern1.test(value) || pattern2.test(value);
}

// End of the function IsFloat()


//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: This function is called when Delete or Retrieve link is clicked.
//	@											It is used to change the action depending on the link clicked.
//  @   Pages Affected  : Retreivecart
//  @		Function Name		: RetrieveCart(getcart,todo)									
//	@		Input Parameters: getcart = cartid,todo = 1(Delete) or 0(Retrieve)							
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function RetrieveCart(getcart,todo)
{
	if(todo=="1")
		if(confirm(getMessage("iDelSavedCart")))
			document.frmRetrieveCart.action = sNonSecurePath + "retrievecart.asp?action=DEL";
		else
			return;
	else
		document.frmRetrieveCart.action = sNonSecurePath + "retrievecart.asp?action=RET";
	document.frmRetrieveCart.PrevCartID.value =  getcart;
	document.frmRetrieveCart.submit();
}
// End of the function RetrieveCart(getcart,todo)


//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: This function is called when New cart name and Email id is entered.
//	@											It validates the Name and the Email id.
//  @   Pages Affected  : SaveCart
//  @		Function Name		: SaveCart()									
//	@		Input Parameters: null							
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function SaveCart(){
	if (document.frmSaveCart.CARTNAME.value == ""){
    	alert(getMessage("iEnterCartName"));
		document.frmSaveCart.CARTNAME.focus();
		return;
	}
	if (document.frmSaveCart.CARTNAME.value.charAt(0)==" "){
		alert(getMessage("iCartSpaces"));
		document.frmSaveCart.CARTNAME.focus();
		return;
	}
	if(document.frmSaveCart.CARTNAME.value.indexOf('"')!=-1)
	 {
		alert(getMessage("iInvalidCartname"));
		document.frmSaveCart.CARTNAME.focus();
		return;
	 }
	document.frmSaveCart.action = sNonSecurePath + "savecart.asp?action=SN&saved=1"
	document.frmSaveCart.submit();
}
// End of the function SaveCart()


//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@	Description		:	This function is called when New cart name and Email id is entered.
//	@						It validates the Name and the Email id.
//  @   Pages Affected  :	SaveEmail()
//  @	Function Name	:	SaveEmail()									
//	@	Input Parameters:	null
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function SaveEmail(){
	
	// ### Validating email.
	ret_val = IsEmail(document.frmSaveEmail.EMAIL.value);
	if (ret_val == 1){
		document.frmSaveEmail.EMAIL.focus();
		document.frmSaveEmail.EMAIL.select();
		return;
	}
	
	document.frmSaveEmail.action = sNonSecurePath + "EmailidReq.asp"
	document.frmSaveEmail.submit();
}
// End of the function SaveEmail()





//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: This function is called when when existing cart name is selected.
//  @   Pages Affected  : SaveCart
//  @		Function Name		: RestoreCart()									
//	@		Input Parameters: null							
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function RestoreCart()
{
	if (document.frmSaveCart.CARTLIST.options[document.frmSaveCart.CARTLIST.selectedIndex].value == 0 )	{
		alert(getMessage("iChooseCartName"));
		document.frmSaveCart.CARTLIST.focus();
	}	
	else	{	
		document.frmSaveCart.action = sNonSecurePath + "savecart.asp?action=SE&saved=1"
		document.frmSaveCart.submit();
	}
}
// End of the function RestoreCart()


//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: This function is called to validate the zipcode.
//  @   Pages Affected  : ShipCalculator
//  @		Function Name		: ZipCode_validate()									
//	@		Input Parameters: null							
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function ZipCode_validate(bUseDestZone)
{	
	var retval;
	// ### Validating address type
	if (document.frmShip.RESI.options[document.frmShip.RESI.selectedIndex].value == 0)
	{
		alert(getMessage("iAddressType"));
		document.frmShip.RESI.focus();
		return false;
	}
	if(document.frmShip.zipcode.value != ""){	
		if(bUseDestZone.toUpperCase() !="TRUE") {
			retval=IsNumeric(document.frmShip.zipcode.value)
			if(retval == 1)	{
				alert(getMessage("iValidZipCode"));
				document.frmShip.zipcode.focus();
				document.frmShip.zipcode.select();
				return false;
			}
		}
	}
	if((bUseDestZone.toUpperCase()=="FALSE") && (document.frmShip.zipcode.value == ""))	
		alert(getMessage("iEnterZipCode"));
			
	if(bUseDestZone.toUpperCase()=="TRUE"){
		// ### Validating City
		if((document.frmShip.City.value != "") && (document.frmShip.City.value.charAt(0)==" ") ){
				alert(getMessage("iValidText"))
				document.frmShip.City.focus();
				document.frmShip.City.select();
				return false;
		}
		// ### Validating State/ Province
		if((document.frmShip.State.value != "") && (document.frmShip.State.value.charAt(0)==" " )){	
				alert(getMessage("iValidText"))
				document.frmShip.State.focus();
				document.frmShip.State.select();
				return false;
		}
	}	
	document.frmShip.submit();
}
// End of the function ZipCode_validate()


//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: This function is called when a shipping method is selected.
//  @		Pages Affected  : ShipCalculator
//  @		Function Name		: ShipCharge_Calculate()									
//	@		Input Parameters: null							
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function ShipCharge_Calculate(iLocale)
{	var iTotal, iCartTotal,i, iRadselValue
	if(iLocale==null)
		iLocale=iEnglishLocaleId;
	
	for(i=0;i<=document.frmCost.radsel.length-1;i++){
	
  	 if(document.frmCost.radsel[i].checked)
	  { 
	   iRadselValue=document.frmCost.radsel[i].value.split("*")
	   
	  
	   iRadselValue[0]=getEnglishLocale(iRadselValue[0],iLocale)

	        iRadselValue[0] = formatValue(parseFloat(iRadselValue[0]));
  			iCartTotal=sCartTotal;
  			
			iCartTotal=getEnglishLocale(iCartTotal,iLocale)
   			iTotal = parseFloat(iRadselValue[0]) + parseFloat(iCartTotal);
   			
			document.frmCost.total.value = formatValue(iTotal);
			setFormat("frmCost.total");
			document.frmCost.total.value = getCurrentLocale(document.frmCost.total.value,iLocale);
			document.frmCost.shipprice.value = iRadselValue[0] 
			setFormat("frmCost.shipprice");
			document.frmCost.shipprice.value = getCurrentLocale(document.frmCost.shipprice.value,iLocale);
			
		if (bAddCurrExists) {
			iRadselValue[1]=getEnglishLocale(iRadselValue[1],iLocale)
	        iRadselValue[1] = formatValue(parseFloat(iRadselValue[1]));	        
  			iCartTotal=sCartTotalInAddCurr;
			iCartTotal=getEnglishLocale(iCartTotal,iLocale)
   			iTotal = parseFloat(iRadselValue[1]) + parseFloat(iCartTotal);   		
			document.frmCost.total_add_curr.value = formatValue(iTotal);
			setFormat("frmCost.total_add_curr");
			document.frmCost.total_add_curr.value = getCurrentLocale(document.frmCost.total_add_curr.value,iLocale);
			document.frmCost.shipprice_add_curr.value = iRadselValue[1] 
			setFormat("frmCost.shipprice_add_curr");
			document.frmCost.shipprice_add_curr.value = getCurrentLocale(document.frmCost.shipprice_add_curr.value,iLocale);
		}
		break;
		
		}
	}
}
// End of the function ShipCharge_Calculate()

//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: Function is to validate the alphanumeric characters and  string.  
//  @  		Pages Affected 		: Shipcalculator
//  @		Function Name		: isAlphanumeric(str,cSpace)
//	@		Input Parameters	: formname = name of the form
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function isAlphanumeric(str,cSpace){
    var sSpacepat = /^(((\w+)[\s,\-*\.]*)+)$/
     var sPat = /^(((\w+)[*,\-\.]*)+)$/
     if (cSpace=="1"){
		if(!(sSpacepat.test(str)))
		   {
			 alert(getMessage("iValidText"));
			 return false;
	       }	
		}
	  else{
		
		if(!(sPat.test(str)))  
			{
				alert(getMessage("iValidText"));
				return false;
	        }
	        }
     return true;
}
// End of the function isAlphanumeric(str,cSpace)

//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: This function changes the no. of days dynamically according to  
//  @											the month and the year.
//	@	  Pages Affected  : powersearch.asp
//  @		Function Name		: DateValidate(which)									
//	@		Input Parameters: which = field
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function DateValidate(which)
{
	var sel = eval("document.frmPSearch." + which + "day.selectedIndex");
	var i=eval("document.frmPSearch." + which + "month.options[document.frmPSearch." + which + "month.selectedIndex].value");
	var j=eval("document.frmPSearch." + which + "year.options[document.frmPSearch." + which + "year.selectedIndex].value");
	var k;
	if(i=="1" || i=="3" || i=="5" || i=="7" || i=="8" || i=="10" || i=="12")
	{
		eval("document.frmPSearch." + which + "day.length=31");
		for(k=28;k<=30;k++)
		{
			eval("document.frmPSearch." + which + "day.options[" + k + "].value=" + parseInt(k+1));
			eval("document.frmPSearch." + which + "day.options[" + k + "].text=" + parseInt(k+1));
		}
	}
	if(i=="4" || i=="6" || i=="9" || i=="11")
	{
		eval("document.frmPSearch." + which + "day.length=30");
		for(k=28;k<=29;k++)
		{
			eval("document.frmPSearch." + which + "day.options[" + k + "].value=" + parseInt(k+1));
			eval("document.frmPSearch." + which + "day.options[" + k + "].text=" + parseInt(k+1));
		}
	}
	var mydate = new Date();
	if(i==2)
	{
		mydate.setDate(1);
		mydate.setYear(j);
		mydate.setMonth(1);
		mydate.setDate(31);
		var k=31-mydate.getDate();
		eval("document.frmPSearch." + which + "day.length=" + k);
		if((k==29) || (k==28))
		{
			eval("document.frmPSearch." + which + "day.options[" + (k-1) + "].value=" + k);
			eval("document.frmPSearch." + which + "day.options[" + (k-1) + "].text=" + k);
		}
	}
	
	if((sel+1) > eval("document.frmPSearch." + which + "day.length"))
	{
		eval("document.frmPSearch." + which + "day.selectedIndex=document.frmPSearch." + which + "day.length-1");
	}
}
// End of the function DateValidate(which)


//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: Validation for EMail									@
//  @		Function Name		: IsEmail()												@
//	@		Input Parameters	: Value to be tested									@
//	@		Return Value		: 0 - Success											@
//	@							  1 - Failure											@
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
function IsEmail(strEmail)
{
var intReturn =1;
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>'@,;:\\\\\\\"\\.\\[\\]'"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var matchArray=strEmail.match(emailPat)
	if (matchArray==null ) {
		alert(getMessage("iValidEmail"));
		return intReturn;
	}
var user=matchArray[1]
var domain=matchArray[2]
if (user.match(userPat)==null) {
    alert(getMessage("iValidEmail"));
    return intReturn;
}
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		// this is an IP address
		for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				alert(getMessage("iValidEmail"));
			return intReturn;
			}
		}
		intReturn=0;
		return intReturn;
	}
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert(getMessage("iValidEmail"));
    return intReturn;
}
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	if (domArr[domArr.length-1].length<2 || 
		domArr[domArr.length-1].length>4) {
	alert(getMessage("iValidEmail"));
	return intReturn;
	}
var len=domArr.length	
if (len<2) {
   var errStr = getMessage("iValidEmail");
   alert(errStr)
   return intReturn;
}
intReturn=0;
return intReturn;
}
//	End of the function IsEmail(strEmail)

