SymRealWinOpen=window.open;



function popUp(url) {
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=400,height=500');
	self.name = "mainWin";
}
function openwin2(windowname) {
	window.open(windowname,'wtcwin2','width=410,height=550,directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
}
function openwin(windowname) {
	window.open(windowname,'wtcwin2','width=410,height=550,directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
}



function checkEmail() {
emailX=""+	document.scribeme.email.value;
if((emailX.indexOf("@")<2)||(emailX.indexOf(".")<2)||(emailX.length<4)){
alert("Please enter a valid email address");
document.scribeme.email.focus();
return false;
}
return true;
}



var XMLHttpRequestObject = false;

if (window.XMLHttpRequest) 
 {	XMLHttpRequestObject = new XMLHttpRequest();  } 
 else if (window.ActiveXObject) 
 { XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP")  }

function getData(datasource,divid)
{
  if (XMLHttpRequestObject)
 	{
		var obj = document.getElementById(divid);
		XMLHttpRequestObject.open("GET", datasource+"&ms=" + new Date().getTime(),true);
		XMLHttpRequestObject.onreadystatechange = function()
		{
			if (XMLHttpRequestObject.readyState ==4 && XMLHttpRequestObject.status == 200)
				{ obj.innerHTML  = XMLHttpRequestObject.responseText; }           
		}
		XMLHttpRequestObject.send(null);
	}         
}  



function ValidFormProd(formname) {
		
			thefieldnameP = formname + ".the_product_id"
			thefieldvalP=eval("document." + thefieldnameP);
			
			allprods =thefieldvalP.value.split(",");
			var haserror = 0;
			
			for(x=0;x<allprods.length;x++) {
				if (allprods[x] != "") {
					
					thefieldnameQ="qty_" + allprods[x];
					thefieldvalQ=eval("document." + formname + "." + thefieldnameQ);
					thefieldvalQ=thefieldvalQ.value;
					
					thefieldname1="variant_1_" + allprods[x];
					thefieldval1=eval("document." + formname + "." + thefieldname1);
					thefieldval1 = thefieldval1.value;
					
					thefieldname2="variant_sku_" + allprods[x];
					thefieldval2=eval("document." + formname + "." + thefieldname2);
					thefieldval2 = thefieldval2.value;
					
					if (thefieldval1 != "" || thefieldval2 != "" ) { // only run error chekcing on products that were selected
						if ((thefieldvalQ != "" && thefieldvalQ > 0) && (thefieldval1 == "" || thefieldval2 == "") ) {
							alert("Please select a size and/or color before you add the item to your cart.")
							haserror = 1 
						}
						
						if (thefieldvalQ == "" || thefieldvalQ < 0 || isNum(thefieldvalQ) == false  || thefieldvalQ > 999 ) {
							alert("Please enter a valid quantity.")
							haserror = 1 
						}
					 } 
				}
			}
			if (haserror == 1) {
				return(false) 
			} 
	}
	
function isNum(str) {
	var test = "0123456789"
	for (i=0; i <= str.length-1; i++) {
	if (test.indexOf(str.charAt(i)) == -1) return false;
	}
	return true;
}


function ValidFormProdshelf(formname) {
	thefieldnameP = formname + ".the_product_id"
	thefieldvalP=eval("document." + thefieldnameP);
	allprods =thefieldvalP.value.split(",");
	var haserror = 0;
	
	for(x=0;x<allprods.length;x++) {
		if (allprods[x] != "") {
			thefieldnameQ="qty_" + allprods[x];
			thefieldvalQ=eval("document." + formname + "." + thefieldnameQ);
			thefieldvalQ=thefieldvalQ.value;
			
			thefieldname1="variant_1_" + allprods[x];
			thefieldval1=eval("document." + formname + "." + thefieldname1);
			thefieldval1 = thefieldval1.value;
			
			thefieldname2="variant_sku_" + allprods[x];
			thefieldval2=eval("document." + formname + "." + thefieldname2);
			thefieldval2 = thefieldval2.value;
			
			if ((thefieldvalQ != "" && thefieldvalQ > 0) && (thefieldval1 == "" || thefieldval2 == "") ) {
				alert("Please select a size and color before you add the item to your cart.")
				haserror = 1 
			}
		}
	}
	
	if (haserror == 1) {
		return(false) 
	} 
}



function FixImgShelf(that){
var myH = 298;  //164
var myW = 190;  //125
//alert(that.height + ' ' + that.width);
	if(that.height>myH){
	var Differential = myH/that.height;
	that.height = myH;
	that.width = that.width * Differential;
	}
	if(that.width>myW){
	var Differential = myW/that.width;
	that.width = myW;
	that.height = that.height * Differential;
	}
}

function toggledisplay(divid,imgid){
	if (document.getElementById(divid).style.display != "block"){
	document.getElementById(divid).style.display="block"
	document.getElementById(imgid).src='images/new_cs_arrow_open.gif'
	}
	else{
	document.getElementById(divid).style.display="none"
	document.getElementById(imgid).src='images/new_cs_arrow.gif'
	}
}

function toggledisplaysub(divid,qid,imgid){
	if (document.getElementById(divid).style.display != "block"){
	document.getElementById(divid).style.display="block"
	document.getElementById(qid).style.color="#ff7920"
	document.getElementById(imgid).src='images/new_cs_arrow_sub.gif'
	}
	else{
	document.getElementById(divid).style.display="none"
	document.getElementById(qid).style.color="#333333"
	document.getElementById(imgid).src='images/new_cs_arrow_subx.gif'
	}
}