//  Removed CartId from Line No. 159 by Armour - 23/12/2004
var Total=0
var configArr,sCustomFields

//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: This function used to format numbers.
//	@		                	If we pass 100 , this funciton will return 100.00.
//	@	  Pages Affected  : CustomKitItems.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)


function goBack() {
	if (window.print) {
		window.print() ;
	}
	else {
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
		WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box
		WebBrowser1.outerHTML = "";
	}
}

//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: This printkit function is to show the printable version of the Kit. 
//	@		                	It opens Customprint.htm and shows the ItemImage, ItemName, Item desc 
//	@		                	and Price. These data's are taken from the hidden fields. It checks  
//	@		                	for callforprice also. Qty is taken as 1 by default. It checks for 
//	@		                	the selected item in the combo box and dispalays the category 
//	@		                	for selected item and the corresponding item. It checks for '[' in the 
//	@		                	item name and removes all character's after '['.
//	@	  Pages Affected  : CustomKitItems.asp
//  @		Function Name		: printkit()									
//	@		Input Parameters: null
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


function printkit()
{
	var iIndex,myWin,iCount,sString1,len,sString2,sImgLink;
	myWin = window.open('','_kit','width=500,height=500,scrollbars')
	iCount = 0;
	len = document.frmKitUpgrades.elements.length;
	myWin.document.write("<TITLE>"+getMessage("iPrintVerKit")+"</TITLE>");
	myWin.document.write("<table border=0><tr><td width=50% valign=top>");
	myWin.document.write("<img src='images/company_logo.gif' align=left>");
	myWin.document.write("</td>");
	myWin.document.write("<td width=50% valign=top><font face = 'verdana, arial' size = 1 valign=top><b>" + sContactInfo + "<br>");
	myWin.document.write("</b></font>");
	myWin.document.write("</td></tr></table>");
	myWin.document.write("<table cellspacing=0 cellpadding=0 border=0>");
	myWin.document.write("<tr>");
	myWin.document.write("<td rowspan=2 valign=top align=right><img src=images/left_curve.gif width=9 height=19 border=0></td>");
	myWin.document.write("<td rowspan=2 height=19 align=center width='35%' bgcolor=#760D0F valign=middle><img src=images/yellow_arrow.gif width=10 height=5 hspace=3 vspace=2 border=0 ><font style='FONT-WEIGHT: bold; FONT-SIZE: 8pt; COLOR: white; FONT-FAMILY: Verdana'>Product Profile</font></td>");
	myWin.document.write("<td rowspan=2 align=left valign=top><img src=images/right_curve.gif width=15 height=19 border=0 ></td>");
	myWin.document.write("<td height=1 width=480 bgcolor=#760D0F valign=top align=left><img src=images/dot_black.gif width=1 height=1 border=0 ></td>");
	myWin.document.write("</tr>");
	myWin.document.write("<tr>");
	myWin.document.write("<td height=17><img src=images/blank.gif width=1 height=1 border=0 ></td>");
	myWin.document.write("</tr>");
	myWin.document.write("</table>");
	myWin.document.write("<table border =0 cellspacing = '8'>");
	myWin.document.write("<tr><td width = 110 valign = top align=center><font face='verdana' style='font-size: 8pt'><b>" + document.frmKitAmt.itemcode.value + "</b></font></td>");
	myWin.document.write("<td valign = top><font face='verdana' style='font-size: 8pt'><b>" + document.frmKitAmt.itemname.value + "</b></font></td></tr>");
	myWin.document.write("<tr><td width = 110 valign = top>");
	sImgLink=document.frmKitAmt.imglink.value 
	if (sImgLink.substring(sImgLink.length - 1, sImgLink.length) != "/" )
	myWin.document.write("<img src='" + document.frmKitAmt.imglink.value + "' align=left>");
	myWin.document.write("</td><td valign=top><font face = 'verdana, arial' style='font-size: 8pt'>" + document.frmKitAmt.description.value+"</font><br><br>");
	if (sKitCall4Price == "T") {
		myWin.document.write("<font face = 'verdana, arial' style='font-size: 8pt' valign=top><b>Price :&nbsp;"+getMessage("iCallForPrice")+"</b><br>");
	}
	else {
		myWin.document.write("<font face = 'verdana, arial' style='font-size: 8pt'><b>Price :&nbsp;"+sCurrSymbol);
		myWin.document.write(document.frmKitAmt.txtTotalKitValue.value);
		
		if (sAdditionalCurrencySymbol != "") {
			myWin.document.write("&nbsp; ("+sAdditionalCurrencySymbol+ document.frmKitAmt.txtTotalKitValue_Add_Curr.value +")");
		}
		myWin.document.write("</b><br>");
	}
	myWin.document.write("<font face = 'verdana, arial' style='font-size: 8pt' valign=top>"+sWeight+sDimensions+sWarranty+"</font><br>");
	for(iIndex=0;iIndex<=parseInt(len)-1;iIndex++)
	{
		if((document.frmKitUpgrades.elements[iIndex].type.substring(0,3) == "sel") || (document.frmKitUpgrades.elements[iIndex].name.substring(0,8) == "upg_name"))
		{		
			myWin.document.write("<font face = 'verdana, arial' size = 1>");
			myWin.document.write("<font face = 'verdana, arial' style='font-size: 8pt'>");
			if(document.frmKitUpgrades.elements[iIndex].type.substring(0,3) == "sel"){
				for (i = 0; i < document.frmKitUpgrades.elements[iIndex].options.length; i++) {
					sColor = "";
					if (i == 0) {
						sString1 = document.frmKitUpgrades.elements[iIndex].options[i].text;
						sString1 = "<br><b>Following "+sString1.substring(6)+"s are available:</b><br>";
					}
					else {
						sColor = document.frmKitUpgrades.elements[iIndex].options[i].style.backgroundColor;
						sString1 = document.frmKitUpgrades.elements[iIndex].options[i].text;
						sString2 = sString1.indexOf("[");
						if(sString2 != -1)
							sString1 = sString1.substring(0,sString2-1);
					}
					myWin.document.write("<table width='100%' border=0>");
					myWin.document.write("<tr><td><font face = 'verdana, arial' style='font-size: 8pt'>"+sString1+"</td><td width=50 bgcolor="+sColor+"><font face = 'verdana, arial' style='font-size: 8pt'>&nbsp;</font></td>");
					myWin.document.write("</table>");
				}
			}	
		}
	}	
	myWin.document.write("</td></tr>");
	myWin.document.write("<tr><td colspan=2 align=right valign=top>"+sRecycled+sUSA+sAssembly+sQuick+sGSA+"</td></tr>");
	myWin.document.write('<tr><td colspan="2" height="30">&nbsp;</td></tr><tr><td colspan="2" align="center"><form name="frmPrint"><input type="button" name="bPrint" value="  Print  " onclick="window.opener.goBack();self.focus();"></from></td></tr>');
	myWin.document.write("</table>");
	myWin.document.close();
	myWin.focus();
}
// End of the function printkit()
// function to add inventory items
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;
	if (type == "3") {
		document.frmAdditem.action = sNonSecurePath+"customkititems.asp?kc="+code+"&iQty="+qty;
	}
	else {
		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			: This function is to popup the details of the item selected in the list box.
//	@	  Pages Affected  : CustomKitItems.asp
//  @		Function Name		: printitem(sel)									
//	@		Input Parameters: sel = To find the name of the list box
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function printitem(sel)
{
	var code,arr;
	code =eval("document.frmKitUpgrades.sel" + sel + ".options[document.frmKitUpgrades.sel" + sel + ".selectedIndex].value");
	arr = code.split("#");
	if(arr[3]=="T")
		window.open(sNonSecurePath+"printItem.asp?Source=CK&ic=" + arr[0],"winPrint","toolbar,height=400,width=550,scrollbars,resizable");
	else
		alert(getMessage("iMoreInfoNotAvail"));
}
// End of the function printitem(sel)


//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: This function is to recalculate the total whenever user changes 
//  @                     the configuration, and to change the price in the text box.
//	@	  Pages Affected  : CustomKitItems.asp
//  @		Function Name		: CalculateTotal()									
//	@		Input Parameters: null
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function retrive(selid,optid,kitprice1,sLocaleId1,addKitPrice1)
	{

		var chval;
		var selObj = document.getElementById('selids'+selid);
		selObj.selectedIndex = optid;

		//chval =document.test.radcol.value;
		chval=document.getElementById("rad"+optid).value;
			//chval=document.getElementsByName("radcol").value;
		//alert(chval);
		//var ss = code.split("#");
		var tempval="(chr(34)"+ chval+"chr(34))";
		//alert(tempval);
		//document.myform.opttwo.options[document.myform.opttwo.selectedIndex].value

		//document.frmKitUpgrades.sel2.value=tempval;

		//alert(document.frmKitUpgrades.sel2.value);
		//document.frmKitUpgrades.sel + selid + .value=tempval;
		//document.frmKitUpgrades.sel + selid + .options[document.frmKitUpgrades.sel + selid + .selectedIndex].value=tempval;
		//code1 =eval("document.frmKitUpgrades.sel" + sel + ".options[document.frmKitUpgrades.sel" + sel + ".selectedIndex].value");
		//code1 =eval("document.frmKitUpgrades.sel" + selid + ".options[document.frmKitUpgrades.sel" + selid + ".selectedIndex].value");
		//arr10 = code1.split("#");
		//alert(code1);

		//document.frmKitUpgrades.cmbLeaveName.value=id;
		var  clubtotal1=sKitClubTotal;
	

	CalculateTotal(kitprice1,clubtotal1,sLocaleId1,addKitPrice1)


}

function retrive1(selid,optid,kitprice1,sLocaleId1,addKitPrice1,selid)
	{

		var chval;
		var selObj = document.getElementById('selids'+selid);
		selObj.selectedIndex = optid;

		//chval =document.test.radcol.value;
		//chval=document.getElementById("rad"+optid).value;
			//chval=document.getElementsByName("radcol").value;
		//alert(chval);
		//var ss = code.split("#");
		//var tempval="(chr(34)"+ chval+"chr(34))";
		//alert(tempval);
		//document.myform.opttwo.options[document.myform.opttwo.selectedIndex].value

		//document.frmKitUpgrades.sel2.value=tempval;

		//alert(document.frmKitUpgrades.sel2.value);
		//document.frmKitUpgrades.sel + selid + .value=tempval;
		//document.frmKitUpgrades.sel + selid + .options[document.frmKitUpgrades.sel + selid + .selectedIndex].value=tempval;
		//code1 =eval("document.frmKitUpgrades.sel" + sel + ".options[document.frmKitUpgrades.sel" + sel + ".selectedIndex].value");
		//code1 =eval("document.frmKitUpgrades.sel" + selid + ".options[document.frmKitUpgrades.sel" + selid + ".selectedIndex].value");
		//arr10 = code1.split("#");
		//alert(code1);

		//document.frmKitUpgrades.cmbLeaveName.value=id;
		var  clubtotal1=sKitClubTotal;
	

	CalculateTotal(kitprice1,clubtotal1,sLocaleId1,addKitPrice1,selid)
	
	


}

function retrive2(selid,optid,kitprice1,sLocaleId1,addKitPrice1)
	{

		var chval,elem,p;
		//var selObj = document.getElementById('selids'+selid);
		//selObj.selectedIndex = optid;
		var selectatt=document.getElementById('attr'+optid+selid).value;
		var attval=document.getElementById('attrval'+optid+selid).value;
		//alert(attval);
		//document.getElementById("div1").innerHTML
		document.getElementById('selcolor'+selid).innerHTML="&nbsp;"+selectatt;
		p=document.getElementById('attrcolor'+optid+selid).value;
		elem = document.getElementById('selcolor'+selid).style;
		//elem.color = document.getElementById('attrcolor'+optid).value;
		//alert(p);
		elem.color ='black';
		//elem.background ='#'+p;
		if (isBlank(p) ==true)
		{
		document.getElementById('selcolblank'+selid).style.background='white';
		}
		else
		{
		document.getElementById('selcolblank'+selid).style.background='#'+p;
		}
		elem.background = "white";
		//elem.fontWeight = "bold";
		elem.fontFamily ="verdana";
		elem.fontSize = "8pt";
		//document.getElementById('selcolors'+selid).style.color='black';
		//font-weight:bold;
		//font-style:italic
		//this is for only index value
		//document.getElementById('selhide'+selid).value=optid;
		
		document.getElementById('selhide'+selid).value=attval;
		//document.getElementById('selhides'+selid).value=attval;
		//alert(document.getElementById('selhides'+selid).value);
		//alert(document.getElementById('selhide'+selid).value);
		
		
		var  clubtotal1=sKitClubTotal;
	

	CalculateTotal(kitprice1,clubtotal1,sLocaleId1,addKitPrice1,selid)
	
	


}

function retriveonpage(selid,optid,kitprice1,sLocaleId1,addKitPrice1,QtyDisc1,QtyDisc2,QtyDisc3,QtyDisc4,QtyDisc5,QtyLabelPric1,QtyLabelPric2,QtyLabelPric3,QtyLabelPric4,QtyLabelPric5)
	{

		var chval,elem,p;
		
		var attval=document.getElementById('attrval'+optid+selid).value;
				
		document.getElementById('selhide'+selid).value=attval;
		document.getElementById('selcolor'+selid).value=attval;
			
		
		var  clubtotal1=sKitClubTotal;
	

	CalculateTotal(kitprice1,clubtotal1,sLocaleId1,addKitPrice1,selid,QtyDisc1,QtyDisc2,QtyDisc3,QtyDisc4,QtyDisc5,QtyLabelPric1,QtyLabelPric2,QtyLabelPric3,QtyLabelPric4,QtyLabelPric5)
	
	


}

function retrive3(selid,optid,kitprice1,sLocaleId1,addKitPrice1)
	{

		var chval,elem;
		//var selObj = document.getElementById('selids'+selid);
		//selObj.selectedIndex = optid;
		var selectatt=document.getElementById('attrs'+optid+selid).value;
		//var selectatt=document.getElementById('attr'+optid+selid).value;
		//var attval=document.getElementById('attrvals'+optid).value;
		var attval=document.getElementById('attrvals'+optid+selid).value;
		//alert(attval);
		//document.getElementById("div1").innerHTML
		document.getElementById('selcolor'+selid).innerHTML=selectatt;
		//this is for only index value
		//document.getElementById('selhide'+selid).value=optid;
		
		document.getElementById('selhide'+selid).value=attval;
		//document.getElementById('selhides'+selid).value=attval;
		//alert(document.getElementById('selhides'+selid).value);
		//alert(document.getElementById('selhide'+selid).value);
		elem = document.getElementById('selcolor'+selid).style;
		elem.fontWeight = "bold";
		elem.color ='black';
		document.getElementById('selcolors'+selid).style.color='black';
		var  clubtotal1=sKitClubTotal;
		var p=selid

	CalculateTotal(kitprice1,clubtotal1,sLocaleId1,addKitPrice1,p)
	
	


}
function CalculateTotal(kitprice,clubtotal,sLocaleId,addKitPrice,count,QtyDis1,QtyDis2,QtyDis3,QtyDis4,QtyDis5,QtyLabelPric1,QtyLabelPric2,QtyLabelPric3,QtyLabelPric4,QtyLabelPric5){
	
	
	
	if(typeof(count) == "undefined")
	{
	count=0
	}
		
		
	if(sLocaleId == "")
		sLocaleId = iEnglishLocaleId;
	var i,sel_Count;
	var Sum,addSum,temp,addtemp,arr,arr2,arr3,totalvalue,addTotalvalue,sKitValue,sAddKitValue,objKitFld,objAddKitFld,RegSum,RegAddSum,sRegKitValue;
	totalvalue=0;
	addTotalvalue=0;
	configArr=""
	arrWeight="";
	iWeight=0;
	iTotweight="";
	
	
	
	len = document.frmKitUpgrades.elements.length;
	
  if (sKitCall4Price != "T") {
		if(clubtotal=='T'){
			Sum=getEnglishLocale(kitprice,sLocaleId);
			addSum = getEnglishLocale(addKitPrice,sLocaleId);
			
		}
		else{
			Sum = 0.0;
			addSum = 0.0;
			RegSum=0.0;
			RegAddSum=0.0;
			
			
		}
			
		sel_Count = 0;
		
		for(i=0;i<=parseInt(len)-1;i++)	{
			if(document.frmKitUpgrades.elements[i].type.substring(0,3) == "sel") {				
				arr =  document.frmKitUpgrades.elements[i].options[document.frmKitUpgrades.elements[i].selectedIndex].value.split("#");
				arr2 = document.frmKitUpgrades.elements[i].options[0].value.split("#");
				
				
				if (document.frmKitUpgrades.elements[i].selectedIndex == 0){
					if (clubtotal != 'T'){
						Sum = formatValue(parseFloat(Sum) + parseFloat(getEnglishLocale(arr[1],sLocaleId) * parseInt(arr[2])));
						addSum = formatValue(parseFloat(addSum) + parseFloat(getEnglishLocale(arr[4],sLocaleId) * parseInt(arr[2])));
						
					}
						
				}
				else{
					
					if (clubtotal == 'T'){					
						Sum = formatValue(parseFloat(Sum) + parseFloat(getEnglishLocale(arr[1],sLocaleId) * parseInt(arr[2])));
						addSum = formatValue(parseFloat(addSum) + parseFloat(getEnglishLocale(arr[4],sLocaleId) * parseInt(arr[2])));
						
					}
					else {
						Sum = formatValue(parseFloat(Sum) + parseFloat((parseFloat(getEnglishLocale(arr[1],sLocaleId)) + parseFloat(getEnglishLocale(arr2[1],sLocaleId))) * parseInt(arr2[2])));
						addSum = formatValue(parseFloat(addSum) + parseFloat((parseFloat(getEnglishLocale(arr[4],sLocaleId)) + parseFloat(getEnglishLocale(arr2[4],sLocaleId))) * parseInt(arr2[2])));
						
						
					}
				}				
				configArr = configArr + parseInt(document.frmKitUpgrades.elements[i].selectedIndex)+ "#";
				
				
				
				sel_Count = parseInt(sel_Count) + 1;
				if (clubtotal != 'T'){
					if(document.frmKitUpgrades.elements[i].selectedIndex == 0)	{
						temp = getEnglishLocale(arr2[1],sLocaleId)*arr2[2];
						addtemp	=getEnglishLocale(arr2[4],sLocaleId)*arr2[2];
						eval("document.frmKitUpgrades.price" + sel_Count + ".value=" + formatValue(temp));
						fldname="frmKitUpgrades.price" + sel_Count;
						setFormat(fldname);
						objKitFld = eval("document.frmKitUpgrades.price" + sel_Count);						 
						objKitFld.value= getCurrentLocale(objKitFld.value,sLocaleId);
						if (sAdditionalCurrencySymbol != "") {
						eval("document.frmKitUpgrades.Add_Curr_price" + sel_Count + ".value=" + formatValue(addtemp));												
						addfldname="frmKitUpgrades.Add_Curr_price" + sel_Count;
						setFormat(addfldname);
						objAddKitFld = eval("document.frmKitUpgrades.Add_Curr_price" + sel_Count);	
						objAddKitFld.value= getCurrentLocale(objAddKitFld.value,sLocaleId);				
						}
						
					}
					else	{
						temp = getEnglishLocale(arr[1],sLocaleId);
						temp = (parseFloat(temp) + parseFloat(getEnglishLocale(arr2[1],sLocaleId)))*arr2[2];
						addtemp = getEnglishLocale(arr[4],sLocaleId);
						addtemp = (parseFloat(addtemp) + parseFloat(getEnglishLocale(arr2[4],sLocaleId)))*arr2[2];
						eval("document.frmKitUpgrades.price" + sel_Count + ".value=" + formatValue(temp));
						fldname="frmKitUpgrades.price" + sel_Count;
						setFormat(fldname);
						objKitFld = eval("document.frmKitUpgrades.price" + sel_Count);
						objKitFld.value= getCurrentLocale(objKitFld.value,sLocaleId);
						if (sAdditionalCurrencySymbol != "") {
						eval("document.frmKitUpgrades.Add_Curr_price" + sel_Count + ".value=" + formatValue(addtemp));												
						addfldname="frmKitUpgrades.Add_Curr_price" + sel_Count;
						setFormat(addfldname);
						objAddKitFld = eval("document.frmKitUpgrades.Add_Curr_price" + sel_Count);						 
						objAddKitFld.value= getCurrentLocale(objAddKitFld.value,sLocaleId);				
						}
						
						
					}
				}
			}
				
					//add for hidden field, displat Attributes on page and popup
						if(document.frmKitUpgrades.elements[i].name.substring(0,4) == "sels") {	
						
						//alert(document.frmKitUpgrades.elements[i].name);
																			
							arr =  document.frmKitUpgrades.elements[i].value.split("#");
							
							//alert(arr);			
						/*if(document.frmKitUpgrades.elements[i].name.substring(0,7) == "selsdiv") {	
							arr3 = document.frmKitUpgrades.elements[i].value.split("#");
							//alert(arr3);
						}*/
							//arr3=document.getElementById('dival'+count).value;
							//alert(arr);
							if(typeof(arr[6]) == "undefined")
							{
							arrWeight=arrWeight;
							iWeight=iWeight;
							}
							else
							{
							iWeight=parseFloat(iWeight)+parseFloat(arr[6]);
							//arrWeight=arrWeight+arr[0]+"^"+parseFloat(arr[6])+"|";
							arrWeight=arrWeight+arr[0]+"^";
							}
							iTotweight=iWeight;
							//alert('tot'+iTotweight);
							
							//RegSum=0.00;
							
							
						
										
										if (document.frmKitUpgrades.elements[i].value == ''){
											if (isNaN(arr[1])==true)
											{
											arr[1]=0;
											arr[2]=0;
											arr[7]=0;
											
											}
											
											if (clubtotal != 'T'){
												
												
												Sum = formatValue(parseFloat(Sum) + parseFloat(getEnglishLocale(arr[1],sLocaleId) * parseInt(arr[2])));
												addSum = formatValue(parseFloat(addSum) + parseFloat(getEnglishLocale(arr[4],sLocaleId) * parseInt(arr[2])));
												RegSum=formatValue(parseFloat(RegSum) + parseFloat(getEnglishLocale(arr[2],sLocaleId) * parseInt(arr[7])));
												
											}
												
										
										}
										
										else{
										
											if (clubtotal == 'T'){	
												
												Sum = formatValue(parseFloat(Sum) + parseFloat(getEnglishLocale(arr[1],sLocaleId) * parseInt(arr[2])));
												addSum = formatValue(parseFloat(addSum) + parseFloat(getEnglishLocale(arr[4],sLocaleId) * parseInt(arr[2])));
												RegSum=formatValue(parseFloat(RegSum) + parseFloat(getEnglishLocale(arr[2],sLocaleId) * parseInt(arr[7])));
											}
											else {
											//alert('a'+i+'-'+Sum);
											//alert("array-1"+ arr[1]);
											//alert("array-1"+ arr[2]);
											//alert("array-1"+ arr[3]);
											//alert("array-1"+ arr[4]);
											//alert("array-1"+ arr[5]);
											//alert("array-1"+ arr[6]);
											//alert("array-1"+ arr[7]);
												
												Sum = formatValue(parseFloat(Sum) + parseFloat(getEnglishLocale(arr[1],sLocaleId) * parseInt(arr[2])));
												addSum = formatValue(parseFloat(addSum) + parseFloat(getEnglishLocale(arr[4],sLocaleId) * parseInt(arr[2])));
												//Sum = formatValue(parseFloat(Sum) + parseFloat((parseFloat(getEnglishLocale(arr[1],sLocaleId)) + parseFloat(getEnglishLocale(arr3[1],sLocaleId))) * parseInt(arr3[2])));
												//addSum = formatValue(parseFloat(addSum) + parseFloat((parseFloat(getEnglishLocale(arr[4],sLocaleId)) + parseFloat(getEnglishLocale(arr3[4],sLocaleId))) * parseInt(arr3[2])));
												//alert('stary'+Sum);
													if (isNaN(RegSum)==true)
													{
													RegSum=0.00
													}												
												RegSum= formatValue(parseFloat(RegSum) + parseFloat(getEnglishLocale(arr[2],sLocaleId) * parseInt(arr[7])));
												
												
											}
										}
										//alert('cb'+i+'-'+Sum);
										
										//alert('regtestup'+RegSum);
										//alert('c'+i+'-'+Sum);									
										//alert(document.frmKitUpgrades.elements[i].name);
										//configArr = configArr + parseInt(document.frmKitUpgrades.elements[i].value)+ "#";
										configArr = configArr + parseInt(arr[5])+ "#";
										//alert(configArr);
																			
										 sel_Count = parseInt(sel_Count) + 1;
										
										
										
						
						
						}
						
			
			
			
			if(document.frmKitUpgrades.elements[i].name.substring(0,13) == "upgradehidden")	{
				configArr = configArr + 0 + "#"
				sel_Count = parseInt(sel_Count) + 1;
			}
		}
	
		if(clubtotal != 'T'){
			for(i=0;i<=parseInt(len)-1;i++)	{
				if(document.frmKitUpgrades.elements[i].name.substring(0,13) == "upgradehidden")
					totalvalue= totalvalue + parseFloat(getEnglishLocale(document.frmKitUpgrades.elements[i].value,sLocaleId));
				if(document.frmKitUpgrades.elements[i].name.substring(0,22) == "Add_Curr_upgradehidden")
					addTotalvalue= addTotalvalue + parseFloat(getEnglishLocale(document.frmKitUpgrades.elements[i].value,sLocaleId));									
				
				if(document.frmKitUpgrades.elements[i].name.substring(0,14) == "upgAddRegPrice")
					RegAddSum= RegAddSum + parseFloat(getEnglishLocale(document.frmKitUpgrades.elements[i].value,sLocaleId));
					
					
					
			
			}
		}
		//alert('t='+Sum);
		//alert(totalvalue);
		if (isNaN(Sum)==true)
		{
			Sum=0.00
		}
		
		//alert('reg'+RegSum);
		//alert('reg1'+RegAddSum);
		
		if (isNaN(RegSum)==true)
		{
		RegSum=0.00
		}
			
		
		sRegKitValue=parseFloat(RegSum)+ RegAddSum;
		
		//Changes for Tiered Pricing start
		sRegKitValue1 = parseFloat(RegSum)+parseFloat(QtyLabelPric1);
		sRegKitValue2 = parseFloat(RegSum)+parseFloat(QtyLabelPric2);
		sRegKitValue3 = parseFloat(RegSum)+parseFloat(QtyLabelPric3);
		sRegKitValue4 = parseFloat(RegSum)+parseFloat(QtyLabelPric4);
		sRegKitValue5 = parseFloat(RegSum)+parseFloat(QtyLabelPric5);
		
		if (QtyDis1>0)
		{
		document.frmKitAmt.txtTotalKitValue1.value = parseFloat(Sum)+parseFloat(QtyDis1);			
		}
		if (QtyDis2>0)
		{
		document.frmKitAmt.txtTotalKitValue2.value = parseFloat(Sum)+parseFloat(QtyDis2);
		}
		if (QtyDis3>0)
		{
		document.frmKitAmt.txtTotalKitValue3.value = parseFloat(Sum)+parseFloat(QtyDis3);
		}
		if (QtyDis4>0)
		{
		document.frmKitAmt.txtTotalKitValue4.value = parseFloat(Sum)+parseFloat(QtyDis4);
		}
		if (QtyDis5>0)
		{
		document.frmKitAmt.txtTotalKitValue5.value = parseFloat(Sum)+parseFloat(QtyDis5);
		}
		//Changes for Tiered Pricing ends
		
		
		
		sKitValue=parseFloat(Sum)+ totalvalue;	
		//alert (totalvalue);
		sAddKitValue = parseFloat(addSum)+ addTotalvalue;	
		if (sAdditionalCurrencySymbol != "") {
			if(sKitValue < 0 || sAddKitValue<0)
				alert(getMessage("iValidPriceComb"));
		}
		else {
			if(sKitValue < 0)
				alert(getMessage("iValidPriceComb"));
		}
		//alert(configArr);
		document.frmKitAmt.txtTotalKitValue.value = sKitValue;
		setFormat("frmKitAmt.txtTotalKitValue");
		
		//Changes for Tiered Pricing start
		if(document.frmKitAmt.txtTotalKitValue_Main)
		{
		    document.frmKitAmt.txtTotalKitValue_Main.value = sKitValue;
		    setFormat("frmKitAmt.txtTotalKitValue_Main");
		}
		if (QtyDis1>0)
		{
		    setFormat("frmKitAmt.txtTotalKitValue1");
		}
		if (QtyDis2>0)
		{
		    setFormat("frmKitAmt.txtTotalKitValue2");
		}
		if (QtyDis3>0)
		{
		    setFormat("frmKitAmt.txtTotalKitValue3");
		}
		if (QtyDis4>0)
		{
		    setFormat("frmKitAmt.txtTotalKitValue4");
		}
		if (QtyDis5>0)
		{
		    setFormat("frmKitAmt.txtTotalKitValue5");
		}
		
		//Changes for Tiered Pricing start
				

		if (document.getElementById('regPrices'))
		{
			document.getElementById('regPrices').innerHTML= "$"+CurrencyFormatted(sRegKitValue);
						
		}
		stempKitVal = document.frmKitAmt.txtTotalKitValue.value;
		document.frmKitAmt.txtTotalKitValue.value = getCurrentLocale(stempKitVal,sLocaleId);
		
		if (sAdditionalCurrencySymbol != "") 
		{
		document.frmKitAmt.txtTotalKitValue_Add_Curr.value = sAddKitValue		
		setFormat("frmKitAmt.txtTotalKitValue_Add_Curr");
		stempAddKitVal = document.frmKitAmt.txtTotalKitValue_Add_Curr.value;
		document.frmKitAmt.txtTotalKitValue_Add_Curr.value = getCurrentLocale(stempAddKitVal,sLocaleId);
		}
	}
}
// End of the function CalculateTotal()

function CalculateTotal_old(kitprice,clubtotal,sLocaleId,addKitPrice,count){

	
	
	
	if(typeof(count) == "undefined")
	{
	count=0
	}
		
		
	if(sLocaleId == "")
	sLocaleId = iEnglishLocaleId;
	var i,sel_Count;
	var Sum,addSum,temp,addtemp,arr,arr2,arr3,totalvalue,addTotalvalue,sKitValue,sAddKitValue,objKitFld,objAddKitFld,iWeight,RegSum,RegAddSum,sRegKitValue;
	totalvalue=0;
	addTotalvalue=0;
	configArr=""
	arrWeight="";
	iWeight=0;
	iTotweight="";
	len = document.frmKitUpgrades.elements.length;
	
	
 	 if (sKitCall4Price != "T")
 	 {
		 
		
		 if(clubtotal=='T')
		  {
				
				
				Sum=getEnglishLocale(kitprice,sLocaleId);
				addSum = getEnglishLocale(addKitPrice,sLocaleId);


		  }
		  else
		  {
			
			
			Sum = 0.0;
			addSum = 0.0;
			RegSum=0.0;
			RegAddSum=0.0;
		  }

		 sel_Count = 0;
		
		 for(i=0;i<=parseInt(len)-1;i++)
		 {
			
			
			if(document.frmKitUpgrades.elements[i].type.substring(0,3) == "sel")
			{				
				
				arr =  document.frmKitUpgrades.elements[i].options[document.frmKitUpgrades.elements[i].selectedIndex].value.split("#");
				arr2 = document.frmKitUpgrades.elements[i].options[0].value.split("#");
				
				if (document.frmKitUpgrades.elements[i].selectedIndex == 0)
				{
					if (clubtotal != 'T')
					{
						Sum = formatValue(parseFloat(Sum) + parseFloat(getEnglishLocale(arr[1],sLocaleId) * parseInt(arr[2])));
						addSum = formatValue(parseFloat(addSum) + parseFloat(getEnglishLocale(arr[4],sLocaleId) * parseInt(arr[2])));
						RegSum=formatValue(parseFloat(RegSum) + parseFloat(getEnglishLocale(arr[2],sLocaleId) * parseInt(arr[7])));
					}
						
				}
				else
				{
				
				 
				 if (clubtotal == 'T')
				 {					
					Sum = formatValue(parseFloat(Sum) + parseFloat(getEnglishLocale(arr[1],sLocaleId) * parseInt(arr[2])));
					addSum = formatValue(parseFloat(addSum) + parseFloat(getEnglishLocale(arr[4],sLocaleId) * parseInt(arr[2])));
					RegSum=formatValue(parseFloat(RegSum) + parseFloat(getEnglishLocale(arr[2],sLocaleId) * parseInt(arr[7])));
				 }
					
				else
				{
					
				   	Sum = formatValue(parseFloat(Sum) + parseFloat((parseFloat(getEnglishLocale(arr[1],sLocaleId)) + parseFloat(getEnglishLocale(arr2[1],sLocaleId))) * parseInt(arr2[2])));
					addSum = formatValue(parseFloat(addSum) + parseFloat((parseFloat(getEnglishLocale(arr[4],sLocaleId)) + parseFloat(getEnglishLocale(arr2[4],sLocaleId))) * parseInt(arr2[2])));
					RegSum=formatValue(parseFloat(RegSum) + parseFloat(getEnglishLocale(arr[2],sLocaleId) * parseInt(arr[7])));
						
				}
				}				
				configArr = configArr + parseInt(document.frmKitUpgrades.elements[i].selectedIndex)+ "#";
				
				
				sel_Count = parseInt(sel_Count) + 1;
				if (clubtotal != 'T')
				{
					
					
					if(document.frmKitUpgrades.elements[i].selectedIndex == 0)
					{
						temp = getEnglishLocale(arr2[1],sLocaleId)*arr2[2];
						addtemp	=getEnglishLocale(arr2[4],sLocaleId)*arr2[2];
						eval("document.frmKitUpgrades.price" + sel_Count + ".value=" + formatValue(temp));
						fldname="frmKitUpgrades.price" + sel_Count;
						setFormat(fldname);
						objKitFld = eval("document.frmKitUpgrades.price" + sel_Count);						 
						objKitFld.value= getCurrentLocale(objKitFld.value,sLocaleId);
						if (sAdditionalCurrencySymbol != "") {
						eval("document.frmKitUpgrades.Add_Curr_price" + sel_Count + ".value=" + formatValue(addtemp));												
						addfldname="frmKitUpgrades.Add_Curr_price" + sel_Count;
						setFormat(addfldname);
						objAddKitFld = eval("document.frmKitUpgrades.Add_Curr_price" + sel_Count);	
						objAddKitFld.value= getCurrentLocale(objAddKitFld.value,sLocaleId);				
					}
						
					}
					else	
					{
						
						temp = getEnglishLocale(arr[1],sLocaleId);
						temp = (parseFloat(temp) + parseFloat(getEnglishLocale(arr2[1],sLocaleId)))*arr2[2];
						addtemp = getEnglishLocale(arr[4],sLocaleId);
						addtemp = (parseFloat(addtemp) + parseFloat(getEnglishLocale(arr2[4],sLocaleId)))*arr2[2];
						eval("document.frmKitUpgrades.price" + sel_Count + ".value=" + formatValue(temp));
						fldname="frmKitUpgrades.price" + sel_Count;
						setFormat(fldname);
						objKitFld = eval("document.frmKitUpgrades.price" + sel_Count);
						objKitFld.value= getCurrentLocale(objKitFld.value,sLocaleId);
						if (sAdditionalCurrencySymbol != "") {
						eval("document.frmKitUpgrades.Add_Curr_price" + sel_Count + ".value=" + formatValue(addtemp));												
						addfldname="frmKitUpgrades.Add_Curr_price" + sel_Count;
						setFormat(addfldname);
						objAddKitFld = eval("document.frmKitUpgrades.Add_Curr_price" + sel_Count);						 
						objAddKitFld.value= getCurrentLocale(objAddKitFld.value,sLocaleId);				
					}
					
						
					}
					
				}
				
			}
				
					
					//add for hidden field
						if(document.frmKitUpgrades.elements[i].name.substring(0,4) == "sels") {	
						
						
																			
							arr =  document.frmKitUpgrades.elements[i].value.split("#");
							
							
										
						/*if(document.frmKitUpgrades.elements[i].name.substring(0,7) == "selsdiv") {	
							arr3 = document.frmKitUpgrades.elements[i].value.split("#");
							//alert(arr3);
						}*/
							//arr3=document.getElementById('dival'+count).value;
							//alert(arr3);
							if(typeof(arr[6]) == "undefined")
								{
								arrWeight=arrWeight;
								iWeight=iWeight;
								}
								else
								{
								iWeight=parseFloat(iWeight)+parseFloat(arr[6]);
								//arrWeight=arrWeight+arr[0]+"^"+parseFloat(arr[6])+"|";
								arrWeight=arrWeight+arr[0]+"^";
								}
								iTotweight=iWeight;
								//alert(iWeight);
						
										
										if (document.frmKitUpgrades.elements[i].value == ''){
											if (isNaN(arr[1])==true)
											{
											arr[1]=0;
											arr[2]=0;
											}
											
											if (clubtotal != 'T'){
												
												Sum = formatValue(parseFloat(Sum) + parseFloat(getEnglishLocale(arr[1],sLocaleId) * parseInt(arr[2])));
												addSum = formatValue(parseFloat(addSum) + parseFloat(getEnglishLocale(arr[4],sLocaleId) * parseInt(arr[2])));
											}
												
										
										}
										
										else{
										
											if (clubtotal == 'T'){					
												Sum = formatValue(parseFloat(Sum) + parseFloat(getEnglishLocale(arr[1],sLocaleId) * parseInt(arr[2])));
												addSum = formatValue(parseFloat(addSum) + parseFloat(getEnglishLocale(arr[4],sLocaleId) * parseInt(arr[2])));
												
											}
											else {
											//alert('a'+i+'-'+Sum);
											//alert(arr);
												
												Sum = formatValue(parseFloat(Sum) + parseFloat(getEnglishLocale(arr[1],sLocaleId) * parseInt(arr[2])));
												addSum = formatValue(parseFloat(addSum) + parseFloat(getEnglishLocale(arr[4],sLocaleId) * parseInt(arr[2])));
												//Sum = formatValue(parseFloat(Sum) + parseFloat((parseFloat(getEnglishLocale(arr[1],sLocaleId)) + parseFloat(getEnglishLocale(arr3[1],sLocaleId))) * parseInt(arr3[2])));
												//addSum = formatValue(parseFloat(addSum) + parseFloat((parseFloat(getEnglishLocale(arr[4],sLocaleId)) + parseFloat(getEnglishLocale(arr3[4],sLocaleId))) * parseInt(arr3[2])));
												
												//alert('b'+i+'-'+Sum);
											}
										}
										//alert('cb'+i+'-'+Sum);
										
										
										//alert('c'+i+'-'+Sum);									
										//alert(document.frmKitUpgrades.elements[i].name);
										//configArr = configArr + parseInt(document.frmKitUpgrades.elements[i].value)+ "#";
										configArr = configArr + parseInt(arr[5])+ "#";
										//alert(configArr);
																			
										 sel_Count = parseInt(sel_Count) + 1;
										
										
										
						
						
						}
						
			
			
			
			if(document.frmKitUpgrades.elements[i].name.substring(0,13) == "upgradehidden")	{
				configArr = configArr + 0 + "#"
				sel_Count = parseInt(sel_Count) + 1;
			}
		}
	
		if(clubtotal != 'T'){
			for(i=0;i<=parseInt(len)-1;i++)	{
				if(document.frmKitUpgrades.elements[i].name.substring(0,13) == "upgradehidden")
					totalvalue= totalvalue + parseFloat(getEnglishLocale(document.frmKitUpgrades.elements[i].value,sLocaleId));
				if(document.frmKitUpgrades.elements[i].name.substring(0,22) == "Add_Curr_upgradehidden")
					addTotalvalue= addTotalvalue + parseFloat(getEnglishLocale(document.frmKitUpgrades.elements[i].value,sLocaleId));
					
			if(document.frmKitUpgrades.elements[i].name.substring(0,14) == "upgAddRegPrice")
					RegAddSum= RegAddSum + parseFloat(getEnglishLocale(document.frmKitUpgrades.elements[i].value,sLocaleId));		
					
			//alert('d'+i+'-'+Sum);
			}
		}
		
		if (isNaN(Sum)==true)
		{
			Sum=0.00
		}
		
		
		sRegKitValue=parseFloat(RegSum)+ RegAddSum;
		alert(RegAddSum);
		alert(RegSum);
		sKitValue=parseFloat(Sum)+ totalvalue;   
		
				
		sAddKitValue = parseFloat(addSum)+ addTotalvalue;	
		if (sAdditionalCurrencySymbol != "") {
			if(sKitValue < 0 || sAddKitValue<0)
				alert(getMessage("iValidPriceComb"));
		}
		else {
			if(sKitValue < 0)
				alert(getMessage("iValidPriceComb"));
		}
		document.frmKitAmt.txtTotalKitValue.value = sKitValue;
		
		
		setFormat("frmKitAmt.txtTotalKitValue");
		
		if (document.getElementById('regPrices'))
		{
			
			document.getElementById('regPrices').innerHTML="&nbsp;<strike>$ "+CurrencyFormatted(sRegKitValue)+"</strike>";
			alert(document.getElementById('regPrices').innerHTML="&nbsp;<strike>$ "+CurrencyFormatted(sRegKitValue)+"</strike>");
					
		}
		
		stempKitVal = document.frmKitAmt.txtTotalKitValue.value;
		
		document.frmKitAmt.txtTotalKitValue.value = getCurrentLocale(stempKitVal,sLocaleId);
		if (sAdditionalCurrencySymbol != "") {
		document.frmKitAmt.txtTotalKitValue_Add_Curr.value = sAddKitValue		
		setFormat("frmKitAmt.txtTotalKitValue_Add_Curr");
		stempAddKitVal = document.frmKitAmt.txtTotalKitValue_Add_Curr.value;
		alert (stempAddKitVal);
		document.frmKitAmt.txtTotalKitValue_Add_Curr.value = getCurrentLocale(stempAddKitVal,sLocaleId);
		}
	}
}
// End of the function CalculateTotal()





//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		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  : CustomKitItems.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;
			}
		}
}// End of the function setFormat(field)



function estimateship(sIc,sCustZip,sResi){
	
	var retval,iKitqty,iTotalqty,iMaxCount,sAttvalue,sAttvalue1,sAttvalue2;
	//Added for selection of atleast one attribute by Ashish/Ani - 19/06/2004
	//alert(document.frmKitUpgrades.selhide2.value);
	
	len = document.frmKitUpgrades.elements.length;
	//alert(len);
	var attcount=document.frmKitUpgrades.indcount.value;
	//alert(attcount);
	for(iIndex=0;iIndex<=parseInt(len)-1;iIndex++) {
		if(document.frmKitUpgrades.elements[iIndex].type.substring(0,3) == "sel"){
			sString1 = document.frmKitUpgrades.elements[iIndex].options[0].text;
			sAlert = "Please select at least one "+sString1.toLowerCase().substring(7)+" for estimate shipping.";
			if (document.frmKitUpgrades.elements[iIndex].options.selectedIndex == 0) {
				alert(sAlert);
				return;
			}
		}
		
		
		
	}
	for(i=2;i<=parseInt(attcount);i++) {
								
				
	//alert(i);
	//alert(attcount);
			//sString1 = document.frmKitUpgrades.elements[iIndex].options[0].text;
			sAttvalue=document.getElementById('selcolor'+[i]).innerHTML;
			sAttvalue1=Trim(document.getElementById('selcolors'+[i]).innerHTML);
			if (isBlank(sAttvalue) ==true)
			{
			sAttvalue=document.getElementById('selcolor'+[i]).value;
			//alert(sAttvalue);
			}
			//alert(sAttvalue);
			sAttvalue1 = sAttvalue1.replace(":","");
			sAttvalue1 = sAttvalue1.replace("&amp;","&");
			//alert(sAttvalue1);
			sAlert = "Please select at least one "+sAttvalue1.toLowerCase().substring(7)+" for estimate shipping.";
			//sAlert = "Please select at least one"+sAttvalue1;
			//alert(sAlert);
			//if (sAttvalue.toLowerCase().substring(0,6)=="select")
			if (isBlank(sAttvalue) ==true)
			{
			alert(sAlert);
			//document.getElementById('selcolors'+[i]).style.color='Red';
			return;
						
			}			
				
		}
	iKitqty=document.frmKitAmt.qty.value
	retval=IsNumeric(iKitqty)
	if(document.frmKitAmt.txtTotalKitValue.value < 0){
		alert(getMessage("iValidPriceComb"));
		return;
	}	
	if(retval == 1)	{
		alert(getMessage("iValidQuantity"));
		document.frmKitAmt.qty.value=1;
		document.frmKitAmt.qty.focus();
		return;
	}
	iKitqty = iKitqty*1
	//alert('max'+iMaxCount);
	if ((iMaxCount != "") && (bMaxItem.toLowerCase()=="true")){
		iTotalqty = parseInt(sCartItems)
		if(todo=="update")
			iTotalqty=iTotalqty - parseInt(iQty)
		if((iKitqty + iTotalqty)>parseInt(iMaxCount)){
			alert(getMessage("iTotalQtyExceed") + " " + iMaxCount);
			document.frmKitAmt.qty.value=1;
			document.frmKitAmt.qty.focus();
			return;
		}
	}
	//alert('weight:'+arrWeight);
	//alert(iTotweight);
	
	//document.frmKitInfo.qty.value = document.frmKitAmt.qty.value;
	//document.frmKitInfo1.AttWeight.value = arrWeight;
	//document.frmKitInfo1.txhControl.value = "Submit";
	//document.frmKitInfo1.submit();
	window.open("itemshipcalculator.asp?sAttval="+iTotweight+"&sAttcode="+arrWeight+"&isItemCode="+sIc+"&sZipCode="+sCustZip+"&sResi="+sResi,"0C7BA32642A8469586C312CEVEREST7119B26F3","top=100,left=250,width=650,resizable=no,scrollbars=yes,toolbar=no,height=500,status=yes");
}
// End of the function estimateship(todo)

//***** Function for Bulk Enquiry
function sendBulk(bulkic)
{
    var bulkqty;
    bulkqty = document.getElementById("qty").value;
    if(bulkqty != 0)
    {
	document.frmBulk.bulkic.value = bulkic;
	document.frmBulk.bulkquantity.value = bulkqty;
    	var attcode = GetAttCode(bulkic);
    	
    		if (attcode != undefined)
    		{
    			var l = attcode.length;
		    	var n = l-1;
    			attcode = attcode.substr(0,n);
    			document.frmBulk.bulkattcode.value = attcode;
    			document.frmBulk.submit();
    		}
    		
    		
	    
	}
	else
	{
	    alert("Enter valid quantity");
	}
}
//***** Function for Bulk Enquiry	        
//************* Function to Get Attribute Code
function GetAttCode(sIc){
	
	var retval,iKitqty,iTotalqty,iMaxCount,sAttvalue,sAttvalue1,sAttvalue2;
	//Added for selection of atleast one attribute by Ashish/Ani - 19/06/2004
		
	len = document.frmKitUpgrades.elements.length;
	var attcount=document.frmKitUpgrades.indcount.value;
	
	for(iIndex=0;iIndex<=parseInt(len)-1;iIndex++) {
		if(document.frmKitUpgrades.elements[iIndex].type.substring(0,3) == "sel"){
			sString1 = document.frmKitUpgrades.elements[iIndex].options[0].text;
			sAlert = "Please select at least one "+sString1.toLowerCase().substring(7)+" for bulk inquiry.";
			if (document.frmKitUpgrades.elements[iIndex].options.selectedIndex == 0) {
				alert(sAlert);
				return;
			}
		}
	}
	for(i=2;i<=parseInt(attcount);i++) {				
	
			sAttvalue=document.getElementById('selcolor'+[i]).innerHTML;
			sAttvalue1=Trim(document.getElementById('selcolors'+[i]).innerHTML);
			if (isBlank(sAttvalue) ==true)
			{
			sAttvalue=document.getElementById('selcolor'+[i]).value;
			
			}
			
			sAttvalue1 = sAttvalue1.replace(":","");
			sAttvalue1 = sAttvalue1.replace("&amp;","&");
			
			sAlert = "Please select at least one "+sAttvalue1.toLowerCase().substring(7)+" for bulk enquiry.";
			
			if (isBlank(sAttvalue) ==true)
			{
			alert(sAlert);
			
			return;
						
			}			
				
		}
	iKitqty=document.frmKitAmt.qty.value
	retval=IsNumeric(iKitqty)
	if(document.frmKitAmt.txtTotalKitValue.value < 0){
		alert(getMessage("iValidPriceComb"));
		return false;
	}	
	if(retval == 1)	{
		alert(getMessage("iValidQuantity"));
		document.frmKitAmt.qty.value=1;
		document.frmKitAmt.qty.focus();
		return;
	}
	iKitqty = iKitqty*1
	
	if ((iMaxCount != "") && (bMaxItem.toLowerCase()=="true")){
		iTotalqty = parseInt(sCartItems)
		if(todo=="update")
			iTotalqty=iTotalqty - parseInt(iQty)
		if((iKitqty + iTotalqty)>parseInt(iMaxCount)){
			alert(getMessage("iTotalQtyExceed") + " " + iMaxCount);
			document.frmKitAmt.qty.value=1;
			document.frmKitAmt.qty.focus();
			return;
		}
	}
	
	if (arrWeight != "")
	{
	    return arrWeight;
	}
	else
	{
	    return;
	}
	//window.open("itemshipcalculator.asp?sAttval="+iTotweight+"&sAttcode="+arrWeight+"&isItemCode="+sIc+"&sZipCode="+sCustZip+"&sResi="+sResi,"0C7BA32642A8469586C312CEVEREST7119B26F3","top=100,left=250,width=650,resizable=no,scrollbars=yes,toolbar=no,height=500,status=yes");
}
// End of the function GetAttCode(todo)

//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: This function is used to validate the quantity and submit the form.
//	@	  Pages Affected  : CustomKitItems.asp
//  @		Function Name		: CheckConfig(todo)									
//	@		Input Parameters: todo = action to be done, whether to add, or update a kit 
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function CheckConfig(todo){
	var retval,iKitqty,iTotalqty,iMaxCount,sAttvalue,sAttvalue1,sAttvalue2;
	//Added for selection of atleast one attribute by Ashish/Ani - 19/06/2004
	//alert(document.frmKitUpgrades.selhide2.value);
	len = document.frmKitUpgrades.elements.length;
	//alert(len);
	var attcount=document.frmKitUpgrades.indcount.value;
	//alert(attcount);
	for(iIndex=0;iIndex<=parseInt(len)-1;iIndex++) {
		if(document.frmKitUpgrades.elements[iIndex].type.substring(0,3) == "sel"){
			sString1 = document.frmKitUpgrades.elements[iIndex].options[0].text;
			sAlert = "Please select at least one "+sString1.toLowerCase().substring(7)+".";
			if (document.frmKitUpgrades.elements[iIndex].options.selectedIndex == 0) {
				alert(sAlert);
				return;
			}
		}
		
		
		
	}
	for(i=2;i<=parseInt(attcount);i++) {
								
				
	//alert(i);
	//alert(attcount);
			//sString1 = document.frmKitUpgrades.elements[iIndex].options[0].text;
			sAttvalue=document.getElementById('selcolor'+[i]).innerHTML;
			sAttvalue1=Trim(document.getElementById('selcolors'+[i]).innerHTML);
			if (isBlank(sAttvalue) ==true)
			{
			sAttvalue=document.getElementById('selcolor'+[i]).value;
			//alert(sAttvalue);
			}
			//alert(sAttvalue);
			sAttvalue1 = sAttvalue1.replace(":","");
			sAttvalue1 = sAttvalue1.replace("&amp;","&");
			//alert(sAttvalue1);
			sAlert = "Please select at least one "+sAttvalue1.toLowerCase().substring(7);
			//sAlert = "Please select at least one"+sAttvalue1;
			//alert(sAlert);
			//if (sAttvalue.toLowerCase().substring(0,6)=="select")
			if (isBlank(sAttvalue) ==true)
			{
			alert(sAlert);
			//document.getElementById('selcolors'+[i]).style.color='Red';
			return;
						
			}			
				
		}
	iKitqty=document.frmKitAmt.qty.value
	retval=IsNumeric(iKitqty)
	if(document.frmKitAmt.txtTotalKitValue.value < 0){
		alert(getMessage("iValidPriceComb"));
		return;
	}	
	if(retval == 1)	{
		alert(getMessage("iValidQuantity"));
		document.frmKitAmt.qty.value=1;
		document.frmKitAmt.qty.focus();
		return;
	}
	iKitqty = iKitqty*1
	//alert('max'+iMaxCount);
	if ((iMaxCount != "") && (bMaxItem.toLowerCase()=="true")){
		iTotalqty = parseInt(sCartItems)
		if(todo=="update")
			iTotalqty=iTotalqty - parseInt(iQty)
		if((iKitqty + iTotalqty)>parseInt(iMaxCount)){
			alert(getMessage("iTotalQtyExceed") + " " + iMaxCount);
			document.frmKitAmt.qty.value=1;
			document.frmKitAmt.qty.focus();
			return;
		}
	}
	//alert(configArr);
	document.frmKitInfo.qty.value = document.frmKitAmt.qty.value;
	document.frmKitInfo.configArr.value = configArr;
	document.frmKitInfo.todo.value = todo;
	document.frmKitInfo.submit();
}
// End of the function CheckConfig(todo)


// @@@@@@@@@@@@@@@@@@@@  check for blank
function isBlank(val){
	if(val==null){return true;}
	for(var i=0;i<val.length;i++) {
		if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}
		}
	return true;
	}
// check for blank

//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Trim fuction

function RTrim(str){
	if (str==null){return null;}
	for(var i=str.length-1;str.charAt(i)==" " || str.charAt(i)=="\n" || str.charAt(i)=="\t";i--);
	return str.substring(0,i+1);
	}
//
//@@@@@@@@@@@@@@@@@@@@@@@@@@@

function LTrim(str){
	if (str==null){return null;}
	for(var i=0;str.charAt(i)==" " || str.charAt(i)=="\n" || str.charAt(i)=="\t";i++);
	return str.substring(i,str.length);
	}
function Trim(str){return LTrim(RTrim(str));}
//


//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		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 is used to submit the upgrade items form.
//  @   Pages Affected  : Itemdesc
//  @		Function Name		: UpgradeBuy(itemcode)									
//	@		Input Parameters: itemcode = Item Code									
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function UpgradeBuy(itemcode,iUnits)
{
	iTotalqty = parseInt(sCartItems)
	if ((iMaxCount != "") && (bMaxItem.toLowerCase()=="true")){
		if(iTotalqty >= parseInt(iMaxCount)){
			alert(getMessage("iTotalQtyExceed") + " " + iMaxCount);
			return;
		}
	}
	document.frmUpgrade.ic.value = itemcode;
	document.frmUpgrade.qty.value = iUnits;
	document.frmUpgrade.submit();
}
// End of the function UpgradeBuy(itemcode)

//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@	Description			: This function is to show the Color Disclaimer. 
//	@	Pages Affected			: CustomKitItems.asp
//	@	Function Name			: showdisclaim()									
//	@	Input Parameters		: null
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


function showdisclaim()
{
//	var iIndex,myWin,iCount,sString1,len,sString2,sImgLink;
//	myWin = window.open('','_kitdcl','width=530,height=370')
//	myWin.document.write("<TITLE>Image and Color Disclaimer</TITLE>");
//	myWin.document.write("<table border=0>");
//	myWin.document.write("<tr><td valign=top>");
//	myWin.document.write("<font face='verdana' style='font-size: 8pt'><b>Why wouldn’t the product image exactly match the product being described?</b><br><br></font>");
//	myWin.document.write("</td></tr>");
//	myWin.document.write("<tr><td valign=top>");
//	myWin.document.write("<font face='verdana' style='font-size: 8pt'>Because of the multiple options that some of our products offer we do not always have a picture of every product with every option.&nbsp;&nbsp;In this situation we offer the closest image available to show what the product looks like.<br><br></font>");
//	myWin.document.write("</td></tr>");
//	myWin.document.write("<tr><td valign=top>");
//	myWin.document.write("<font face='verdana' style='font-size: 8pt'><b>Why doesn’t the product look at all like the product I am ordering?</b><br><br></font>");
//	myWin.document.write("</td></tr>");
//	myWin.document.write("<tr><td valign=top>");
//	myWin.document.write("<font face='verdana' style='font-size: 8pt'>On occasion we do make mistakes and it is possible that we have the wrong picture shown on the website.&nbsp;&nbsp;If you think that is the case please feel free to call us at 888-776-2517 with any questions or comments.<br><br></font>");
//	myWin.document.write("</td></tr>");
//	myWin.document.write("<tr><td valign=top>");
//	myWin.document.write("<font face='verdana' style='font-size: 8pt'><b>Are the colors on the website exactly what the product will look like?</b><br><br></font>");
//	myWin.document.write("</td></tr>");
//	myWin.document.write("<tr><td valign=top>");
//	myWin.document.write("<font face='verdana' style='font-size: 8pt'>It is almost impossible to match the colors of our products to the colors that we can show you over the internet.&nbsp;&nbsp;Every monitor shows colors a little differently and the colors of our products will often vary from lot to lot.&nbsp;&nbsp;We do our best to show you the color of our products but if there is any question please give us a call and we would be happy to send you an actual samples for your review.<br><br></font>");
//	myWin.document.write("</td></tr>");
//	myWin.document.write("<tr><td>&nbsp;</td></tr>");
//	myWin.document.write("<tr><td align=center><input type=button name=bClose value='Close Window' onclick='window.close();'></td></tr>");
//	myWin.document.write("</table>");
//	myWin.document.close();
//	myWin.focus();
	window.open("colordisclaimer.html",'win1','width=530,height=370,scrollbars,resizable=no')
}
// End of the function showdisclaim()
//function for resize image

function Resize(img){
  foto1= new Image();
  foto1.src=(img);
  ResizeWidthHeight(img);
}
function ResizeWidthHeight(img){
  if((foto1.width!=0)&&(foto1.height!=0)){
    viewPhoto(img);
  }
  else{
    funzione="ResizeWidthHeight('"+img+"')";
    intervallo=setTimeout(funzione,20);
  }
}
function viewPhoto(img){
  largh=foto1.width+20;
  altez=foto1.height+20;
  stringa="width="+largh+",height="+altez;
  finestra=window.open(img,"",stringa);
}

function estimateitemship(sIc,sCustZip,sResi)
{
	
	var retval,iKitqty,iTotalqty,iMaxCount,sAttvalue,sAttvalue1,sAttvalue2;
	//Added for selection of atleast one attribute by Ashish/Ani - 19/06/2004
	//alert(document.frmKitUpgrades.selhide2.value);
	
	//len = document.frmAdd.elements.length;
	//alert(len);
	
	//alert(attcount);
	window.open("itemshipcalculator.asp?isItemCode="+sIc+"&sZipCode="+sCustZip+"&sResi="+sResi,"0C7BA32642A8469586C312CEVEREST7119B26F3","top=100,left=250,width=650,resizable=no,scrollbars=yes,toolbar=no,height=500,status=yes");
}

function CurrencyFormatted(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}
// end of function CurrencyFormatted()

