function formHandler(form){var URL = document.form.site.options[document.form.site.selectedIndex].value;
window.location.href = URL;}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function OpenCertDetails() {
    thewindow = window.open('https://www.thawte.com/cgi/server/certdetails.exe?code=USCAMC3-1', 'anew', config='height=400,width=450,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes');
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var updating;
function onAddToCart() {	
	if(updating) {
		alert("Updating product status, please wait and try again...");
		return;
	}
	
	o = document.getElementById("allowAddToCart");
	if(o.value == 0) {
		o = document.getElementById("csurl");
		document.location.href = o.value;
		return;
	} else {
		url = document.getElementById("addToCartPage").value + '&' + getItemInfoIntoUrl() + '&qty=1';
		document.location.href = url;
	}

}

function changeSubsize() {
	navigateProductIFrame('subsize');
	freezeItem(false,false,true);
}

function changeColor() {
	navigateProductIFrame('color');
	freezeItem(true,false,false);			
}

function emptyComboBoxToUpdating(comboBox) {
	if(comboBox) {
		while(comboBox.length > 0) {
			comboBox.options[0] = null;
		}
		
		comboBox.options[0] = document.createElement("OPTION");
		comboBox.options[0].value = "";
		comboBox.options[0].text = "Updating...";
		comboBox.options[0].selected = true;
	}
}

function freezeItem(changedColor, changedSize, changedSubsize) {
	o = document.getElementById("itemColorBox");
	if(o) {
		o.disabled = true;
	}
	
	o = document.getElementById("itemSizeBox");
	if(o) {
		o.disabled = true;
		
		if(changedColor) {
			emptyComboBoxToUpdating(o);
		}
	}
	
	o = document.getElementById("itemSubsizeBox");
	if(o) {
		o.disabled = true;
		
		if(changedColor || changedSize) {
			emptyComboBoxToUpdating(o);
		}
	}
	
	o = document.getElementById("priceDiv");
	if(o) {
		o.firstChild.data = "Updating...";
	}
	
	o = document.getElementById("stockStatusDiv");
	if(o) {
		o.firstChild.data = "Updating..";
	}

	updating = true;
}

function getItemInfoIntoUrl() {
	colorid='';
	sizeid='';
	subsizeid='';
	
	id = document.forms['productInfoForm'].productId.value;
	csurl = document.forms['productInfoForm'].csurl.value;
	
	o = document.getElementById('itemColorValue');
	if(o) {
		colorid = o.value;
	}

	o = document.getElementById('itemColorBox');
	if(o) {
		colorid = o.options[o.selectedIndex].value;
	}
	
	o = document.getElementById('itemSizeValue');
	if(o) {
		sizeid = o.value;
	}

	o = document.getElementById('itemSizeBox');
	if(o) {
		sizeid = o.options[o.selectedIndex].value;
	}
	
	o = document.getElementById('itemSubsizeValue');
	if(o) {
		subsizeid = o.value;
	}

	o = document.getElementById('itemSubsizeBox');
	if(o) {
		subsizeid = o.options[o.selectedIndex].value;
	}
	
	url = 'id=' + escape(id) + '&csurl=' + escape(csurl);

	o = document.getElementById('PersonalizationYes');
	if(o && o.checked) {
		url = url + '&pers=yes';
	} else {
		o = document.getElementById('PersonalizationNo');
		if(o && o.checked) {
			url = url + '&pers=no';
		}
	}

	if(String(colorid).length > 0) {
		url = url + '&color=' + escape(colorid);
	}
	
	if(String(sizeid).length > 0) {
		url = url + '&size=' + escape(sizeid);
	}
	
	if(String(subsizeid).length > 0) {
		url = url + '&subsize=' + escape(subsizeid);
	}
	
	return url;
}

function navigateProductIFrame(boxChanged) {
	urlinfo = getItemInfoIntoUrl();
	
	url = 'istar.asp?a=40&' + urlinfo + '&changed=' + boxChanged;
	productiframe.location.href = url;
}

function changeSize() {
	navigateProductIFrame('size');
	freezeItem(false,true,false);	
}
function popOrder(strURL) {
	if(window.popupWin) {
		if(popupWin.closed != true) {
			window.popupWin.focus();
			window.popupWin.location = strURL;
		} else {
			popupWin = window.open(strURL, "JasperBarnhart", 'resizable,scrollbars,status=no,width=480,height=390,left=50,top=10');
		}
	} else {
		popupWin = window.open(strURL, "JasperBarnhart", 'resizable,scrollbars,status=no,width=480,height=390,left=50,top=10');
	}
}
function popOrderLG(strURL) {
	if(window.popupWin) {
		if(popupWin.closed != true) {
			window.popupWin.focus();
			window.popupWin.location = strURL;
		} else {
			popupWin = window.open(strURL, "JasperBarnhart", 'resizable,scrollbars,status=no,width=600,height=650,left=50,top=10');
		}
	} else {
		popupWin = window.open(strURL, "JasperBarnhart", 'resizable,scrollbars,status=no,width=600,height=650,left=50,top=10');
	}
}	
	

function popOrderWd(strURL) {
	if(window.popupWin) {
		if(popupWin.closed != true) {
			window.popupWin.focus();
			window.popupWin.location = strURL;
		} else {
			popupWin = window.open(strURL, "JasperBarnhart", 'resizable,scrollbars,status=no,width=800,height=450,left=50,top=10');
		}
	} else {
		popupWin = window.open(strURL, "JasperBarnhart", 'resizable,scrollbars,status=no,width=800,height=450,left=50,top=10');
	}
}		
	
function popOrderSm(strURL) {
	if(window.popupWin) {
		if(popupWin.closed != true) {
			window.popupWin.focus();
			window.popupWin.location = strURL;
		} else {
			popupWin = window.open(strURL, "JasperBarnhart", 'resizable,scrollbars,status=no,width=475,height=475,left=50,top=10');
		}
	} else {
		popupWin = window.open(strURL, "JasperBarnhart", 'resizable,scrollbars,status=no,width=475,height=475,left=50,top=10');
	}
}			

function popOrderTr(strURL) {
	if(window.popupWin) {
		if(popupWin.closed != true) {
			window.popupWin.focus();
			window.popupWin.location = strURL;
		} else {
			popupWin = window.open(strURL, "JasperBarnhart", 'resizable,scrollbars,status=no,width=950,height=800,left=50,top=10');
		}
	} else {
		popupWin = window.open(strURL, "JasperBarnhart", 'resizable,scrollbars,status=no,width=950,height=800,left=50,top=10');
	}
}		

function popOrderWwd(strURL) {
	if(window.popupWin) {
		if(popupWin.closed != true) {
			window.popupWin.focus();
			window.popupWin.location = strURL;
		} else {
			popupWin = window.open(strURL, "JasperBarnhart", 'resizable,scrollbars,status=no,width=900,height=550,left=50');
		}
	} else {
		popupWin = window.open(strURL, "JasperBarnhart", 'resizable,scrollbars,status=no,width=900,height=550,left=50');
	}
}		

function popOrderTall(strURL) {
	if(window.popupWin) {
		if(popupWin.closed != true) {
			window.popupWin.focus();
			window.popupWin.location = strURL;
		} else {
			popupWin = window.open(strURL, "JasperBarnhart", 'resizable,scrollbars,status=no,width=600,height=700,left=25');
		}
	} else {
		popupWin = window.open(strURL, "JasperBarnhart", 'resizable,scrollbars,status=no,width=600,height=700,left=25');
	}
}		

function popOrderFit(strURL) {
	if(window.popupWin) {
		if(popupWin.closed != true) {
			window.popupWin.focus();
			window.popupWin.location = strURL;
		} else {
			popupWin = window.open(strURL, "JasperBarnhart", 'resizable,scrollbars,status=no,width=710,height=600,left=25');
		}
	} else {
		popupWin = window.open(strURL, "JasperBarnhart", 'resizable,scrollbars,status=no,width=710,height=600,left=25');
	}
}		

function popOrderFit2(strURL) {
	if(window.popupWin) {
		if(popupWin.closed != true) {
			window.popupWin.focus();
			window.popupWin.location = strURL;
		} else {
			popupWin = window.open(strURL, "JasperBarnhart", 'resizable,scrollbars,status=no,width=800,height=600,left=25');
		}
	} else {
		popupWin = window.open(strURL, "JasperBarnhart", 'resizable,scrollbars,status=no,width=800,height=600,left=25');
	}
}		