function isObj(o){
	if(o!=null&&o!='undefined'){
		return true;
	}
	return false;
}
//editOrder
function saveAndSendOrder(){ //OSBuyNowRecordsConfirmation.asp ; edit prder
	action=confirm('Do you want to save and send this order to customer?');
	if(action){
	document.editOrder.sendOrderFlag.value=1;
	document.editOrder.submit();
	}
}
function reCal(rsOrder_i,obj,ovalue,minvalue,maxvalue){ //OSBuyNowRecordsConfirmation.asp ; edit prder
		
		if(obj.id=='SalesTax')document.getElementById("TaxRate").value=0;
		if(obj.id=='InsuranceCost')document.getElementById("InsuranceRate").value=0;
		
		fvalue=obj.value;
		
		if (fvalue<minvalue || isNaN(fvalue) ){
			alert("Error: Input value must contains a number between " + minvalue + " and " + maxvalue + ".");
			obj.value = ovalue;			
		}
		else if (fvalue>maxvalue){
			alert("Error: Input value must contains a number between " + minvalue + " and " + maxvalue + ".");
			obj.value = ovalue;	
		}else{
			reCalAll();
		}
		
		//document.getElementById(obj).value=Math.round(fvalue);
//document.getElementById("SalesPriceTotal_"+rsOrder_i).innerText='x';
}
function reCalAll(){ //OSBuyNowRecordsConfirmation.asp ; edit orders

	var subTotal=0;
	var OrderTotal=0;
	
	for(i=0;document.getElementById('SalesPrice_' +(i)+ '');i++){
	
		this_SalesPrice=parseFloat(document.getElementById("SalesPrice_"+i).value);
		this_SalesPrice=this_SalesPrice.toFixed(2);
		document.getElementById("SalesPrice_"+i).value=this_SalesPrice;
		
		this_Quantity=parseInt(document.getElementById("Quantity_"+i).value);
		this_SalesPriceTotal=(this_SalesPrice*this_Quantity).toFixed(2);	
		document.getElementById("Quantity_"+i).value=this_Quantity;
		document.getElementById("SalesPriceTotal_"+i).innerText='$ '+formatCurrency(this_SalesPriceTotal);	
		subTotal+=parseFloat(this_SalesPriceTotal);
		
	}
	
	document.getElementById("b4_SubTotal").innerText=formatCurrency(subTotal);
	
	//memDiscount
	memDiscount=parseFloat(document.getElementById("memDiscount").value)
	document.getElementById("memDiscount").value=memDiscount.toFixed(2);
	if(memDiscount > 0){
		subTotal=(subTotal-(subTotal*memDiscount/100)); //find member discount
	}
	subTotal=subTotal.toFixed(2);
	//SubTotal
	document.getElementById("SubTotal").value=subTotal;
	document.getElementById("SubTotal_SPAN").innerText=formatCurrency(subTotal);	
	OrderTotal+=parseFloat(subTotal);
	//SalesTax
	SalesTax=parseFloat(document.getElementById("SalesTax").value);
	document.getElementById("SalesTax").value=SalesTax.toFixed(2);
	TaxRate=parseFloat(document.getElementById("TaxRate").value);
	document.getElementById("TaxRate").value=TaxRate.toFixed(3);
	if(TaxRate > 0){
		SalesTax=(subTotal*(TaxRate/100)).toFixed(2);		
		document.getElementById("SalesTax").value=SalesTax;
	}
	OrderTotal+=parseFloat(SalesTax);
	//InsuranceCost
	InsuranceCost=parseFloat(document.getElementById("InsuranceCost").value);
	document.getElementById("InsuranceCost").value=InsuranceCost.toFixed(2);
	InsuranceRate=parseFloat(document.getElementById("InsuranceRate").value);
	document.getElementById("InsuranceRate").value=InsuranceRate.toFixed(3);
	if(InsuranceRate > 0){
		InsuranceCost=(subTotal*(InsuranceRate/100)).toFixed(2);		
		document.getElementById("InsuranceCost").value=InsuranceCost;
	}
	OrderTotal+=parseFloat(InsuranceCost);
	//ShippingTotal
	if(!document.getElementById("FreeShippingFlag").checked){ //cal shipping
		document.getElementById("ShippingTotal").style.color='#000000';
		ShippingTotal=parseFloat(document.getElementById("ShippingTotal").value);	
		if(ShippingTotal > 0){		
			document.getElementById("ShippingTotal").value=ShippingTotal;
		}
		document.getElementById("ShippingTotal").value=ShippingTotal.toFixed(2);
		OrderTotal+=parseFloat(ShippingTotal);
	}else{
		document.getElementById("ShippingTotal").style.color='#cccccc';
	}
	
	//ShoppingOptionTotal
	ShoppingOptionTotal=parseFloat(document.getElementById("ShoppingOptionTotal").value);		
	document.getElementById("ShoppingOptionTotal").value=ShoppingOptionTotal.toFixed(2);
	OrderTotal+=parseFloat(ShoppingOptionTotal);
	document.getElementById("OrderTotal").value=OrderTotal.toFixed(2);
	document.getElementById("OrderTotal_SPAN").innerText=formatCurrency(OrderTotal);	
	
}

//editOrder

function handleKey_GSOS(e) { //OSBuyNowRecords.asp
var keyCode = e.keyCode 
	if (keyCode==13){ //enter
		return false;
	}
}
function updInsuranceType(val){
if(val==1){
	alert('Calculated by flat insurance rate.');
}else{
	alert('Calculated by insurance percentage.');	
}
parent.document.getElementById("upd").src='http://'+document.domain+'/productcatalog/DynamicFormEle_InsUpd.asp?updCommand=updInsuranceType&val=' + val + '';
}
function writeDetailPdtSource_combo(){
parent.document.getElementById("pdtComboArea").innerHTML=document.getElementById("pdtComboArea").innerHTML;
}

function updateRowPriceDefault(index_i){
	
	// set save_comboPriceStr<%=index_i%> to "0"
	// why? when update price, don't + combo price to updated price when reload
	// when str set to 0, treat run as no combo price
	document.dropmsgform["save_comboPriceStr"+index_i].value="0";
	document.dropmsgform["YourDiscount"+index_i].value="0";
	if(isObj(document.getElementById("lessDiscountTxt"+index_i))){
		document.getElementById("lessDiscountTxt"+index_i).innerHTML="";
	}	
	if(isObj(document.getElementById("seediscount"+index_i))){
		document.getElementById("seediscount"+index_i).innerHTML="";
	}
	document.dropmsgform["thisqtyorder_str"+index_i].value="0";


	//validate
	thisRowPrice = replaceComma(document.dropmsgform["thisRowPrice"+index_i].value);
	if(isNaN(thisRowPrice)){
		alert("Error: Please Input Number.");		
		ovalue = Math.abs(document.dropmsgform["rowPriceDefault"+index_i].value);
		document.dropmsgform["thisRowPrice"+index_i].value = formatCurrency(ovalue);
		return false;
	}
	
	document.dropmsgform["thisRowPrice"+index_i].value = formatCurrency(thisRowPrice);
	document.dropmsgform["rowPriceDefault"+index_i].value = thisRowPrice;
	
	//reload page
	parent.document.getElementById("iframeOnlinebasket").src='http://' + document.domain + '/OS_onlineBasket.asp';

}

function buttomTotal(){
btmTotal.style.visibility = "hidden";
showbuttomTotal();
}

function showbuttomTotal(){
	var objHeight=20;
	btmTotal.style.visibility = "visible";
	btmTotal.style.height=objHeight+"px";
	yPos=document.body.scrollTop+document.body.clientHeight-objHeight;
	
	btmTotal.style.top=yPos+"px";
}


function reload_OS_onlineBasket(){	
	parent.document.getElementById("iframeOnlinebasket").src='http://' + document.domain + '/OS_onlineBasket.asp';
}
//Dynamic drop down menu, shipping, currency, tax
function contractall(name){

if (document.getElementById){
var inc=0
while (document.getElementById(name+"_dropmsg"+inc)){
document.getElementById(name+"_dropmsg"+inc).style.display="none"
inc++
}
}
}

function expandone(name){

	if (document.getElementById){
		var selectedItem=document.getElementById(name).selectedIndex;
		contractall(name)
		document.getElementById(name+"_dropmsg"+selectedItem).style.display="block"
		//alert(document.getElementById(name+"_dropmsg"+selectedItem).id);
	}
}
//Dynamic drop down menu, shipping, currency, tax

function updPaymentStatus(orderid){

	for(i=0;i<=document.OrderStatusform.OrderStatus.length-1;i++){
		if(document.OrderStatusform.OrderStatus[i].selected==true){
			updstatus=document.OrderStatusform.OrderStatus[i].value;
		}
	}
	if(window.opener.parent.parent.document.getElementById("upd")){
		window.opener.parent.parent.document.getElementById("upd").src='http://'+document.domain+'/productcatalog/DynamicFormEle_InsUpd.asp?updCommand=updPaymentStatus&orderid=' + orderid + '&updstatus=' + updstatus + '';
	}else{
		parent.parent.document.getElementById("upd").src='http://'+document.domain+'/productcatalog/DynamicFormEle_InsUpd.asp?updCommand=updPaymentStatus&orderid=' + orderid + '&updstatus=' + updstatus + '';
	}
	document.getElementById("OrderStatus").innerHTML='Order status has been changed to [' + updstatus + ']<br>';
		
}

function addtobasket_catalog(pdtid,flag){
	

	dirPath=document.updformele["c_dirPath_"+(pdtid)].value;
	fileName=document.updformele["c_fileName_"+(pdtid)].value;
	pdtName=document.updformele["c_pdtName_"+(pdtid)].value;
	catid=document.updformele["c_catid_"+(pdtid)].value;
	qty=document.updformele["orderQty_"+(pdtid)].value;
	
	ourPrice=document.updformele["c_ourPrice_"+(pdtid)].value;
	shippingCost=document.updformele["c_shippingCost_"+(pdtid)].value;
	GrossWgt=document.updformele["c_GrossWgt_"+(pdtid)].value;
	
	var optionSelectedValue=''; //build arr
	for(i=0;document.getElementById('option_' +(pdtid)+ '_' +(i)+ '');i++){
		var thisEle = document.getElementById('option_' +(pdtid)+ '_' +(i)+ '');
		var selIndex= thisEle.selectedIndex;
		var thisVal = thisEle[selIndex].value;
		optionSelectedValue+=','+thisVal;
	}
	
	

	
	if(flag==1){ //add
			
		if(parent.iframeOnlinebasket){ //clientside
			var thisFrame=parent.iframeOnlinebasket;
		}else{ //adm
			var thisFrame=iframeOnlinebasket;
		}
		thisFrame.document.upd.flag.value='9';
		thisFrame.document.upd.pdtid.value=pdtid;
		thisFrame.document.upd.qty.value=qty;
		thisFrame.document.upd.dirPath.value=dirPath;
		thisFrame.document.upd.fileName.value=fileName;
		thisFrame.document.upd.pdtName.value=pdtName;
		thisFrame.document.upd.catid.value=catid;	
		
		thisFrame.document.upd.ourPrice.value=ourPrice;
		thisFrame.document.upd.shippingCost.value=shippingCost;
		thisFrame.document.upd.GrossWgt.value=GrossWgt;		
		
		thisFrame.document.upd.optionSelectedValue.value=optionSelectedValue;	
		
		thisFrame.document.upd.target='_self';
		thisFrame.document.upd.action='http://'+document.domain+'/OS_onlineBasket_rfq.asp';
		thisFrame.document.upd.submit();
		document.getElementById("cart_icon"+pdtid).innerHTML = loadCartBt('remove_from_cart','removeSavedItem_rfq('+pdtid+',8,111111,0);');
	}
	
}

function addSaveItem_rfq(pdtid,editIndex,mode){
	//mode: 0=add, 1=edit
	if(parent.document.getElementById("iframeOnlinebasket")){ //client side
		doc=parent.document;
	}
	else if(document.getElementById("iframeOnlinebasket")){
		doc=document;
	}
	
	dirPath=doc.dropmsgform["c_dirPath"].value;
	fileName=doc.dropmsgform["c_fileName"].value;
	pdtName=doc.dropmsgform["c_pdtName"].value;
	catid=doc.dropmsgform["c_catid"].value;
	qty=doc.dropmsgform["orderQty"].value;
	
	
	if(parent.document.getElementById("iframeOnlinebasket")){ //client side
		var thisFrame=parent.iframeOnlinebasket;
	}else{ //adm
		var thisFrame=iframeOnlinebasket;
	}
		thisFrame.document.upd.flag.value="9";
		thisFrame.document.upd.pdtid.value=pdtid;
		thisFrame.document.upd.qty.value=qty;
		thisFrame.document.upd.dirPath.value=dirPath;
		thisFrame.document.upd.fileName.value=fileName;
		thisFrame.document.upd.pdtName.value=pdtName;
		thisFrame.document.upd.catid.value=catid;
		thisFrame.document.upd.target='_self';
		thisFrame.document.upd.action='http://'+document.domain+'/OS_onlineBasket_rfq.asp';
		thisFrame.document.upd.submit();
		
		if(isObj(doc.getElementById("continueShopping"))){
			doc.getElementById("continueShopping").style.display="block";
		}
		
		doc.getElementById("cart_icon"+pdtid).innerHTML = loadCartBt('remove_from_cart','removeSavedItem_rfq('+pdtid+',8,111111);');
}

function removeSavedItem_rfq(pdtid,flag,index,isUneditableItem){

	if(parent.document.getElementById("iframeOnlinebasket")){
		doc=parent.document;
	}else{
		doc=document;
	}	
			
			if(isObj(doc.getElementById("continueShopping"))){
				doc.getElementById("continueShopping").style.display="block";
			}

			if(isObj(doc.getElementById("cart_icon"+pdtid))){
				//detailpdtsouces.asp
					
					if(isObj(doc.dropmsgform["c_editSize"])){ //detail.asp
						doc.getElementById("cart_icon"+pdtid).innerHTML = loadCartBt('add_to_cart','addSaveItem_rfq('+pdtid+',0,0);');
					}else{//catalog.asp
						doc.getElementById("cart_icon"+pdtid).innerHTML = loadCartBt('add_to_cart','addtobasket_catalog('+pdtid+',1);');					
					}	
			}	
		doc.getElementById("iframeOnlinebasket").src='http://'+document.domain+'/OS_onlineBasket_rfq.asp?pdtid='+pdtid+'&flag='+flag+'&index='+index+'&updRecFrame=on&isUneditableItem='+isUneditableItem+'';
}

function addSaveItem(pdtid,editIndex,mode){
	
	//mode: 0=add, 1=edit
	if(parent.document.getElementById("iframeOnlinebasket")){ //client side
		doc=parent.document;
	}
	else if(document.getElementById("iframeOnlinebasket")){
		doc=document;
	}

	//menuShipId=doc.dropmsgform["c_menuShipId"].value;
	dirPath=doc.dropmsgform["c_dirPath"].value;
	fileName=doc.dropmsgform["c_fileName"].value;
	pdtName=doc.dropmsgform["c_pdtName"].value;
	minOrderQty=doc.dropmsgform["c_minOrderQty"].value;
	maxOrderQty=doc.dropmsgform["c_maxOrderQty"].value;
	//nextIndex=doc.dropmsgform["c_nextIndex"].value;
	addmoreflag=doc.dropmsgform["c_addmoreflag"].value;
	catid=doc.dropmsgform["c_catid"].value;
	editSize=doc.dropmsgform["c_editSize"].value;
	qtyOrderStr=doc.dropmsgform["c_qtyOrderStr"].value;
	qty=doc.dropmsgform["orderQty"].value;

	var price="0";
	if(isObj(doc.getElementById("OurPrice_Default"))){
		price=doc.getElementById("OurPrice_Default").value;
	}
	var pdtGrossWgt="0";
	if(isObj(doc.getElementById("pdtGrossWgt"))){
		if(!isNaN(doc.getElementById("pdtGrossWgt").value)){
			pdtGrossWgt=doc.getElementById("pdtGrossWgt").value;
		}
	}

	var taxRate="0";		
		if (isObj(doc.getElementById("dropmsgoptionMenuTax"))){ //@ detailpdtsources.asp
			sel_index = doc.dropmsgform.dropmsgoptionMenuTax.selectedIndex; 		
			taxRate = doc.dropmsgform.dropmsgoptionMenuTax[sel_index].value; 			
		}	
	var InsuranceRate="0";		
		if (isObj(doc.getElementById("dropmsgoptionInsurance"))){ //@ detailpdtsources.asp
			sel_index = doc.dropmsgform.dropmsgoptionInsurance.selectedIndex; 		
			InsuranceRate = doc.dropmsgform.dropmsgoptionInsurance[sel_index].value; 			
		}		
		
	var countryid="0";		
		if (isObj(doc.getElementById("countryid"))){ //@ detailpdtsources.asp
			sel_index = doc.dropmsgform.countryid.selectedIndex; 		
			countryid = doc.dropmsgform.countryid[sel_index].value; 
			if(countryid=='0'){			
				alert(doc.dropmsgform.countryidErrorTxt.value);
				return false;
			}	
		}	
		
	var courierid="0";	
		if (isObj(doc.getElementById("courierid"))){ //@ detailpdtsources.asp
			//sel_index = parent.document.getElementById("courierid").selectedIndex;
			sel_index = doc.getElementById("courierid").selectedIndex;
			
			if(sel_index>=0){
				courierid = doc.getElementById("courierid")[sel_index].value; 
			}else{			
				alert(doc.getElementById("countryidErrorTxt").value);
				return false;
			}
		}		

		
	//find loop combo selected index string
	var comboStr="0";
	var comboId="0";
	var comboStr="0";

	for(i=0;isObj(doc.getElementById("pdtCombo"+i));i++){
		
		if(isObj(doc.getElementById("pdtComboTEXTAREA"+i))){
			comboId = doc.getElementById("thisComboId"+i).value;
			//test : pass in not &# unicode
			this_pdtComboTEXTAREA=(doc.getElementById("pdtComboTEXTAREA"+i).value);
			this_pdtComboTEXTAREA=replaceSTR(this_pdtComboTEXTAREA,',',';');
			comboStr += "$,$" + comboId + "," + this_pdtComboTEXTAREA;
		}
		else if(doc.getElementById("pdtCombo"+i).tagName=="INPUT"){						
				for(j=0;j<=doc.getElementsByName("pdtCombo"+i).length-1;j++){			
					if(doc.getElementsByName("pdtCombo"+i)[j].checked==true){
						comboId = doc.getElementById("thisComboId"+i).value;
						comboStr += "$,$" + comboId + "," + j;
					}
				}
		}
		else if (doc.getElementById("pdtCombo"+i).tagName=="SELECT"){
				index=doc.getElementById("pdtCombo"+i).selectedIndex;
				comboId = doc.getElementById("thisComboId"+i).value;
				comboStr += "$,$" + comboId + "," + index;	
		}
	}	

//pdtCombo_grossWgt" & PdtComboEle_i & "-" & pdtCombo_grossWgtOption_i
	// find selected combo price str
	var comboTotal="0";var comboGrossWgt="0";
	var comboPriceStr="0";var comboGrossWgtStr="0";
	for(i=0;isObj(doc.getElementById("pdtCombo"+i));i++){

		if(doc.getElementById("pdtCombo"+i).tagName=="INPUT"){	
		
			for(j=0;j<=doc.getElementsByName("pdtCombo"+i).length-1;j++){
				if(doc.getElementsByName("pdtCombo"+i)[j].checked==true){
					comboTotal=Math.abs(doc.getElementsByName("pdtCombo"+i)[j].value);		
					comboGrossWgt=Math.abs(doc.getElementById("pdtCombo_grossWgt"+i+"-"+j).value);	
				}
			}

		}
		else if (doc.getElementById("pdtCombo"+i).tagName=="SELECT"){
			index=doc.getElementById("pdtCombo"+i).selectedIndex;
				comboTotal=Math.abs(doc.getElementById("pdtCombo"+i)[index].value);		
				comboGrossWgt=Math.abs(doc.getElementById("pdtCombo_grossWgt"+i+"-"+index).value);	
		}
		comboPriceStr = comboPriceStr + "," + comboTotal //only recording the combo price
		comboGrossWgtStr = comboGrossWgtStr + "," + comboGrossWgt //only recording the combo wgt
		//the both array is balance
	}
	
	
	if(mode==0){
		flag=9;//add
	}else{
		flag=10;//edit
	}
	
	if(parent.document.getElementById("iframeOnlinebasket")){ //client side
			
			parent.iframeOnlinebasket.document.upd.flag.value=flag;
			parent.iframeOnlinebasket.document.upd.editIndex.value=editIndex;
			parent.iframeOnlinebasket.document.upd.editSize.value=editSize;
			parent.iframeOnlinebasket.document.upd.pdtid.value=pdtid;
			parent.iframeOnlinebasket.document.upd.qty.value=qty;
			parent.iframeOnlinebasket.document.upd.price.value=price;
			parent.iframeOnlinebasket.document.upd.dirPath.value=dirPath;
			parent.iframeOnlinebasket.document.upd.fileName.value=fileName;
			parent.iframeOnlinebasket.document.upd.pdtName.value=pdtName;
			parent.iframeOnlinebasket.document.upd.minOrderQty.value=minOrderQty;
			parent.iframeOnlinebasket.document.upd.maxOrderQty.value=maxOrderQty;
			parent.iframeOnlinebasket.document.upd.combo.value=comboStr;
			parent.iframeOnlinebasket.document.upd.catid.value=catid;
			parent.iframeOnlinebasket.document.upd.comboPriceStr.value=comboPriceStr;
			parent.iframeOnlinebasket.document.upd.qtyOrderStr.value=qtyOrderStr;	
			parent.iframeOnlinebasket.document.upd.taxRate.value=taxRate;			
			parent.iframeOnlinebasket.document.upd.countryid.value=countryid;
			parent.iframeOnlinebasket.document.upd.courierid.value=courierid;	
			parent.iframeOnlinebasket.document.upd.comboGrossWgtStr.value=comboGrossWgtStr;	
			parent.iframeOnlinebasket.document.upd.pdtGrossWgtStr.value=pdtGrossWgt;	
			parent.iframeOnlinebasket.document.upd.InsuranceRate.value=InsuranceRate;	
			
			parent.iframeOnlinebasket.document.upd.target='_self';
			parent.iframeOnlinebasket.document.upd.action='http://'+document.domain+'/OS_onlineBasket.asp';
			parent.iframeOnlinebasket.document.upd.submit();
	}else{ //admin
			iframeOnlinebasket.document.upd.flag.value=flag;
			iframeOnlinebasket.document.upd.editIndex.value=editIndex;
			iframeOnlinebasket.document.upd.editSize.value=editSize;
			iframeOnlinebasket.document.upd.pdtid.value=pdtid;
			iframeOnlinebasket.document.upd.qty.value=qty;
			iframeOnlinebasket.document.upd.price.value=price;
			iframeOnlinebasket.document.upd.dirPath.value=dirPath;
			iframeOnlinebasket.document.upd.fileName.value=fileName;
			iframeOnlinebasket.document.upd.pdtName.value=pdtName;
			iframeOnlinebasket.document.upd.minOrderQty.value=minOrderQty;
			iframeOnlinebasket.document.upd.maxOrderQty.value=maxOrderQty;
			iframeOnlinebasket.document.upd.combo.value=comboStr;
			iframeOnlinebasket.document.upd.catid.value=catid;
			iframeOnlinebasket.document.upd.comboPriceStr.value=comboPriceStr;
			iframeOnlinebasket.document.upd.qtyOrderStr.value=qtyOrderStr;	
			iframeOnlinebasket.document.upd.taxRate.value=taxRate;		
			iframeOnlinebasket.document.upd.countryid.value=countryid;
			iframeOnlinebasket.document.upd.courierid.value=courierid;	
			iframeOnlinebasket.document.upd.comboGrossWgtStr.value=comboGrossWgtStr;	
			iframeOnlinebasket.document.upd.pdtGrossWgtStr.value=pdtGrossWgt;	
			iframeOnlinebasket.document.upd.InsuranceRate.value=InsuranceRate;	
			
			iframeOnlinebasket.document.upd.target='_self';
			iframeOnlinebasket.document.upd.action='http://'+document.domain+'/OS_onlineBasket.asp';
			iframeOnlinebasket.document.upd.submit();
	}
	
	//comboStr ...>>> *,*ComboId,Index*,*ComboId,Index*,*ComboId,Index*,*
	//alert("if addmoreflag==0 then set nextIndex = 111111 then find to be delete index @ OS_onlineBasket.asp");
	if(addmoreflag==0){ //only show "remove it"
		if(isObj(doc.getElementById("continueShopping"))){
			doc.getElementById("continueShopping").style.display="block";
		}
		doc.getElementById("cart_icon"+pdtid).innerHTML = loadCartBt('remove_from_cart','removeSavedItem('+pdtid+',8,111111);');
	}else{ // show add-more-to-cart
			
			if(isObj(doc.getElementById("continueShopping"))){
				doc.getElementById("continueShopping").style.display="block";
			}
		doc.getElementById("cart_icon"+pdtid).innerHTML = loadCartBt('add_more_to_cart','addSaveItem('+pdtid+',0,0);');
	}

}

function editBasketItem(catid,pdtid,qty,editIndex,editSize,comboStr){
			
			document.upd.catid.value=catid;
			document.upd.pdtid.value=pdtid;
			document.upd.qty.value=qty;
			document.upd.editIndex.value=editIndex;
			document.upd.editSize.value=editSize;			
			document.upd.comboStr.value=comboStr;

			if(isObj(parent.parent.document.getElementById("text"))){ //admin side
				document.upd.action='http://'+document.domain+'/productcatalog/detail.asp';				
			}else{
				document.upd.action='http://'+document.domain+'/detail.asp';
			}
				document.upd.target='_parent';
				document.upd.submit();
	
//http://127.0.0.1/detail.asp?catid=2272&pdtid=22927&comboStr=0$,$25,1$,$26,0&qty=1&editIndex=2&editSize=3
}

//Cart @ OS_onlineBasket.asp Start
function SetPdtidstr(npdtid,flag){
	if(flag==4){//upd sales tax
		//sales tax drop down menu name in selected
		sel_TaxIndex = document.dropmsgform.dropmsgoptionMenuTax.selectedIndex; //get the selected taxRate index
		taxRate = document.dropmsgform.dropmsgoptionMenuTax[sel_TaxIndex].value; //get the selected taxRate
		document.getElementById("iframeOnlinebasket").src='http://' + document.domain + '/OS_onlineBasket.asp?pdtid='+npdtid+'&flag='+flag+'&taxRate='+taxRate+'';
	}
	else if(flag==5){//upd change selected currecny
		//currecny drop down menu name in selected
		sel_CurrecnyIndex = document.dropmsgform.dropmsgoptionMenuCurr.selectedIndex; //get the selected currecny index
		sel_currecny = document.dropmsgform.dropmsgoptionMenuCurr[sel_CurrecnyIndex].value; //get the selected currecny
		document.getElementById("iframeOnlinebasket").src='http://' + document.domain + '/OS_onlineBasket.asp?pdtid='+npdtid+'&flag='+flag+'&sel_currecny='+sel_currecny+'';
	}	
	else if(flag==11){ //input courier no.
		if(parent.document.getElementById("iframeOnlinebasket")){ //OSBuyNowRecords
			doc=parent.document;
		}
		else if(document.getElementById("iframeOnlinebasket")){ //detailpdtsources
			doc=document;
		}		
		CourierName_selectedIndex=document.dropmsgform.CourierName.selectedIndex;
		CourierName = document.dropmsgform.CourierName[CourierName_selectedIndex].value;
		CourierNo = document.dropmsgform.CourierNo.value;
	
		doc.getElementById("iframeOnlinebasket").src='http://' + document.domain + '/OS_onlineBasket.asp?pdtid='+npdtid+'&flag='+flag+'&CourierName='+CourierName+'&CourierNo='+CourierNo+'';
	}
	else if(flag==111){ //add rfq product
		document.getElementById("iframeOnlinebasket").src='http://' + document.domain + '/OS_onlineBasket.asp?pdtid='+npdtid+'&rfqflag=111';
	}
	else if(flag==12){//upd change selected CountryID
		var countryid=0;
		sel_Index = document.dropmsgform.countryid.selectedIndex;
		countryid = document.dropmsgform.countryid[sel_Index].value;
		document.getElementById("iframeOnlinebasket").src='http://' + document.domain + '/OS_onlineBasket.asp?pdtid='+npdtid+'&flag='+flag+'&countryid='+countryid+'';
	}
	else if(flag==13){//upd change selected CourierID
		var courierid=0;
			sel_Index = parent.document.getElementById("courierid").selectedIndex;
			courierid = parent.document.getElementById("courierid")[sel_Index].value;		
			parent.document.getElementById("iframeOnlinebasket").src='http://' + document.domain + '/OS_onlineBasket.asp?pdtid='+npdtid+'&flag='+flag+'&courierid='+courierid+'';
	}
	else if(flag==14){//upd Insurance
		var InsuranceRate=0; //Insurance drop down menu name in selected		
		sel_Index = document.dropmsgform.dropmsgoptionInsurance.selectedIndex; //get the selected InsuranceRate index				
		InsuranceRate = document.dropmsgform.dropmsgoptionInsurance[sel_Index].value; //get the selected InsuranceRate
		document.getElementById("iframeOnlinebasket").src='http://' + document.domain + '/OS_onlineBasket.asp?pdtid='+npdtid+'&flag='+flag+'&InsuranceRate='+InsuranceRate+'';
	}
	else if(flag==15){ //input couponCode
		if(parent.document.getElementById("iframeOnlinebasket")){ //OSBuyNowRecords
			doc=parent.document;
		}
		couponCode = document.dropmsgform.couponCodeField.value;
		doc.getElementById("iframeOnlinebasket").src='http://' + document.domain + '/OS_onlineBasket.asp?flag=15&couponCode='+couponCode+'';		
	}
	else{
			alert('no match case...');
	}
}

function updateQtyDiscount_detailPdtSource(qty){ //detailPdtSource.asp
	
	//upd qty order discount
	if(isObj(document.dropmsgform.thisqtyorder_str)){
		thisRow=document.dropmsgform.thisqtyorder_str.value;
		eachRow=thisRow.split('$,$');
		found=0;thisQty=Math.abs(qty);
		for(i=1;i<eachRow.length&&found==0;i++){
			thisCol = eachRow[i];
			eachCol=thisCol.split(',');
			cola=Math.abs(eachCol[0]);						
			colc=Math.abs(eachCol[2]);

			if(eachCol[1]!="or above"){ //not last
				colb=Math.abs(eachCol[1]);							
				if(thisQty>=cola&&thisQty<=colb){		
					document.dropmsgform.YourDiscount.value=colc;
					found=1;
				}
			}else{
			
				document.dropmsgform.YourDiscount.value=colc;
				found=1;
			}
		}
		reCalculateTotal();
		setbtmOrderTotal();
	}
	
}

function checknumber(npdtid,obj,minvalue,maxvalue){
		fvalue=document.getElementById(obj).value;
		if (fvalue<minvalue || isNaN(fvalue) ){
			alert("Error: Input value must contains a number between " + minvalue + " and " + maxvalue + ".");
			document.getElementById(obj).value = minvalue;
			fvalue=minvalue;
		}
		else if (fvalue>maxvalue){
			alert("Error: Input value must contains a number between " + minvalue + " and " + maxvalue + ".");
			document.getElementById(obj).value = maxvalue;	
			fvalue=maxvalue;
		}
		
		document.getElementById(obj).value=Math.round(fvalue);
		if(!isObj(parent.parent.document.getElementById("text"))){ //admin : Avoid confusing. don't + comboAmount to Total Amount and List Price
			updateQtyDiscount_detailPdtSource(fvalue);	
		}	
}
function setComboRadioSelected(pdtid,comboId,index_i,comboEle,sclientfolder){ //detailpdtsources.asp
	if(navigator.appName=='Microsoft Internet Explorer')showComboOptImg_radio(index_i,comboEle,sclientfolder);
	reCalculateTotal();
	setbtmOrderTotal();
}
function setComboComboBoxSelected(pdtid,comboId,comboEle,sclientfolder){ //detailpdtsources.asp
	if(navigator.appName=='Microsoft Internet Explorer')showComboOptImg_select(comboEle,sclientfolder);
	reCalculateTotal();
	setbtmOrderTotal();
}
function showComboOptImg_radio(index_i,comboEle,sclientfolder){
	if(document.getElementById('filename_'+comboEle+'_'+index_i)){
		dirpath=document.getElementById('dirpath_'+comboEle+'_'+index_i).value;
		filename=document.getElementById('filename_'+comboEle+'_'+index_i).value;
		setComboOptImg(dirpath,filename,sclientfolder);		
	}
}
function showComboOptImg_select(comboEle,sclientfolder){
	sel_CurrecnyIndex = document.getElementById(comboEle).selectedIndex; //get the selected currecny index
	if(document.getElementById('filename_'+comboEle+'_'+sel_CurrecnyIndex)){
		dirpath=document.getElementById('dirpath_'+comboEle+'_'+sel_CurrecnyIndex).value;
		filename=document.getElementById('filename_'+comboEle+'_'+sel_CurrecnyIndex).value;
		setComboOptImg(dirpath,filename,sclientfolder);	
	}
}
function setComboOptImg(dirpath,filename,sclientfolder){
	img_placeholder.style.display='block';
	img_placeholder.style.left=(document.body.scrollLeft+(document.body.clientWidth/2)-100)+"px";
	img_placeholder.style.top=(document.body.scrollTop+(document.body.clientHeight/2)-200)+"px";	
	img_placeholder.innerHTML='<img src="http://' + document.domain + '/imageResizeLibrary.asp?f=' + sclientfolder + '&file=' + dirpath + filename + '&MaxWidth=200&MaxHeight=200" border="0">';
	setTimeout('closeComboOptImg()', 2000);
}
function closeComboOptImg(){
	img_placeholder.style.display='none';
}

function setbtmOrderTotal(){ //detailpdtsources.asp
		if(document.dropmsgform.dropmsgoptionMenuCurr.tagName=='INPUT'){
			sel_currecny = document.dropmsgform.dropmsgoptionMenuCurr.value; //get the currecny
		}else{ //SELECT //currecny drop down menu name in selected
			sel_CurrecnyIndex = document.dropmsgform.dropmsgoptionMenuCurr.selectedIndex; //get the selected currecny index
			sel_currecny = document.dropmsgform.dropmsgoptionMenuCurr[sel_CurrecnyIndex].value; //get the selected currecny	
		}
		var sel_currecnyRateStr=sel_currecny.split(",");
		selectedCurrCode = sel_currecnyRateStr[0];
			
			if(parent.document.getElementById("btmOrderTotal")){
				if (parent.document.getElementById("YourPrice")){
					parent.document.getElementById("btmItemTotal").innerHTML="Your Price: " + selectedCurrCode + " " + parent.document.getElementById("YourPrice").innerHTML + " - ";
				}else if(parent.document.getElementById("OurPrice")){
					parent.document.getElementById("btmItemTotal").innerHTML="Our Price: " +  selectedCurrCode + " " + parent.document.getElementById("OurPrice").innerHTML + " - ";
				}
				if (parent.document.getElementById("orderTotal")){
					parent.document.getElementById("btmOrderTotal").innerHTML="Order Total: " + selectedCurrCode + " " + parent.document.getElementById("orderTotal").innerHTML;
				}	
			}
}

function reCalculateTotal(){ // recalculate pdt + combo price total //detailpdtsources.asp

	var comboAmount=0;var comboAmount_wDiscount=0; var comboTotal=0;var ListPrice_Amount=0;var OurPrice_Amount=0;
	if(parent.document.getElementById("iframeOnlinebasket")){ //client side
		doc=parent.document;
	}else if(document.getElementById("iframeOnlinebasket")){
		doc=document;		
	}

			//find currency rate
			//currecny drop down menu name in selected
			if(doc.dropmsgform.dropmsgoptionMenuCurr.tagName=='INPUT'){
				sel_currecny = doc.dropmsgform.dropmsgoptionMenuCurr.value; //get the currecny
			}else{ //SELECT
				sel_CurrecnyIndex = doc.dropmsgform.dropmsgoptionMenuCurr.selectedIndex; //get the selected currecny index
				sel_currecny = doc.dropmsgform.dropmsgoptionMenuCurr[sel_CurrecnyIndex].value; //get the selected currecny
			}
			var sel_currecnyRateStr=sel_currecny.split(",");
			sel_currecnyRate = Math.abs(sel_currecnyRateStr[1]);
			
			if(!isObj(parent.parent.document.getElementById("text"))){ //admin : Avoid confusing. don't + comboAmount to Total Amount and List Price
				comboAmount = calComboAmount(0); // cal the combo (price x curr) total amount
			}else{
				sel_currecnyRate = 1; //admin : reset to 1
			}
			
			// set ListPrice (price x curr)
			if(isObj(doc.getElementById("ListPrice"))){
				ListPrice_Default = Math.abs(doc.getElementById("ListPrice_Default").value);		
				ListPrice_Default = formatCurrency(sel_currecnyRate*Math.abs(ListPrice_Default));		
				ListPrice_Default = replaceComma(ListPrice_Default);	
				ListPrice_Amount = comboAmount + Math.abs(ListPrice_Default);
				doc.getElementById("ListPrice").innerHTML = formatCurrency(ListPrice_Amount);
				
			}
			
			// set OurPrice (price x curr)
			if(isObj(doc.getElementById("OurPrice"))){
				OurPrice_Default = Math.abs(doc.getElementById("OurPrice_Default").value);	
				OurPrice_Default = formatCurrency(sel_currecnyRate*Math.abs(OurPrice_Default));		
				OurPrice_Default = Math.abs(replaceComma(OurPrice_Default));	
				
				OurPrice_Amount = comboAmount + OurPrice_Default;
				if(isObj(doc.getElementById("YourDiscount"))){
					doc.getElementById("OurPrice").innerHTML = "<s>" +  formatCurrency(OurPrice_Amount) + "</s>";			
				}else{
					doc.getElementById("OurPrice").innerHTML =  formatCurrency(OurPrice_Amount);
				}	
			}
			
			if(isObj(doc.getElementById("YourDiscount"))){	
				// x discount
				YourDiscount=Math.abs(doc.getElementById("YourDiscount").value);
				OurPrice_Default = Math.abs(doc.getElementById("OurPrice_Default").value);			
				OurPrice_Default=OurPrice_Default-(OurPrice_Default*YourDiscount/100);		
				OurPrice_Default = formatCurrency(OurPrice_Default);		
				OurPrice_Default = Math.abs(replaceComma(OurPrice_Default));	
				//x currency		
				OurPrice_Default = formatCurrency(sel_currecnyRate*OurPrice_Default);		
				OurPrice_Default = Math.abs(replaceComma(OurPrice_Default));	
				OurPrice_Default_wDiscount=OurPrice_Default;
				
				if(!isObj(parent.parent.document.getElementById("text"))){ //admin : Avoid confusing. don't + comboAmount to Total Amount and List Price
					comboAmount_wDiscount = calComboAmountDis(0); // cal combo : price x discount x curr
				}
				YourPrice_Amount = comboAmount_wDiscount + OurPrice_Default_wDiscount
				
				doc.getElementById("YourPrice").innerHTML = formatCurrency(YourPrice_Amount);
			}
			
			YouSave_Amount=ListPrice_Amount-OurPrice_Amount;
			
			//find YouSave_Amount
			if(isObj(doc.getElementById("YourDiscount"))){		
				discountRate=Math.abs(doc.getElementById("YourDiscount").value);
				
				if(discountRate>0){
					YourPrice_Amount = OurPrice_Amount - (OurPrice_Amount*discountRate/100);
					if(ListPrice_Amount > 0){
						YouSave_Amount = ListPrice_Amount - YourPrice_Amount;
					}else{
						YouSave_Amount = OurPrice_Amount - YourPrice_Amount;
					}	
				}
			}
		
			
			if(YouSave_Amount>0){
				if(ListPrice_Amount>0){
					YouSavePercent = YouSave_Amount / ListPrice_Amount * 100;
				}else{
					YouSavePercent = YouSave_Amount / OurPrice_Amount * 100;
				}
			}else{
				YouSavePercent = 0;
				YouSave_Amount = 0;
			}
			
			//set YouSave %
			if(isObj(doc.getElementById("YouSave"))){
				doc.getElementById("YouSave").innerHTML=formatCurrency(YouSave_Amount);
				doc.getElementById("YouSave_Per").innerHTML=" ("+formatCurrency(YouSavePercent)+"%)";	
			}
			//YourDiscount_Rate
			if(isObj(doc.getElementById("YourDiscount_Rate"))){
				//doc.getElementById("YourDiscount_Rate").innerHTML="Less "+(doc.getElementById("YourDiscount").value)+"%";
				doc.getElementById("YourDiscount_Rate").innerHTML=(doc.getElementById("YourDiscount").value)+"%";
			}

}

function calComboAmount(comboAmount){ //calculate combo (Price x Curr) total amount //detailpdtsources.asp
		
		for(i=0;isObj(doc.getElementById("pdtCombo"+i));i++){
		
					if(doc.getElementById("pdtCombo"+i).tagName=="INPUT"){					
						for(j=0;j<=doc.getElementsByName("pdtCombo"+i).length-1;j++){
							if(doc.getElementsByName("pdtCombo"+i)[j].checked==true){
								comboTotal=Math.abs(doc.getElementsByName("pdtCombo"+i)[j].value);						
							}
						}
					}
					else if (doc.getElementById("pdtCombo"+i).tagName=="SELECT"){
						index=doc.getElementById("pdtCombo"+i).selectedIndex;
							comboTotal=Math.abs(doc.getElementById("pdtCombo"+i)[index].value);			
					}
					
					// x Currency rate
					comboTotal = formatCurrency(sel_currecnyRate*comboTotal);							
					comboTotal = replaceComma(comboTotal);	
		
					comboAmount = comboAmount + Math.abs(comboTotal);
					comboAmount = formatCurrency(comboAmount);
					comboAmount = replaceComma(comboAmount);	
					comboAmount = Math.abs(comboAmount);
			
			}
			
			return comboAmount;
}


function calComboAmountDis(comboAmountDis){ //calculate combo (Price x Curr) total amount //detailpdtsources.asp
			var YourDiscount=0;
			if(isObj(doc.getElementById("YourDiscount"))){	
				YourDiscount=Math.abs(doc.getElementById("YourDiscount").value);
			}
			
			for(i=0;isObj(doc.getElementById("pdtCombo"+i));i++){
					
					if(doc.getElementById("pdtCombo"+i).tagName=="INPUT"){					
						for(j=0;j<=doc.getElementsByName("pdtCombo"+i).length-1;j++){
							if(doc.getElementsByName("pdtCombo"+i)[j].checked==true){
								comboTotal=Math.abs(doc.getElementsByName("pdtCombo"+i)[j].value);						
							}
						}
					}
					else if (doc.getElementById("pdtCombo"+i).tagName=="SELECT"){
						index=doc.getElementById("pdtCombo"+i).selectedIndex;
							comboTotal=Math.abs(doc.getElementById("pdtCombo"+i)[index].value);			
					}
					
					// x discount					
					if(YourDiscount>0){
						comboTotal=formatCurrency(comboTotal-(comboTotal*YourDiscount/100));
						comboTotal = Math.abs(replaceComma(comboTotal));	
					}
					// x Currency rate
					comboTotal = formatCurrency(sel_currecnyRate*comboTotal);							
					comboTotal = Math.abs(replaceComma(comboTotal));	
		
					comboAmountDis = comboAmountDis + comboTotal;
					comboAmountDis = formatCurrency(comboAmountDis);
					comboAmountDis = replaceComma(comboAmountDis);	
					comboAmountDis = Math.abs(comboAmountDis);
			}
			return comboAmountDis;
}
//Cart @ OS_onlineBasket.asp End

//Cart @ OSBuyNowRecords.asp Start
function checknumber_OSBuyNowRecords(npdtid,obj,minvalue,maxvalue,index,flag){

		fvalue=document.getElementById(obj).value;
		if (fvalue<minvalue || isNaN(fvalue) ){
			alert("Error: Input value must contains a number between " + minvalue + " and " + maxvalue + ".");
			document.getElementById(obj).value = Math.round(minvalue);
		}
		else if (fvalue>maxvalue){
			alert("Error: Input value must contains a number between " + minvalue + " and " + maxvalue + ".");
			document.getElementById(obj).value = Math.round(maxvalue);	
		}else{
			document.getElementById(obj).value=Math.round(fvalue);
		}
		SetPdtidstr_OSBuyNowRecords(npdtid,flag,index);


}

function updateQtyDiscount(qty,index){ // OSBuyNowRecords.asp

	var isUneditableItem="0";
	if(isObj(document.dropmsgform["isUneditableItem"+(index)])){
		isUneditableItem=document.dropmsgform["isUneditableItem"+(index)].value;
	}
	
	if(isUneditableItem=="0"){
			//upd qty order discount
			if(isObj(document.dropmsgform["thisqtyorder_str"+(index)])){
				
				colc=0;
				thisRow=document.dropmsgform["thisqtyorder_str"+(index)].value;
				eachRow=thisRow.split('$,$');
				found=0;thisQty=Math.abs(qty);
				for(i=1;i<eachRow.length&&found==0;i++){
					thisCol = eachRow[i];
					eachCol=thisCol.split(',');
					cola=Math.abs(eachCol[0]);						
					colc=Math.abs(eachCol[2]);
					
					if(eachCol[1]!="or above"){ //not last
						colb=Math.abs(eachCol[1]);							
						if(thisQty>=cola&&thisQty<=colb){		
							document.dropmsgform["YourDiscount"+(index)].value=colc;
							found=1;
						}
					}else{
					
						document.dropmsgform["YourDiscount"+(index)].value=colc;
						found=1;
					}
		
				}
				
				if(isObj(document.getElementById("lessDiscountTxt"+(index)))){
					if(document.dropmsgform["thisqtyorder_str"+(index)].value!="0"&&document.dropmsgform["thisqtyorder_str"+(index)].value!=""){
						document.getElementById("lessDiscountTxt"+(index)).innerHTML = '<br> - ' +colc+ '%';
					}
				} 
				
			}
	}		
}
function SetPdtidstr_OSBuyNowRecords(npdtid,flag,index){
	
	if (flag==2||flag==6){//2=upd qty //6=upd SAVE QTY
			if(document.getElementById("qty"+index)){	//@ OS_onlineBasket.asp upd qty
				nqty=Math.round(document.getElementById("qty"+index).value);
				updateQtyDiscount(nqty,index);
				parent.document.getElementById("iframeOnlinebasket").src='http://' + document.domain + '/OS_onlineBasket.asp?pdtid='+npdtid+'&qty='+nqty+'&flag='+flag+'&index='+index+'';
			}
			
			if(document.getElementById("qty_"+index)){	//@OSBuyNowRecords.asp upd qty				
				nqty=Math.round(document.getElementById("qty_"+index).value);
				updateQtyDiscount(nqty,index);
				parent.document.getElementById("iframeOnlinebasket").src='http://' + document.domain + '/OS_onlineBasket.asp?pdtid='+npdtid+'&qty='+nqty+'&flag='+flag+'&index='+index+'';				
			}
	}
	else if(flag==14){//upd Insurance
		var InsuranceRate=0;
		sel_Index = document.dropmsgform.dropmsgoptionInsurance.selectedIndex; 
		InsuranceRate = document.dropmsgform.dropmsgoptionInsurance[sel_Index].value; 
		parent.document.getElementById("iframeOnlinebasket").src='http://' + document.domain + '/OS_onlineBasket.asp?pdtid='+npdtid+'&flag='+flag+'&InsuranceRate='+InsuranceRate+'';
		
	}
	else if(flag==4){//upd sales tax
		//sales tax drop down menu name in selected
		sel_TaxIndex = document.dropmsgform.dropmsgoptionMenuTax.selectedIndex; //get the selected taxRate index
		taxRate = document.dropmsgform.dropmsgoptionMenuTax[sel_TaxIndex].value; //get the selected taxRate
		parent.document.getElementById("iframeOnlinebasket").src='http://' + document.domain + '/OS_onlineBasket.asp?pdtid='+npdtid+'&flag='+flag+'&taxRate='+taxRate+'';
	}
	else if(flag==5){//upd change selected currecny
		//currecny drop down menu name in selected		
		sel_CurrecnyIndex = document.dropmsgform.dropmsgoptionMenuCurr.selectedIndex; //get the selected currecny index
		sel_currecny = document.dropmsgform.dropmsgoptionMenuCurr[sel_CurrecnyIndex].value; //get the selected currecny		
		parent.document.getElementById("iframeOnlinebasket").src='http://' + document.domain + '/OS_onlineBasket.asp?pdtid='+npdtid+'&flag='+flag+'&sel_currecny='+sel_currecny+'';
	}else if(flag==12){//upd change selected CountryID
		var countryid=0;
		sel_Index = document.dropmsgform.countryid.selectedIndex;
		countryid = document.dropmsgform.countryid[sel_Index].value;
		parent.document.getElementById("iframeOnlinebasket").src='http://' + document.domain + '/OS_onlineBasket.asp?pdtid='+npdtid+'&flag='+flag+'&countryid='+countryid+'';
	}
	else if(flag==13){//upd change selected CourierID
		var courierid=0;
		sel_Index = document.getElementById("courierid").selectedIndex;
		courierid = document.getElementById("courierid")[sel_Index].value;
		parent.document.getElementById("iframeOnlinebasket").src='http://' + document.domain + '/OS_onlineBasket.asp?pdtid='+npdtid+'&flag='+flag+'&courierid='+courierid+'';
	}		
	else{

		alert("do nothing...");
			
	}
}

function loadCartBt(thisBt,thisFunction){
	
	if(parent.document.getElementById("iframeOnlinebasket")){
		doc=parent.document;
	}else{
		doc=document;
	}	
	thisBtTxt = doc.dropmsgform[thisBt+'_txt'].value; //get the field value
	TP_CustomFolderName=getCustomFolderName();
	
	str='<table border="0" cellpadding="0" cellspacing="0" style="cursor:hand;" onclick="'+thisFunction+'">';
    str+='<tr>';
    str+='<td><img src="http://'+document.domain+'/ClientFolder/CustomSet/' + TP_CustomFolderName + '/cartBts/'+thisBt+'.gif"></td>';
	str+='<td><img src="http://'+document.domain+'/ClientFolder/CustomSet/' + TP_CustomFolderName + '/cartBts/cartbt_space_5px.gif"></td>';
	str+='<td align="center" background="http://'+document.domain+'/ClientFolder/CustomSet/' + TP_CustomFolderName + '/cartBts/cartbt_space_5px.gif" class=cartBtTxt>' + thisBtTxt + '</td>';
    str+='<td><img src="http://'+document.domain+'/ClientFolder/CustomSet/' + TP_CustomFolderName + '/cartBts/cartbt_space_5px.gif"></td>';
    str+='<td><img src="http://'+document.domain+'/ClientFolder/CustomSet/' + TP_CustomFolderName + '/cartBts/cartbt_right.gif"></td>';
  	str+='</tr>';
	str+='</table>';
	
	return str;
	
}


function removeSavedItem(pdtid,flag,index,isUneditableItem){

	if(parent.document.getElementById("iframeOnlinebasket")){
		doc=parent.document;
	}else{
		doc=document;
	}	
			if(isObj(doc.getElementById("continueShopping"))){
				doc.getElementById("continueShopping").style.display="none";
			}
			if(isObj(doc.getElementById("cart_icon"+pdtid))){
				//detailpdtsouces.asp
				addmoreflag=0;
				if(isObj(doc.dropmsgform["c_addmoreflag"])){
					addmoreflag=doc.dropmsgform["c_addmoreflag"].value;
				}
				
				if(addmoreflag==0){				
					if(isObj(doc.dropmsgform["c_editSize"])){ //detail.asp
						doc.getElementById("cart_icon"+pdtid).innerHTML = loadCartBt('add_to_cart','addSaveItem('+pdtid+',0,0);');
					}else{//catalog.asp
						doc.getElementById("cart_icon"+pdtid).innerHTML = loadCartBt('add_to_cart','addtobasket_catalog('+pdtid+',1);');					
					}	
					
				}else{
					doc.getElementById("cart_icon"+pdtid).innerHTML = loadCartBt('add_more_to_cart','addSaveItem('+pdtid+',0,0);');
				}	
			}	

		doc.getElementById("iframeOnlinebasket").src='http://'+document.domain+'/OS_onlineBasket.asp?pdtid='+pdtid+'&flag='+flag+'&index='+index+'&updRecFrame=on&isUneditableItem='+isUneditableItem+'';
}




//Cart @ OSBuyNowRecords.asp End

<!-- Begin
function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
//return (((sign)?'':'-') + '$' + num + '.' + cents);
return (((sign)?'':'-') + num + '.' + cents);
}
//  End -->

<!--reset Scroll table width-->
function ResideTBCol(){ //// not in USE

		for(tbId=1;isObj(document.getElementById("headTable_"+tbId));tbId++){
		
			document.getElementById("my_"+tbId+"_x").style.overflowX='scroll';
			document.getElementById("my_"+tbId+"_y").style.overflowY='scroll';
		
			for(i=1;document.getElementById("THead_"+tbId+"_"+i);i++){
				oTHead=document.getElementById("THead_"+tbId+"_"+i);
				oTRow=document.getElementById("TRow_"+tbId+"_"+i);
					oTHead.style.width=oTHead.clientWidth;
					oTRow.style.width=oTHead.clientWidth;
			}
			
			for(i=1;document.getElementById("THead_"+tbId+"_"+i);i++){
				oTHead=document.getElementById("THead_"+tbId+"_"+i);
				oTRow=document.getElementById("TRow_"+tbId+"_"+i);
					oTHead.style.width=oTRow.clientWidth;
					oTRow.style.width=oTRow.clientWidth;
			}
			
					document.getElementById("headTable_"+tbId).style.width=document.getElementById("rowTable_"+tbId).clientWidth;
					document.getElementById("rowTable_"+tbId).style.width=document.getElementById("headTable_"+tbId).clientWidth;
		}			

}
<!--reset Scroll table width-->
function readOrderHistory(eOrderid,readFlag){
	document.getElementById("OSBuyNowRecords").src='http://'+document.domain+'/OSBuyNowRecordsConfirmation.asp?eOrderid='+eOrderid+'&readFlag='+readFlag+'';
}

// reside iframe height
function onloadaction(){
	//autofitIframe 	
	if(parent.document.getElementById(window.name)){
		parent.document.getElementById(window.name).style.height=this.document.body.scrollHeight+"px"
	}
	if(isObj(document.getElementById("headTable_1"))){
		//rside scrollable table col @ OSBuyNowRecordsConfirmation.asp
		ResideTBCol();
	}
}

var pre_updRecFrame=0;var pre_resetShipAndCurrAtDetail=0;var pre_showmybasket=0; var pre_subtotal=0; var pre_shippingAmount=0
var pre_taxCost=0; var pre_taxRate=0; var pre_selectedCurrCode=0; var pre_selectedCurrRate=0; var pre_InsuranceCost=0; var pre_InsuranceRate=0;
var pre_selectedCountryName=0; var pre_selectedPackageName=0; var pre_GrossWgtAmount=0; var pre_DiscountNSurchargeINC=0; var pre_maxCardPurchaseAmount=0;
var pre_couponCode=0;pre_couponMode=0;pre_couponRate=0;pre_couponOnly=0;pre_couponMinimumSpending=0;pre_rsServerName_CurrentID=0;pre_uptoPriceFreeShipping=0;

function loadCartCheck(){
	if(parent.document.getElementById("pdtComboArea").innerHTML==''){ //not yet loaded 
		setTimeout("loadCartCheck()",100)
	}else{
		loadCartNow_action(pre_updRecFrame,pre_resetShipAndCurrAtDetail,pre_showmybasket,pre_subtotal,pre_shippingAmount,pre_taxCost,pre_taxRate,pre_selectedCurrCode,pre_selectedCurrRate,pre_InsuranceCost,pre_InsuranceRate,pre_selectedCountryName,pre_selectedPackageName,pre_GrossWgtAmount,pre_DiscountNSurchargeINC,pre_maxCardPurchaseAmount,pre_couponCode,pre_couponMode,pre_couponRate,pre_couponOnly,pre_couponMinimumSpending,pre_rsServerName_CurrentID,pre_uptoPriceFreeShipping);
	}
}
function loadCartNow(updRecFrame,resetShipAndCurrAtDetail,showmybasket,subtotal,shippingAmount,taxCost,taxRate,selectedCurrCode,selectedCurrRate,InsuranceCost,InsuranceRate,selectedCountryName,selectedPackageName,GrossWgtAmount,DiscountNSurchargeINC,maxCardPurchaseAmount,couponCode,couponMode,couponRate,couponOnly,couponMinimumSpending,rsServerName_CurrentID,uptoPriceFreeShipping){
	if(parent.document.getElementById("pdtComboArea")){ //detailPdtSources.asp	
		//set var
		pre_updRecFrame=updRecFrame;pre_resetShipAndCurrAtDetail=resetShipAndCurrAtDetail;pre_showmybasket=showmybasket;pre_subtotal=subtotal;pre_shippingAmount=shippingAmount;
		pre_taxCost=taxCost;pre_taxRate=taxRate;pre_selectedCurrCode=selectedCurrCode;pre_selectedCurrRate=selectedCurrRate;pre_InsuranceCost=InsuranceCost;pre_InsuranceRate=InsuranceRate;
		pre_selectedCountryName=selectedCountryName;pre_selectedPackageName=selectedPackageName;pre_GrossWgtAmount=GrossWgtAmount;pre_DiscountNSurchargeINC=DiscountNSurchargeINC;pre_maxCardPurchaseAmount=maxCardPurchaseAmount;
		pre_couponCode=couponCode;pre_couponMode=couponMode;pre_couponRate=couponRate;pre_couponOnly=couponOnly;pre_couponMinimumSpending=couponMinimumSpending;pre_rsServerName_CurrentID=rsServerName_CurrentID;pre_uptoPriceFreeShipping=uptoPriceFreeShipping;
		loadCartCheck();
	}else{ //OSBuyNowRecords
		loadCartNow_action(updRecFrame,resetShipAndCurrAtDetail,showmybasket,subtotal,shippingAmount,taxCost,taxRate,selectedCurrCode,selectedCurrRate,InsuranceCost,InsuranceRate,selectedCountryName,selectedPackageName,GrossWgtAmount,DiscountNSurchargeINC,maxCardPurchaseAmount,couponCode,couponMode,couponRate,couponOnly,couponMinimumSpending,rsServerName_CurrentID,uptoPriceFreeShipping);
	}
}	

function loadCartNow_action(updRecFrame,resetShipAndCurrAtDetail,showmybasket,subtotal,shippingAmount,taxCost,taxRate,selectedCurrCode,selectedCurrRate,InsuranceCost,InsuranceRate,selectedCountryName,selectedPackageName,GrossWgtAmount,DiscountNSurchargeINC,maxCardPurchaseAmount,couponCode,couponMode,couponRate,couponOnly,couponMinimumSpending,rsServerName_CurrentID,uptoPriceFreeShipping){


	
			if(updRecFrame=="1"){			
				//action: remove item from cart OSBuyNowSources.asp
				//request to reload the below iframe for update amount
				//request from OSBuyNowSources.asp+GSOnlineStore.js{function removeItem(pdtid)}
				if (parent.document.getElementById("OSBuyNowRecords")){
					parent.document.getElementById("OSBuyNowRecords").src='http://'+document.domain+'/OSBuyNowRecords.asp'
				}				
				/////////////parent.document.getElementById("iframeOnlinebasket").src='http://'+document.domain+'/OS_onlineBasket.asp'
			}
	
	if(parent.document.getElementById("orderTotal")){	 //detailPdtSources.asp	
			
			var memDiscount=0;bf_subtotalvalue=0;
			bf_subtotalvalue=subtotal;
			if(isObj(parent.document.dropmsgform.DiscountRate)){
				memDiscount=Math.abs(parent.document.dropmsgform.DiscountRate.value);				
			}
			
			//detailPdtSources.asp	
			var coupon_Deduction=0; //deduct sub-total [0]
			if(isObj(parent.document.dropmsgform.coupon_Deduction)){
				coupon_Deduction=Math.abs(parent.document.dropmsgform.coupon_Deduction.value);
			}

			//detailPdtSources.asp	
			if(coupon_Deduction!=1){ //deduct sub-total [0] ; member discount will be disabled if deduct order-total [1]
			
						if(couponMode!=''){ //use coupon
								
								if(subtotal!=0&&subtotal>=Math.abs(couponMinimumSpending)){ //meet min spending$
									
												if(couponOnly=='1'&&couponMode=='0'){  //[only coupon] && [-%%%]
													memDiscount=Math.abs(couponRate); 
												}else if(couponOnly=='0'&&couponMode=='0'){ //[member + coupon] && [-%%%]
													memDiscount=Math.abs(couponRate)+memDiscount; //(Member + coupon)[-%]
												}
												
												//Entry discount module
												if(couponOnly=='1'&&couponMode=='1'){ //[only coupon] && [-$$$]
													couponRate=Math.abs(couponRate)*selectedCurrRate;
													formatCurrency(couponRate);
														subtotal=subtotal-Math.abs(couponRate);									
														parent.document.getElementById("yourdiscountRate").innerHTML = parent.document.getElementById('Less_txt').value + ' '+ selectedCurrCode + formatCurrency(couponRate)+'';
																							
												}else if(couponOnly=='0'&&couponMode=='1'){ //[member + coupon] && [-$$$]
													couponRate=Math.abs(couponRate)*selectedCurrRate;
													formatCurrency(couponRate);
														subtotal=subtotal-(subtotal*memDiscount/100); //find member discount
														subtotal=subtotal-Math.abs(couponRate); //mix with coupon
														//reset
														parent.document.getElementById("yourdiscountRate").innerHTML='';
														if(memDiscount>0){
															parent.document.getElementById("yourdiscountRate").innerHTML += parent.document.getElementById('Less_txt').value + ' ' + memDiscount+'% ' + parent.document.getElementById('LessAgain_txt').value;
														}
														parent.document.getElementById("yourdiscountRate").innerHTML += ' ' + parent.document.getElementById('Less_txt').value + ' ' +selectedCurrCode + formatCurrency(couponRate)+'';											
														
												}else{
														subtotal=subtotal-(subtotal*memDiscount/100); //[member only]
														parent.document.getElementById("yourdiscountRate").innerHTML = parent.document.getElementById('Less_txt').value + ' '+ memDiscount+'%';
														
												}
												
												if(subtotal<0){ //20111102
													subtotal=0;
												}
										
									
								}else{ //not meet min spending
										if(memDiscount>0){ //disable coupon , show mem only						
											subtotal=subtotal-(subtotal*memDiscount/100); //[member only]
											parent.document.getElementById("yourdiscountRate").innerHTML = parent.document.getElementById('Less_txt').value + ' '+ memDiscount+'%';
										}
								}
										
										
						}else if(memDiscount>0){ //no coupon , mem only
								subtotal=subtotal-(subtotal*memDiscount/100); //[member only]
								parent.document.getElementById("yourdiscountRate").innerHTML = parent.document.getElementById('Less_txt').value + ' '+ memDiscount+'%';
						}
						
				}		
					
			
					if(subtotal!=bf_subtotalvalue){
						parent.document.getElementById("bf_Subtotal_Currency").innerHTML = selectedCurrCode;
						parent.document.getElementById("bf_Subtotal").innerHTML = formatCurrency(bf_subtotalvalue);					
						parent.document.getElementById("yourdiscountSPAN").style.display = 'block';
					}else{						
						parent.document.getElementById("yourdiscountSPAN").style.display = 'none';
					}

					
							
					parent.document.getElementById("Subtotal").innerHTML = formatCurrency(subtotal);
			//***********************
			
			
			var courierProvided=0;
			if(isObj(parent.document.dropmsgform.CourierNo)){
				if(parent.document.dropmsgform.CourierNo.value!=""){
					courierProvided=1;
				}
			}
			if(shippingAmount=='0.00'||shippingAmount=='0'){
				parent.document.getElementById("shippingAoumnt_Span").style.display='none';
			}else{	
				parent.document.getElementById("shippingAoumnt_Span").style.display='block';
				if(courierProvided==0){
					if(GrossWgtAmount=='0.00'||GrossWgtAmount=='0'){
						parent.document.getElementById("shippingAoumnt").innerHTML = formatCurrency(shippingAmount);
					}else{
						parent.document.getElementById("shippingAoumnt").innerHTML = formatCurrency(shippingAmount) +'('+ GrossWgtAmount +'kg)';
					}
					if(DiscountNSurchargeINC!=""){
						parent.document.getElementById("shippingAoumnt").innerHTML += '<br><font color="#999999">{' + DiscountNSurchargeINC + '}</font>';
					}
				}else{
						if(GrossWgtAmount=='0.00'||GrossWgtAmount=='0'){
							parent.document.getElementById("shippingAoumnt").innerHTML = '<s>' + formatCurrency(shippingAmount) + '</s>';
						}else{
							parent.document.getElementById("shippingAoumnt").innerHTML = '<s>' + formatCurrency(shippingAmount) + '</s>('+ GrossWgtAmount +'kg)';
						}
				}
			}	
			if(isObj(parent.document.getElementById("SalesTax"))){
				if(taxCost=='0.00'){
					parent.document.getElementById("SalesTax_Span").style.display='none';
				}else{	
					parent.document.getElementById("SalesTax_Span").style.display='block';
					parent.document.getElementById("SalesTax").innerHTML = formatCurrency(taxCost);
				}
			}
			if(isObj(parent.document.getElementById("InsuranceCost"))){
				if(InsuranceCost=='0.00'){
					parent.document.getElementById("Insurance_Span").style.display='none';
				}else{	
					parent.document.getElementById("Insurance_Span").style.display='block';
					parent.document.getElementById("InsuranceCost").innerHTML = formatCurrency(InsuranceCost);
				}				
			}

			var freeShippingApplied=0;
			uptoPriceFreeShipping=Math.abs(uptoPriceFreeShipping)*selectedCurrRate;
			if(subtotal>=uptoPriceFreeShipping&&uptoPriceFreeShipping!=0){ //free applied
				freeShippingApplied=1;
				if(isObj(parent.document.getElementById("shippingAoumnt"))){
					parent.document.getElementById("shippingAoumnt").innerHTML = '<s>' + formatCurrency(shippingAmount) + '</s>';	
				}
			}

			if(courierProvided!=0||freeShippingApplied!=0){
				orderTotal = Math.abs(subtotal) + Math.abs(taxCost) + Math.abs(InsuranceCost);
			}else{
				orderTotal = Math.abs(subtotal) + Math.abs(shippingAmount) + Math.abs(taxCost) + Math.abs(InsuranceCost);
			}
			
			//detailPdtSources.asp	
			if(couponMode!=''&&coupon_Deduction==1){ //use coupon ; deduct OrderTotal ; disbaled member discunt if deduct orderTotal
				parent.document.getElementById("yourdiscountSPAN").style.display = 'none';
				if(orderTotal!=0&&orderTotal>=Math.abs(couponMinimumSpending)){ //meet min spending$
						//Entry coupon module
						if(couponMode=='1'){ //[only coupon] && [-$$$]
							couponRate=Math.abs(couponRate)*selectedCurrRate;
							formatCurrency(couponRate);
							orderTotal=orderTotal-Math.abs(couponRate);									
							parent.document.getElementById("yourdiscountRate").innerHTML = parent.document.getElementById('Less_txt').value + ' '+ selectedCurrCode + formatCurrency(couponRate)+'';
						}else{ //if(couponMode=='0'){  //[only coupon] && [-%%%]
							var percentDiscount=Math.abs(couponRate);
							orderTotal=orderTotal-(orderTotal*percentDiscount/100); //[member only]
							parent.document.getElementById("yourdiscountRate").innerHTML = parent.document.getElementById('Less_txt').value + ' '+ percentDiscount+'%';
						}
						
						parent.document.getElementById("bf_Subtotal").innerHTML = formatCurrency(subtotal);
						parent.document.getElementById("yourdiscountSPAN").style.display = 'block';
						
						if(orderTotal<0){ //20111102
							orderTotal=0;
						}	
				}
			}
			
			if(selectedCurrCode=="JPY"){orderTotal=Math.round(orderTotal);};
			parent.document.getElementById("orderTotal").innerHTML = formatCurrency(orderTotal);			

			parent.document.getElementById("Subtotal_Currency").innerHTML=selectedCurrCode; //update Currency code label
			if(isObj(parent.document.getElementById("shippingAoumnt_Currency"))){
				parent.document.getElementById("shippingAoumnt_Currency").innerHTML=selectedCurrCode; //update Currency code label
			}
			if(isObj(parent.document.getElementById("SalesTax_Currency"))){
				parent.document.getElementById("SalesTax_Currency").innerHTML=selectedCurrCode; //update Currency code label
				parent.document.getElementById("SalesTaxRate").innerHTML = '('+taxRate+'%)';
			}
			if(isObj(parent.document.getElementById("Insurance_Currency"))){
				parent.document.getElementById("Insurance_Currency").innerHTML=selectedCurrCode; //update Currency code label
				if(InsuranceRate==0&&InsuranceCost!=0){ //reconigze flat insurance rate
					//alert('flat')
				}else if(InsuranceRate>0){
					parent.document.getElementById("InsuranceRate").innerHTML = '('+InsuranceRate+'%)';
				}	
			}
			
			parent.document.getElementById("orderTotal_Currency").innerHTML=selectedCurrCode; //update Currency code label
	}	

		if(parent.OSBuyNowRecords){ //OSBuyNowRecords.asp
				
				var doc=parent.OSBuyNowRecords.document;
				
				//*********** Dynamic Form Calculating ***********	START			
				//update ComboBoxAddPrice_Curr_i and ComboBoxAddPrice_Price_i
				for(i=0;doc.getElementById("ComboBoxAddPrice_Curr_"+i);i++){
					ComboBoxAddPrice_PriceDefault = doc.dropmsgform["ComboBoxAddPrice_PriceDefault_"+i].value;		
					doc.getElementById("ComboBoxAddPrice_Curr_"+i).innerHTML = selectedCurrCode;
					doc.getElementById("ComboBoxAddPrice_Price_"+i).innerHTML = formatCurrency(ComboBoxAddPrice_PriceDefault*selectedCurrRate);
				}
				
				//update RadioBt_addPrice_Curr_i and RadioBt_addPrice_Price_i
				for(i=0;doc.getElementById("RadioBt_addPrice_Curr_"+i);i++){
					RadioBt_addPrice_PriceDefault = doc.dropmsgform["RadioBt_addPrice_PriceDefault_"+i].value;
					doc.getElementById("RadioBt_addPrice_Curr_"+i).innerHTML = selectedCurrCode;
					doc.getElementById("RadioBt_addPrice_Price_"+i).innerHTML = formatCurrency(RadioBt_addPrice_PriceDefault*selectedCurrRate);
				}
				
					
				
				//Calculate RadioBtAddPrice_*		
				TotalRadioBtAddPrice=0;
				if(doc.getElementById("RadioBtAddPrice_0")){		
							for(i=0;doc.getElementById("RadioBtAddPrice_"+i);i++){
									for(j=0;j<doc.dropmsgform["RadioBtAddPrice_"+i].length;j++){
										if(doc.dropmsgform["RadioBtAddPrice_"+i][j].checked){
											//sum of all selected RadioBtAddPrice_i value
											This_RadioBtAddPrice = formatCurrency(Math.abs(doc.dropmsgform["RadioBtAddPrice_"+i][j].value)*Math.abs(selectedCurrRate));							
											This_RadioBtAddPrice = replaceComma(This_RadioBtAddPrice);	
											TotalRadioBtAddPrice = Math.abs(TotalRadioBtAddPrice) + Math.abs(This_RadioBtAddPrice);
										}
									}								
							}
					//doc.getElementById("ShoppingOption").innerHTML=formatCurrency(selectedCurrRate*TotalRadioBtAddPrice);	
				}
				//Calculate ComboBoxAddPrice_*					
				TotalComboBoxAddPrice=0;

				if(doc.getElementById("ComboBoxAddPrice_0")){		
							for(i=0;doc.getElementById("ComboBoxAddPrice_"+i);i++){
									for(j=0;j<doc.dropmsgform["ComboBoxAddPrice_"+i].length;j++){
										if(doc.dropmsgform["ComboBoxAddPrice_"+i][j].selected){
										
											//sum of all selected RadioBtAddPrice_i value
											//TotalComboBoxAddPrice = TotalComboBoxAddPrice + Math.abs(doc.dropmsgform["ComboBoxAddPrice_"+i][j].value);
											This_ComboBoxAddPrice = formatCurrency(Math.abs(doc.dropmsgform["ComboBoxAddPrice_"+i][j].value)*Math.abs(selectedCurrRate));
											This_ComboBoxAddPrice = replaceComma(This_ComboBoxAddPrice);	
											TotalComboBoxAddPrice = Math.abs(TotalComboBoxAddPrice) + Math.abs(This_ComboBoxAddPrice);
											
										}
									}								
							}					
				}
				ShoppingOptionTotal = TotalRadioBtAddPrice + TotalComboBoxAddPrice;
				
				//*********** Dynamic Form Calculating ***********	END	

			doc.getElementById("Subtotal_Currency").innerHTML=selectedCurrCode; //update Currency code label
			if(isObj(doc.getElementById("shippingAoumnt_Currency"))){
				doc.getElementById("shippingAoumnt_Currency").innerHTML=selectedCurrCode; //update Currency code label					
			}
			doc.getElementById("orderTotal_Currency").innerHTML=selectedCurrCode; //update Currency code label				
			
			if(isObj(doc.getElementById("SalesTax_Currency"))){
				doc.getElementById("SalesTax_Currency").innerHTML=selectedCurrCode; //update Currency code label
				doc.getElementById("SalesTaxRate").innerHTML = '('+taxRate+'%)';										
			}			
			if(isObj(doc.getElementById("Insurance_Currency"))){
				doc.getElementById("Insurance_Currency").innerHTML=selectedCurrCode; //update Currency code label
				if(InsuranceRate!=0)doc.getElementById("InsuranceRate").innerHTML = '('+InsuranceRate+'%)';				
			}
			
			
			
			
			if(isObj(doc.getElementById("countryid"))){
				if(selectedCountryName!=''){
					if(doc.getElementById("CountryORRegion"))
					doc.getElementById("CountryORRegion").value=selectedCountryName;
					if(doc.getElementById("CourierTD"))
					doc.getElementById("CourierTD").style.backgroundColor='';
					if(doc.getElementById("CountryORRegionSpan"))
					doc.getElementById("CountryORRegionSpan").innerHTML=selectedCountryName;
					for(i=0;isObj(doc.getElementById("CountryORRegionSpan_"+i+""));i++){
						doc.getElementById("CountryORRegionSpan_"+i).innerHTML=selectedCountryName;
					}	
				}else{
					if(doc.getElementById("CountryORRegion"))
					doc.getElementById("CountryORRegion").value='';
					if(doc.getElementById("CourierTD"))
					doc.getElementById("CourierTD").style.backgroundColor='red';
					
					if(doc.getElementById("CountryORRegionSpan"))
					doc.getElementById("CountryORRegionSpan").innerHTML='<a href="#country" style="color:red;"><b>'+doc.getElementById("CountryORRegionErrTxt").value+'</b></a>';
					for(i=0;isObj(doc.getElementById("CountryORRegionSpan_"+i+""));i++){
						doc.getElementById("CountryORRegionSpan_"+i).innerHTML='<a href="#country" style="color:red;"><b>'+doc.getElementById("CountryORRegionErrTxt").value+'</b></a>';
					}
				}
				
				doc.getElementById("PackageName").value=selectedPackageName;
			}	
	
				doc.getElementById("GrossWgtAmount").value=GrossWgtAmount;
			
			
			
			
			
//set SPAN display value START	

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
courierProvided=0;
if(isObj(doc.dropmsgform.CourierNo)){
	if(doc.dropmsgform.CourierNo.value!=""){
		courierProvided=1;
	}
}


	if(courierProvided==0){
				if(isObj(doc.getElementById("shippingAoumnt"))){
					doc.getElementById("shippingAoumnt").innerHTML = formatCurrency(shippingAmount);
				}
				if(DiscountNSurchargeINC!=""){
					doc.getElementById("shippingAoumnt").innerHTML += '<br><font color="#999999">{' + DiscountNSurchargeINC + '}</font>';
				}
				
				if(isObj(doc.getElementById("GrossWeightAmountAREA"))){
					if(GrossWgtAmount!=0){
						if(isObj(doc.getElementById("GrossWeightAmountSpan"))){
							doc.getElementById("GrossWeightAmountSpan").innerHTML = GrossWgtAmount +' kg';
						}
					}else{
						doc.getElementById("GrossWeightAmountAREA").style.display='none';
					}	
				}
				
				doc.dropmsgform.ShippingTotalField.value = formatCurrency(shippingAmount);	
	}else{ //else -> if(courierProvided==0){	
				if(isObj(doc.getElementById("shippingAoumnt"))){
					doc.getElementById("shippingAoumnt").innerHTML = '<s>' + formatCurrency(shippingAmount) + '</s>('+doc.dropmsgform.CourierNoProvided_txt.value+')';	
				}
				if(isObj(doc.getElementById("GrossWeightAmountAREA"))){
					if(GrossWgtAmount!=0){	
						if(isObj(doc.getElementById("GrossWeightAmountSpan"))){
							doc.getElementById("GrossWeightAmountSpan").innerHTML = GrossWgtAmount +' kg';
						}
					}else{
						doc.getElementById("GrossWeightAmountAREA").style.display='none';
					}	
				}
				doc.dropmsgform.ShippingTotalField.value = formatCurrency(shippingAmount); 			
				
	} //end -> if(courierProvided==0){			

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++			
			var memDiscount=0;
			var bf_subtotalvalue=subtotal; //store bf_Subtotal
			if(isObj(doc.dropmsgform.DiscountRate)){
				memDiscount=Math.abs(doc.dropmsgform.DiscountRate.value);
			}
			//alert(doc.getElementById('couponModeImg'))
				//set style for "coupon" field
				if(doc.dropmsgform.couponCodeField.value!=''&&couponCode==''){ //invalid set to red				
					doc.getElementById('couponModeImg').src='http://'+document.domain+'/i_icon/i_error.gif';
				}else if(doc.dropmsgform.couponCodeField.value!=''&&couponCode!=''){ //invalid set to green
					doc.getElementById('couponModeImg').src='http://'+document.domain+'/i_icon/i_okay.gif';
				}else if(doc.getElementById('couponCodeField')){
					doc.getElementById('couponModeImg').src='http://'+document.domain+'/images/spacer.gif';
				}
			
			
			doc.dropmsgform.couponModeField.value=couponMode;
			doc.dropmsgform.couponRateField.value=couponRate;
			doc.dropmsgform.couponOnlyField.value=couponOnly;
			
			//OSBuyNowRecords.asp
			var coupon_Deduction=0; //deduct sub-total [0] 
			if(isObj(doc.dropmsgform.coupon_Deduction)){
				coupon_Deduction=Math.abs(doc.dropmsgform.coupon_Deduction.value); //deduct orderTotal [1]
			}
			
			//OSBuyNowRecords.asp
			if(coupon_Deduction!=1){ //if == 1 >> deduct orderTotal [1] *** disable member discount
			
						if(couponMode!=''){ //use coupon
								
								if(subtotal!=0&&subtotal>=Math.abs(couponMinimumSpending)){ //meet min spending$
									
											if(couponOnly=='1'&&couponMode=='0'){  //[only coupon] && [-%%%]
												memDiscount=Math.abs(couponRate); 
											}else if(couponOnly=='0'&&couponMode=='0'){ //[member + coupon] && [-%%%]
												memDiscount=Math.abs(couponRate)+memDiscount; //(Member + coupon)[-%]
											}
											
											//Entry discount module
											if(couponOnly=='1'&&couponMode=='1'){ //[only coupon] && [-$$$]
												couponRate=Math.abs(couponRate)*selectedCurrRate;
												formatCurrency(couponRate);
													subtotal=subtotal-Math.abs(couponRate);									
													doc.getElementById("yourdiscountRate").innerHTML = doc.dropmsgform.Less_txt.value + ' '+ selectedCurrCode + formatCurrency(couponRate)+'';
													doc.getElementById("minimumSpendingSPAN").style.display='none'; 										
											}else if(couponOnly=='0'&&couponMode=='1'){ //[member + coupon] && [-$$$]
												couponRate=Math.abs(couponRate)*selectedCurrRate;
												formatCurrency(couponRate);
													subtotal=subtotal-(subtotal*memDiscount/100); //find member discount
													subtotal=subtotal-Math.abs(couponRate); //mix with coupon
													//reset
													doc.getElementById("yourdiscountRate").innerHTML='';
													if(memDiscount>0){
														doc.getElementById("yourdiscountRate").innerHTML += doc.dropmsgform.Less_txt.value + ' ' + memDiscount+'% ' + doc.dropmsgform.LessAgain_txt.value;
													}
													doc.getElementById("yourdiscountRate").innerHTML += ' ' + doc.dropmsgform.Less_txt.value + ' ' +selectedCurrCode + formatCurrency(couponRate)+'';											
													doc.getElementById("minimumSpendingSPAN").style.display='none';			
											}else{
													subtotal=subtotal-(subtotal*memDiscount/100); //[member only]
													doc.getElementById("yourdiscountRate").innerHTML = doc.dropmsgform.Less_txt.value + ' '+ memDiscount+'%';
													doc.getElementById("minimumSpendingSPAN").style.display='none';
											}
											
											if(subtotal<0){ //20111102
												subtotal=0;
											}
									
								}else{ //not meet min spending
									if(memDiscount>0){ //disable coupon , show mem only						
										subtotal=subtotal-(subtotal*memDiscount/100); //[member only]
										doc.getElementById("yourdiscountRate").innerHTML = doc.dropmsgform.Less_txt.value + ' '+ memDiscount+'%';
									}
									doc.getElementById("minimumSpendingSPAN").style.display='block';
									doc.getElementById("minimumSpendingSPANPrice").innerHTML=selectedCurrCode + formatCurrency(couponMinimumSpending);
								}
						
						}else if(memDiscount>0){ //no coupon , mem only
								subtotal=subtotal-(subtotal*memDiscount/100); //[member only]
								doc.getElementById("yourdiscountRate").innerHTML = doc.dropmsgform.Less_txt.value + ' '+ memDiscount+'%';
								doc.getElementById("minimumSpendingSPAN").style.display='none';
						}
						
						
			}
			
			
					if(subtotal!=bf_subtotalvalue){						
						doc.getElementById("yourdiscountSPAN").style.display = 'block';
					}else{
						bf_subtotalvalue=0; //reset to 0
						doc.getElementById("yourdiscountSPAN").style.display = 'none';
					}
					
					doc.getElementById("bf_Subtotal_Currency").innerHTML = selectedCurrCode;
					doc.getElementById("bf_Subtotal").innerHTML = formatCurrency(bf_subtotalvalue);
					doc.getElementById("bf_SubtotalField").value = formatCurrency(bf_subtotalvalue);	
					
					doc.getElementById("Subtotal").innerHTML = formatCurrency(subtotal);
					doc.dropmsgform.SubTotalField.value = formatCurrency(subtotal);
					
					if(subtotal<=0&&doc.getElementById("fsubmit"))doc.getElementById("fsubmit").disabled=true;
			
			if(isObj(doc.getElementById("SalesTax"))){
				doc.getElementById("SalesTax").innerHTML = formatCurrency(taxCost);
			}
			if(isObj(doc.getElementById("InsuranceCost"))){
				doc.getElementById("InsuranceCost").innerHTML = formatCurrency(InsuranceCost);
			}
			doc.dropmsgform.SalesTaxField.value = formatCurrency(taxCost);	
			doc.dropmsgform.InsuranceCostField.value = formatCurrency(InsuranceCost);
			doc.getElementById("ShoppingOption").innerHTML=formatCurrency(ShoppingOptionTotal);
			doc.dropmsgform.ShoppingOptionTotalField.value = formatCurrency(ShoppingOptionTotal);
			
			var freeShippingApplied=0;
			uptoPriceFreeShipping=Math.abs(uptoPriceFreeShipping)*selectedCurrRate;			
			if(subtotal>=uptoPriceFreeShipping&&uptoPriceFreeShipping!=0){ //free applied
				freeShippingApplied=1;
				if(isObj(doc.getElementById("shippingAoumnt"))){
					doc.getElementById("shippingAoumnt").innerHTML = '<s>' + formatCurrency(shippingAmount) + '</s>';	
				}
				if(isObj(doc.dropmsgform.FreeShippingFlag)){
					doc.dropmsgform.FreeShippingFlag.value=1;
				}
			}else{
				if(isObj(doc.dropmsgform.FreeShippingFlag)){
					doc.dropmsgform.FreeShippingFlag.value=0;
				}
			}

			if(courierProvided!=0||freeShippingApplied!=0){
				orderTotal = Math.abs(subtotal) + Math.abs(taxCost) + Math.abs(ShoppingOptionTotal) + Math.abs(InsuranceCost);
			}else{
				orderTotal = Math.abs(subtotal) + Math.abs(shippingAmount) + Math.abs(taxCost) + Math.abs(ShoppingOptionTotal) + Math.abs(InsuranceCost);				
			}
			
			//OSBuyNowRecords.asp
			if(coupon_Deduction==1){ //if == 1 >> deduct orderTotal [1] *** disable member discount		 	
				if(couponMode!=''){ //use coupon
					doc.getElementById("yourdiscountSPAN").style.display = 'none';
					if(orderTotal!=0&&orderTotal>=Math.abs(couponMinimumSpending)){ //meet min spending$
						if(couponMode=='1'){ //[only coupon] && [-$$$]
							couponRate=Math.abs(couponRate)*selectedCurrRate;
							formatCurrency(couponRate);
							orderTotal=orderTotal-Math.abs(couponRate);									
							doc.getElementById("yourdiscountRate").innerHTML = doc.dropmsgform.Less_txt.value + ' '+ selectedCurrCode + formatCurrency(couponRate)+'';
							doc.getElementById("minimumSpendingSPAN").style.display='none'; 										
						}else{ //-%%%
							var percentDiscount=Math.abs(couponRate);
							orderTotal=orderTotal-(orderTotal*percentDiscount/100);
							doc.getElementById("yourdiscountRate").innerHTML = doc.dropmsgform.Less_txt.value + ' '+ percentDiscount+'%';
							doc.getElementById("minimumSpendingSPAN").style.display='none';
						}
						doc.getElementById("bf_Subtotal").innerHTML = formatCurrency(subtotal);
						doc.getElementById("yourdiscountSPAN").style.display = 'block';
						
						if(orderTotal<0){ //20111102
							orderTotal=0;
						}
						
					}
				}
			}
			
			
			
			maxCardPurchaseAmount=Math.abs(maxCardPurchaseAmount);
			
		
		function findPayMethodId(PayCo){
			for(i=1;isObj(doc.dropmsgform["PayMethodCode"+(i)]);i++){ 
				if(doc.dropmsgform["PayMethodCode"+(i)].value==PayCo){ //find the paypal PayMethod[?]
					 thePayPalPayMethodId = i-1;
					 return thePayPalPayMethodId;
				}
			}
		}
		
		if(isObj(doc.dropmsgform.PayMethod)){ //if check out method available

			//*********PayPal -> USD,GBP ... ********* 
				// if $ > credit card allow || not accepted currency
				if((orderTotal/Math.abs(selectedCurrRate)>maxCardPurchaseAmount)||(selectedCurrCode!="AUD"&&selectedCurrCode!="CAD"&&selectedCurrCode!="CHF"&&selectedCurrCode!="CZK"&&selectedCurrCode!="DKK"&&selectedCurrCode!="EUR"&&selectedCurrCode!="GBP"&&selectedCurrCode!="HKD"&&selectedCurrCode!="HUF"&&selectedCurrCode!="JPY"&&selectedCurrCode!="NOK"&&selectedCurrCode!="NZD"&&selectedCurrCode!="PLN"&&selectedCurrCode!="SEK"&&selectedCurrCode!="SGD"&&selectedCurrCode!="USD")){
					//case: NOT PayPay acceptable currency -> disable PayPal checkout
					thePayPalPayMethodId = findPayMethodId('PayPal');					
					if(!isNaN(thePayPalPayMethodId)){
						doc.dropmsgform.PayMethod[thePayPalPayMethodId].disabled = true; //disable PayPal				
					}
				}else if(selectedCurrCode=="AUD"||selectedCurrCode=="CAD"||selectedCurrCode=="CHF"||selectedCurrCode=="CZK"||selectedCurrCode=="DKK"||selectedCurrCode=="EUR"||selectedCurrCode=="GBP"||selectedCurrCode=="HKD"||selectedCurrCode=="HUF"||selectedCurrCode=="JPY"||selectedCurrCode=="NOK"||selectedCurrCode=="NZD"||selectedCurrCode=="PLN"||selectedCurrCode=="SEK"||selectedCurrCode=="SGD"||selectedCurrCode=="USD"){
					//case: PayPal acceptable currency -> allow accept PayPal again
					thePayPalPayMethodId = findPayMethodId('PayPal');
					if(!isNaN(thePayPalPayMethodId)){				
						doc.dropmsgform.PayMethod[thePayPalPayMethodId].disabled = false;
					}
				}
			
			//*********PayDollar -> (rsServerName_CurrentID) ONLY DEFAULT HKD,USD,SGD,RMB,JPY,TWD,AUD,EUR,GBP,CAD ********* 
				// if $ > credit card allow || not accepted currency

				if((orderTotal/Math.abs(selectedCurrRate)>maxCardPurchaseAmount)||(selectedCurrCode!=rsServerName_CurrentID)){
					//case: NOT PayPay acceptable currency -> disable PayDollar checkout
					thePayPalPayMethodId = findPayMethodId('PayDollar');					
					if(!isNaN(thePayPalPayMethodId)){		
						doc.dropmsgform.PayMethod[thePayPalPayMethodId].disabled = true; //disable PayDollar				
					}
				}else if(selectedCurrCode==rsServerName_CurrentID){ //only allow default
					//case: PayDollar acceptable currency -> allow accept PayDollar again
					thePayPalPayMethodId = findPayMethodId('PayDollar');
					if(!isNaN(thePayPalPayMethodId)){				
						doc.dropmsgform.PayMethod[thePayPalPayMethodId].disabled = false;
					}
				}
				
			//*********Alipay -> RMB********* 
				// if $ > credit card allow || not accepted currency
				if((orderTotal/Math.abs(selectedCurrRate)>maxCardPurchaseAmount)||(selectedCurrCode!="RMB")){
					//case: NOT Alipay acceptable currency -> disable Alipay checkout
					thePayPalPayMethodId = findPayMethodId('Alipay');
					if(!isNaN(thePayPalPayMethodId)){		
						doc.dropmsgform.PayMethod[thePayPalPayMethodId].disabled = true; //disable Alipay
					}					
				}else if(selectedCurrCode=="RMB"){
					//case: Alipay acceptable currency -> allow accept Alipay again
					thePayPalPayMethodId = findPayMethodId('Alipay');	
					if(!isNaN(thePayPalPayMethodId)){				
						doc.dropmsgform.PayMethod[thePayPalPayMethodId].disabled = false;
					}
				}
				

				//*********check which one?*********
				var exit=0;
				for(i=1;((exit==0)&&(isObj(doc.dropmsgform["PayMethodCode"+(i)])));i++){ 
					thisPayMethodId = i-1;	
					//find item : *** checked && disabled ***
					if(doc.dropmsgform.PayMethod[thisPayMethodId].disabled==true&&doc.dropmsgform.PayMethod[thisPayMethodId].checked==true){
						doc.dropmsgform.PayMethod[thisPayMethodId].checked = false; //uncheck itself
						
						//find which one to be checked
						for(j=0;((exit==0)&&(isObj(doc.dropmsgform.PayMethod[j])));j++){ 
							if(!doc.dropmsgform.PayMethod[j].disabled){
								doc.dropmsgform.PayMethod[j].checked = true;
								exit=1;
							}
						}
					}				
				}
				
		}
		
		
		if(isObj(doc.dropmsgform.PayMethod)){ //if check out method available
				//Disable checkout: if the last PayMethod checked
				if(doc.dropmsgform.PayMethod[doc.dropmsgform.PayMethod.length-1].checked){
					doc.dropmsgform.PayMethod[doc.dropmsgform.PayMethod.length-2].checked=true; //never check the last
					if(doc.dropmsgform.fsubmit)doc.dropmsgform.fsubmit.disabled=true;
				}else{
					if(doc.dropmsgform.fsubmit)doc.dropmsgform.fsubmit.disabled=false;
				}
		}		
				
				if(selectedCurrCode=="JPY"){orderTotal=Math.round(orderTotal);};
				doc.getElementById("orderTotal").innerHTML = formatCurrency(orderTotal);				
				doc.dropmsgform.OrderTotalField.value = formatCurrency(orderTotal);	
				
				
		
//set SPAN display value END						


					//for(i=0;doc.getElementById("MenuShip_Currency_"+i);i++){			
							//doc.getElementById("MenuShip_Currency_"+i).innerHTML=selectedCurrCode; //update Currency code label							
							//updateMenuShip_Charge = Math.abs(doc.dropmsgform["MenuShip_DefaultCharge_"+i].value)*Math.abs(selectedCurrRate); //re cal shipping chare 
							//doc.getElementById("MenuShip_Charge"+i).innerHTML=formatCurrency(updateMenuShip_Charge); //write shipping charge
					//}
					
					if(doc.getElementById("col_PriceCurr")){
						doc.getElementById("col_PriceCurr").innerHTML=selectedCurrCode;
					}
					if(doc.getElementById("col_SubtotalCurr")){
						doc.getElementById("col_SubtotalCurr").innerHTML=selectedCurrCode;
					}
					if(doc.getElementById("ShoppingOption_Currency")){
						doc.getElementById("ShoppingOption_Currency").innerHTML=selectedCurrCode;
					}
					
					if(isObj(doc.getElementById("SalesTax_span"))){
						if(taxCost=='0.00'){					
						doc.getElementById("SalesTax_span").style.display='none';
						}else{
						doc.getElementById("SalesTax_span").style.display='block';
						}
					}
					if(isObj(doc.getElementById("Insurance_span"))){
						if(InsuranceCost=='0.00'){					
						doc.getElementById("Insurance_span").style.display='none';
						}else{
						doc.getElementById("Insurance_span").style.display='block';
						}
					}
					
					if(isObj(doc.getElementById("ShoppingOption_span"))){
						if(ShoppingOptionTotal=='0.00'){					
						doc.getElementById("ShoppingOption_span").style.display='none';
						}else{
						doc.getElementById("ShoppingOption_span").style.display='block';
						}
					}
					if(isObj(doc.getElementById("shippingAoumnt_span"))){
						if(shippingAmount=='0.00'){					
						doc.getElementById("shippingAoumnt_span").style.display='none';
						}else{
						doc.getElementById("shippingAoumnt_span").style.display='block';
						}
					}
					
					//onload
					if(doc.getElementById("qty_0")){ //update all row x qty = subtotal @ OSBuyNowecords.asp					
						for(i=0;doc.getElementById("qty_"+i);i++){
									
									//find discount
									if(isObj(doc.getElementById("YourDiscount"+(i)))){
							 				YourDiscount=Math.abs(doc.getElementById("YourDiscount"+(i)).value);
											//alert(YourDiscount);
									}
									//***Find ComboAmount
									thiscomboPriceStr = doc.dropmsgform["save_comboPriceStr"+i].value;
									var each_comboPriceStr=thiscomboPriceStr.split(",");
									var comboAmount = 0;
									for(j=1;!isNaN(each_comboPriceStr[j]);j++){
										thiscomboAmount = Math.abs(each_comboPriceStr[j]);
										//x discount
										thiscomboAmount = formatCurrency(thiscomboAmount-(thiscomboAmount*YourDiscount/100));
										thiscomboAmount = Math.abs(replaceComma(thiscomboAmount));	
										//x currency
										thiscomboAmount = formatCurrency(thiscomboAmount*selectedCurrRate);
										thiscomboAmount = Math.abs(replaceComma(thiscomboAmount));
										
										comboAmount = comboAmount + thiscomboAmount;
									}
							
							//find rowtotal item price							
							rowPriceDefault = Math.abs(doc.dropmsgform["rowPriceDefault"+i].value);
							//keep the row price before add combo
							rowOrgPriceDefault = formatCurrency(rowPriceDefault*selectedCurrRate);
							//x discount
							rowPriceDefault=formatCurrency(rowPriceDefault-(rowPriceDefault*YourDiscount/100));
							rowPriceDefault = Math.abs(replaceComma(rowPriceDefault));
							//x currency
							rowPriceDefault = formatCurrency(rowPriceDefault*selectedCurrRate);
							rowPriceDefault = Math.abs(replaceComma(rowPriceDefault));					
							
							thisTotal = rowPriceDefault + comboAmount;
							//origial price 
							if(thisTotal!=rowPriceDefault){
								if(rowOrgPriceDefault!=rowPriceDefault){ //combo discount counted
									doc.getElementById("rowOrgPrice"+i).innerHTML = '<font color=#cc0000>{'+ selectedCurrCode + ' <s>' + rowOrgPriceDefault + '</s> ' + formatCurrency(rowPriceDefault) + '}</font>';								
								}else{
									doc.getElementById("rowOrgPrice"+i).innerHTML = '<font color=#cc0000>{'+ selectedCurrCode + ' ' + formatCurrency(rowPriceDefault) + '}</font>';								
								}	
							}
							//set price
							thisTotal=formatCurrency(thisTotal);							
							doc.getElementById("rowPrice"+i).innerHTML = thisTotal;	
							doc.getElementById("thisRowPrice"+i).value = thisTotal;					
							thisTotal = replaceComma(thisTotal);
							thisTotal=Math.abs(thisTotal);
							//set total price
							thisQty=Math.abs(doc.getElementById("qty_"+i).value);
							doc.getElementById("rowSubTotal"+i).innerHTML = formatCurrency(thisTotal*thisQty);
						
						}
					}
					
					
					

		}	
	

	
	if(resetShipAndCurrAtDetail=="1"){

		//When load page
		//when currency changed reset shipping menu price
		//shipping drop down menu name on selected
					if (parent.document.getElementById("ShippingMenuName")){ //detailPdtSources.asp
						for(i=0;parent.document.getElementById("MenuShip_Currency_"+i);i++){
							parent.document.getElementById("MenuShip_Currency_"+i).innerHTML=selectedCurrCode; //update Currency code label
							updateMenuShip_Charge = Math.abs(parent.document.dropmsgform["MenuShip_DefaultCharge_"+i].value)*Math.abs(selectedCurrRate); //re cal shipping chare 
							parent.document.getElementById("MenuShip_Charge"+i).innerHTML=formatCurrency(updateMenuShip_Charge); //write shipping charge
						}			
					}
					//update ListPrice //detailpdtsources.asp
					if (parent.document.getElementById("ListPrice_Currency")){
						parent.document.getElementById("ListPrice_Currency").innerHTML=selectedCurrCode + ' '; //update Currency code label
					}
			
					//update OurPrice //detailpdtsources.asp
					if (parent.document.getElementById("OurPrice_Currency")){
						parent.document.getElementById("OurPrice_Currency").innerHTML=selectedCurrCode + ' '; //update Currency code label	
					}
					//update YourPrice //detailpdtsources.asp
					if (parent.document.getElementById("YourPrice_Currency")){
						parent.document.getElementById("YourPrice_Currency").innerHTML=selectedCurrCode; //update Currency code label
					}
					
					//update YouSave //detailpdtsources.asp
					if (parent.document.getElementById("YouSave_Currency")){
						parent.document.getElementById("YouSave_Currency").innerHTML=selectedCurrCode + ' '; //update Currency code label
					}
				
		}
		
		
					//onload --> update combo --> start ******* Convert Combo CURRENCY & Symbol
						if(isObj(parent.OSBuyNowRecords)){ //client OSBuyNowRecords.asp
							doc=parent.OSBuyNowRecords.document;
						}
						else if(isObj(parent.document.getElementById("iframeOnlinebasket"))){ //client side detailpdtsources.asp						
							doc=parent.document;
						}
						else if(isObj(document.getElementById("iframeOnlinebasket"))){ //adm detailpdtsources.asp ### no Netscape allowed
							doc=document;
						}	
						
						if(isObj(doc.getElementById("PdtCombo_Price_0"))){
							
							//this loop reset the COMBOX CurrencyCode and Exchange Price
							for(i=0;isObj(doc.getElementById("PdtCombo_Price_"+i));i++){
									//Upd combo currency USD
									doc.getElementById("PdtCombo_Currency_"+i).innerHTML=selectedCurrCode;										
									PdtCombo_PriceDefault_value = Math.abs(doc.getElementById("PdtCombo_PriceDefault_"+i).value);
																						
											//find this row discount index to get YourDiscount rate 
											thisDiscountIndex="0";
											if(isObj(doc.getElementById("PdtCombo_DiscountIndex_"+i))){			
												thisDiscountIndex = doc.getElementById("PdtCombo_DiscountIndex_"+i).value;
											}
											
											if(isObj(doc.getElementById("YourDiscount"+(thisDiscountIndex)))){									
												YourDiscount=Math.abs(doc.getElementById("YourDiscount"+(thisDiscountIndex)).value);
												
												var s_str="";
												if(YourDiscount>0){
													// Keep Combo price in price x curr, before discount
													Price_beforeDiscount = PdtCombo_PriceDefault_value;
													Price_beforeDiscount = Math.abs(Price_beforeDiscount)*selectedCurrRate;	
													s_str="<s><font color=#cc0000>"+formatCurrency(Price_beforeDiscount)+"</font></s> ";
												}
												// Cal combo price x discount
												
												PdtCombo_PriceDefault_value=PdtCombo_PriceDefault_value-(PdtCombo_PriceDefault_value*YourDiscount/100);
												PdtCombo_PriceDefault_value=formatCurrency(PdtCombo_PriceDefault_value);
												PdtCombo_PriceDefault_value = replaceComma(PdtCombo_PriceDefault_value);	
												// Cal combo price x currency
												PdtCombo_PriceDefault_value = Math.abs(PdtCombo_PriceDefault_value)*selectedCurrRate;		
												// write <s>Before Discount Price</s> to combo price
												doc.getElementById("PdtCombo_Price_"+i).innerHTML=s_str + formatCurrency(PdtCombo_PriceDefault_value);			
												
											}else{
												// Cal combo price x currency
												PdtCombo_PriceDefault_value = Math.abs(PdtCombo_PriceDefault_value)*selectedCurrRate;		
												doc.getElementById("PdtCombo_Price_"+i).innerHTML=formatCurrency(PdtCombo_PriceDefault_value);						
											}
											
							}								
						}		
					//update combo END ******* CURRENCY	
		
	
			if (parent.document.getElementById("OurPrice_Currency")){ // only do at detailpdtsources.asp
				reCalculateTotal();
			}
			
			if(parent.document.getElementById("btmOrderTotal")){
				if (parent.document.getElementById("YourPrice")){
					parent.document.getElementById("btmItemTotal").innerHTML="Your Price: " + selectedCurrCode + " " + parent.document.getElementById("YourPrice").innerHTML + " - ";
				}else if(parent.document.getElementById("OurPrice")){
					parent.document.getElementById("btmItemTotal").innerHTML="Our Price: " +  selectedCurrCode + " " + parent.document.getElementById("OurPrice").innerHTML + " - ";
				}
				if (parent.document.getElementById("orderTotal")){
					parent.document.getElementById("btmOrderTotal").innerHTML="Order Total: " + selectedCurrCode + " " + parent.document.getElementById("orderTotal").innerHTML;
				}	
			}
			
		
				if(showmybasket==1){
					parent.document.getElementById("mybasket").style.display="block";
				}else if(navigator.appName=='Microsoft Internet Explorer'){
					parent.document.getElementById("mybasket").style.display="none";
				}
			
			
			
			
}

function replaceSTR(str,from,to){
	for(com_i=0; com_i <= str.length-1; com_i++){
	
		com_pos = str.indexOf(from,com_i);
		
			if (com_pos>=0) {
				str = str.replace(from,to);
			}
	}
	return str;
}

function replaceComma(str){
	for(com_i=0; com_i <= str.length-1; com_i++){ //replace ','
		com_pos = str.indexOf(",",com_i);
			if (com_pos>0) {
				str = str.replace(",","");
			}
	}
	return str;
}


//OSRfqRecords.asp START


function validate(field,require){
var errMsg="The following error(s) occurred:\n";

	//validate fields
	//field = "Qty,Unit,Payment Terms,Message for this item,Msg";
	//require = "rNum,rTxt,rTxt,rTxt,rTxt";
	eachField=field.split(",");
	eachRequire=require.split(",");
	for(i=0;i<=eachField.length-1;i++){
		//alert(eachField[i]);
			found=0;
			for (j=0;isObj(document.getElementById(eachField[i] + "_" + j));j++){
				//alert(eachRequire[i]);
				//alert(document.form1[eachField[i] + "_" + j]);
				id=eachField[i] + "_" + j;
				thisvalue=document.getElementById(eachField[i] + "_" + j).value;
				if (thisvalue==""&&eachRequire[i]=="rTxt"){
					if(found==0){errMsg += "-" + eachField[i] + " is required.\n";}						
					found=1;setTxtFieldsErr(id);									
				}else if(eachRequire[i]=="rNum"){
					if(isNaN(thisvalue)||thisvalue==""){
						if(found==0){errMsg += "-" + eachField[i] + " is required a number value.\n";}				
						found=1;setTxtFieldsErr(id);	
					}else if(Number(thisvalue)<1||Number(thisvalue)>1000000000){
						if(found==0){errMsg += "-" + eachField[i] + " is required a number value between 1 and 1000000000.\n";}
						found=1;setTxtFieldsErr(id);	
					}else{
						setTxtFields(id);
					}
				}else{
					setTxtFields(id);
				}				

			}
		
		
	}
	
	//return false;
	
	if(errMsg!="The following error(s) occurred:\n"){
		errMsg+="*Please correct field(s) color in red.\n"
		alert(errMsg);
		return false;
	}	
	
}

function setTxtFields(id){
	document.getElementById(id).className="TxtFields";
}
function setTxtFieldsErr(id){
	document.getElementById(id).className="TxtFieldsErr";
}
function onloadaction_OSRfqRecords(){
	if(Math.abs(this.document.body.scrollHeight)<800){
		parent.document.getElementById("iframeRfqRecord").style.height="800px";
	}else{
		parent.document.getElementById("iframeRfqRecord").style.height=this.document.body.scrollHeight+"px";
	}	
}
//OSRfqRecords.asp END

