
function print_url(contextPath, siteControllerURL, siteName, productId) {

   var url = contextPath + "/" + siteControllerURL + "/" + siteName + "/productprintcolors?modal=true&height=450&width=500&productId=" + productId;
   window.open(url);
}
function getpopup(trackingNumber) {
		var queryString = "?InquiryNumber1="+trackingNumber+"&UPS_HTML_License=8C3A0FD116F0C87E&IATA=us&Lang=eng&UPS_HTML_Version=3.0&TypeOfInquiryNumber=T&nonUPS_title=Payless Tracking Response&nonUPS_header=&lt;CENTER&gt;Welcome to Payless! &lt;/CENTER&gt; &lt;HR&gt;&nonUPS_footer=&lt;HR&gt; &lt;CENTER&gt;Copyright &#169; 2003 Payless & lt;/CENTER&gt;&nonUPS_body=BGCOLOR=&quot;#ffffff&quot;";	
		window.open("http://wwwapps.ups.com/WebTracking/OnlineTool"+queryString,"_blank","width=600,height=400,status=0,resizable=0,directories=0,toolbar=0,menubar=0,top=150,left=300,scrollbars=yes",true);
}
function getuspspopup(trackingNumber) {
		var queryString = "?origTrackNum="+trackingNumber;
		window.open("http://trkcnfrm1.smi.usps.com/PTSInternetWeb/InterLabelInquiry.do"+queryString,"_blank","width=600,height=400,status=0,resizable=0,directories=0,toolbar=0,menubar=0,top=150,left=300,scrollbars=yes",true);
}
String.prototype.trim = function() {
 return this.replace(/^\s+|\s+$/g, ""); 
} 
function populateBillingAddress()
{
		var ischecked = document.getElementById('also-billing-address').checked;
		if(ischecked==true)
		{
			if(document.getElementById('billing-selectaddress') == null  && document.getElementById('shipping-selectaddress') == null) {
			} else {
			document.getElementById('billing-selectaddress').value = document.getElementById('shipping-selectaddress').value;
		} 
		document.getElementById('billing-firstname').value=document.getElementById('shipping-firstname').value;
		document.getElementById('billing-middleinitial').value=document.getElementById('shipping-middleinitial').value;
		document.getElementById('billing-lastname').value=document.getElementById('shipping-lastname').value;
		document.getElementById('billing-address1').value=document.getElementById('shipping-address1').value;
		document.getElementById('billing-address2').value=document.getElementById('shipping-address2').value;
		document.getElementById('billing-pobox').value=document.getElementById('shipping-pobox').value;
		document.getElementById('billing-city').value=document.getElementById('shipping-city').value;
		document.getElementById('billing-state').value=document.getElementById('shipping-state').value;
		document.getElementById('billing-zipcode').value=document.getElementById('shipping-zipcode').value ;
	} 
	else 
	{
		if(document.getElementById('billing-selectaddress') == null  && document.getElementById('shipping-selectaddress') == null) {
		} else {
			document.getElementById('billing-selectaddress').value = document.getElementById('billing-selectaddress').options[0].value;
		} 
		document.getElementById('billing-firstname').value="";
		document.getElementById('billing-middleinitial').value="";
		document.getElementById('billing-lastname').value="";
		document.getElementById('billing-address1').value="";
		document.getElementById('billing-address2').value="";
		document.getElementById('billing-pobox').value="";
		document.getElementById('billing-city').value="";
		document.getElementById('billing-state').value="";
		document.getElementById('billing-zipcode').value="";
	}
}
function moreThenTen(formName,commItemId,productRefId){
  var frmObj= document.getElementById(formName);
  var selectedQty = frmObj.elements[commItemId].value;
  if(selectedQty != null && selectedQty !='moreThanten')
	{
	 document.getElementById(productRefId+commItemId+"moreThenten").style.display="none";
	 document.getElementById(commItemId+"morethanten").name="";
	}
  if(selectedQty != null && selectedQty == 'moreThanten')
	{
	 document.getElementById(commItemId+"morethanten").name=commItemId+"morethanten";
	 document.getElementById(productRefId+commItemId+"moreThenten").style.display="inline";
	 document.getElementById(commItemId+"morethanten").focus();
	}				
}	
function submitQtyUpdateform(formName){ 
	var frmObj= document.getElementById(formName);
	frmObj.submit();
} 
function allowNumberOnly(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (charCode > 31 && (charCode < 48 || charCode > 57)){
		return false;
	}
	return true;
}
function allowAlphaNumerics(evt){

	var charCode = (evt.which) ? evt.which : event.keyCode	
	if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 65 || charCode > 90) && (charCode < 97 || charCode > 122))
		return false;

	return true;
}

function formSubmit(formAction,type){
	
	if(type=='shippingMethod'){
		document.shippingMethodForm.formAction.value = formAction;	
		document.shippingMethodForm.submit();
	} else
		if(type=='shippingandbilling'){
			 document.getElementById("handleAction").value=formAction;            
			 document.shippingandbillingform.submit();
		}
	else
		if(type=='orderreviewandpayment'){
			document.forms['orderreviewandpayment'].actionType.value = formAction;
			document.orderreviewandpayment.submit();
		}
	
}	
function placeOrderClicked()
{
	formSubmit('CommitOrder','orderreviewandpayment');
}
function submitlogoutform()
{
	document.getElementById("logoutform").submit();
}
function submitform(action)
{
	document.addnewpaymentform.actionType.value = action ;
	document.addnewpaymentform.submit();
}
function submitFormOnEnterKeyPress(evt,type)
{				
	 var key = (window.Event) ? evt.which : evt.keyCode;
	 if(key==13){
	 	if(type=='creditcard')
	     		 formSubmit('CommitOrder','orderreviewandpayment');
	     	else if(type==='OrderStatus')
	     		document.getElementById('OrderStatusSearch').submit();
	 }
 }
 
// The following scripts are for product details page.
var quantity = 0;
function changeQuantity(qtyValue)
{
	if(qtyValue == 'More than 10'){
		document.getElementById("qty1").value = "";
		document.getElementById("qtyTextBox").style.display = "inline";
	}else{
		document.getElementById("qtyTextBox").style.display = "none";
		document.getElementById("qty1").value = "";
	}
}
function changeColor(productId, catId, selectedStockNumber, selectedSize, selectedWidth, url)
{
	document.getElementById('addtobag').disabled = true;
	window.location.href = url + "?productId=" + productId + "&catId=" + catId + "&stockNumber=" + selectedStockNumber + 
	"&selectedSize=-1&selectedWidth=-1&colorChanged=true";
}
function changeSize(productId, catId, skuId, selectedColor, selectedDisplayColor, selectedWidth, url)
{
	document.getElementById('addtobag').disabled = true;
	if (document.getElementById("size").value == '-1') {
		window.location.href = url + "?productId=" + productId + "&catId=" + catId + "&skuId=" + skuId + "&selectedColor=" + 
		encodeURIComponent(selectedColor) + "&selectedDisplayColor=" + encodeURIComponent(selectedDisplayColor) + "&selectedSize=" + skuId + "&selectedWidth=" + selectedWidth + 
		"&showDefaultSize=" + true;
	} else {
		window.location.href = url + "?productId=" + productId + "&catId=" + catId + "&skuId=" + skuId + "&selectedColor=" + 
		encodeURIComponent(selectedColor) + "&selectedDisplayColor=" + encodeURIComponent(selectedDisplayColor) + "&selectedSize=" + skuId + "&selectedWidth=" + selectedWidth;
	}	
	
}
function changeWidth(productId, catId, selectedWidth, selectedColor, selectedDisplayColor, selectedSize, url)
{
	if (document.getElementById("width").value == '-1') {
		window.location.href = url + "?productId=" + productId + "&catId=" + catId + "&selectedColor=" + encodeURIComponent(selectedColor) + 
		"&selectedDisplayColor=" + encodeURIComponent(selectedDisplayColor) + "&selectedSize=" + selectedSize + "&selectedWidth=" + selectedWidth + 
		"&showDefaultWidth=" + true;
	} else {
		window.location.href = url + "?productId=" + productId + "&catId=" + catId + "&selectedColor=" + encodeURIComponent(selectedColor) + 
		"&selectedDisplayColor=" + encodeURIComponent(selectedDisplayColor) + "&selectedSize=" + selectedSize + "&selectedWidth=" + selectedWidth;
	}
}
// End of scripts for product details page.

//The following script is used in cartpage.
function quantityselected(commerceItemid,selQty,commerceItemrepositoryId)		
{
	var selElement = document.getElementById(commerceItemid);
	var qty = selQty;
		if( (qty==null)||(qty=='') ){											
		}else{
		    qty=qty*1; 
			if(qty>10){						   	    
			   var productid = commerceItemrepositoryId;
			   var commerceItemid = commerceItemid;

			   document.getElementById(productid+commerceItemid+"moreThenten").style.display="inline";
			   document.getElementById(commerceItemid+"morethanten").value=qty;
			   selElement.value='moreThanten';	
			}else{
			  selElement.value=qty;	
			  }						     
	      }		
}


function copyCreditCardNumber(){
	document.getElementById("hiddenCCNumber").value = document.getElementById("CreditCardNumber").value;
}

function moveCreditCardNumber(){
	document.getElementById("hiddenCCNumber").value = document.getElementById("cardnumber").value;
}
