function ShowWindersList(Brand,SearchKey)
{
	xmlHttp=GetXmlHttpObject()

	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	
		
	var url="winderslist.php"
	params="Brand="+Brand+"&SearchKey="+SearchKey
	
	xmlHttp.onreadystatechange=function () 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 	{ 
	 		document.getElementById("WindersList").innerHTML=xmlHttp.responseText;
	 	}
	}
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params)
}

function UploadFileShow(Control,Title)
{
	document.getElementById('file1').value = "";
	document.getElementById('FileName').style.display = "none";
	document.getElementById(Control).style.display = "";
	document.getElementById(Title).style.display = "none";
}
function FileUpload(Control, FileName)
{
	document.getElementById(Control).style.display = "None";
	document.getElementById('FileName').style.display = "";
	document.getElementById("FileNameTD").innerHTML="<img src='images/file-loader.gif' align='center'>";
	setTimeout("showFileName('"+FileName+"')", 1000);
}
function showFileName(FileName)
{
	document.getElementById("FileNameTD").innerHTML="File Uploaded : " +FileName+ " <a href='javascript:;' class='links1' onclick=\"UploadFileShow('uploadFile','uploadFileTitle')\">Delete File</a>";
}

function ShowWinderDetail(SaleWatchID)
{
	//alert(SaleWatchID);
	xmlHttp=GetXmlHttpObject()

	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	document.getElementById("WinderDetails").innerHTML="<img src='images/loader.gif' align='center'>";
		
	var url="winder-detail.php"
	params="SaleWatchID="+SaleWatchID
	
	xmlHttp.onreadystatechange=function () 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 	{ 
	 		document.getElementById("WinderDetails").innerHTML=xmlHttp.responseText;
	 	}
	}
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params)
}

function formatCurrency(strValue)
{
	strValue = strValue.toString().replace(/\$|\,/g,'');
	dblValue = parseFloat(strValue);

	blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
	dblValue = Math.floor(dblValue*100+0.50000000001);
	intCents = dblValue%100;
	strCents = intCents.toString();
	dblValue = Math.floor(dblValue/100).toString();
	if(intCents<10)
		strCents = "0" + strCents;
	for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
		dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+','+
		dblValue.substring(dblValue.length-(4*i+3));
	return (((blnSign)?'':'-') + '$' + dblValue + '.' + strCents);
}

function submitPromoCode(PromoCode)
{
	if(PromoCode=='')
	{
		alert("Please enter promotional code.");
		return false;
	}
	xmlHttp=GetXmlHttpObject()

	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	var url="promo-code-checkout.php"
	params="PromotionalCodeID="+PromoCode
	
	xmlHttp.onreadystatechange=function () 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 	{ 
	 		var rnum=xmlHttp.responseText;
	 		//alert(rnum);
	 		arr=rnum.split("~");
	 		
	 		var di=formatCurrency(arr[0]);
	 		//alert(di);
	 		shipTot=parseFloat(document.getElementById("shipping").value);
	 		taxTot=parseFloat(document.getElementById("tax").value);
	 		
	 		if(arr[1]=='class'){
	 			si=parseFloat(shipTot);
	 		}
	 		else{
	 			si=parseFloat(arr[1]);
	 		}
	 		
	 		if(arr[2]=='class'){
	 			ti=parseFloat(taxTot);
	 		}
	 		else{
	 			ti=parseFloat(arr[2]);
	 		}
	 		if(parseFloat(arr[3])==1){
	 			document.getElementById("paymentOption").style.display='none';
	 			document.getElementById("ccinfo").style.display='none';
	 			document.getElementById("MasterCoder").style.display='block';
	 			document.getElementById("masterImage").innerHTML='';
	 		}
	 		else{
	 			document.getElementById("paymentOption").style.display='block';
	 			document.getElementById("MasterCoder").style.display='none';
	 			document.getElementById("masterImage").innerHTML='<img src="images/payment-option.png" border="0">';
	 		}
	 		
	 		document.getElementById("shipDis").innerHTML=formatCurrency(si);
	 		document.getElementById("taxDis").innerHTML=formatCurrency(ti);
	 		//alert(rnum.toFixed(2));
	 		//document.getElementById("divPromoCode").innerHTML='<strong>$'+xmlHttp.responseText+'</strong>';
	 		//document.getElementById("fieldPromoCode").value=xmlHttp.responseText;
	 		//document.getElementById("googleamount").value=-xmlHttp.responseText;
			TotalAmount = parseFloat(document.getElementById("TotalAmount").value);
						
	 		tamt=parseFloat(TotalAmount)-parseFloat(arr[0])-parseFloat(shipTot)-parseFloat(taxTot)+parseFloat(si)+parseFloat(ti);
	 		document.getElementById("NetAmount").value=tamt.toFixed(2);
			document.getElementById("NetAmountTotal").innerHTML='<strong><font color="#fad493">'+formatCurrency(document.getElementById("NetAmount").value)+'</font></strong>';
			document.getElementById("amount").value=tamt.toFixed(2);
			document.getElementById("googleamount").value=tamt.toFixed(2);
			//document.getElementById("DiscountText").innerHTML='';
			document.getElementById("DiscountAmount").innerHTML=di;
			document.getElementById("dis-text").style.display='block';
			
			 //document.getElementById("DiscountText").innerHTML='<td height="25">&nbsp;</td><td colspan="2"><strong>Discount:</strong></td><td align="right"><strong>$'+xmlHttp.responseText+'</strong></td><td>&nbsp;</td>'
			//document.getElementById("PromoTR").style.display = "none";
			//document.getElementById("ShowPromoTR").style.display = "none";
	 	}
	}
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params)
}

function getLeatherCombination(strVal, SelectStrap)
{
	xmlHttp=GetXmlHttpObject()

	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	document.getElementById("divStrapLeathers").innerHTML="<img src='images/b-loader.gif' align='center'>";
	var url="show-leather-styles.php"
	params="instock="+strVal+"&SelectStrap="+SelectStrap
	
	xmlHttp.onreadystatechange=function () 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 	{ 
			document.getElementById("divStrapLeathers").innerHTML=xmlHttp.responseText;
			document.getElementById("mainStrapDIV").style.display='';
	 	}
	}
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params)
}


function getColorLeatherCombination(strVal, SelectStrap)
{
	xmlHttp=GetXmlHttpObject()

	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	document.getElementById("divStrapLeathers").innerHTML="<img src='images/b-loader.gif' align='center'>";
	
	var url="show-leathercombinations.php"
	params="color="+strVal+"&SelectStrap="+SelectStrap
	
	xmlHttp.onreadystatechange=function () 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 	{ 
			document.getElementById("divStrapLeathers").innerHTML=xmlHttp.responseText;
			document.getElementById("mainStrapDIV").style.display='';
	 	}
	}
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params)
}


function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	 }
	return xmlHttp;
}