<!--
function popopen(swURL, swName, swFeatures, winName) {
  var remote = open(swURL, swName, swFeatures);
  if(window.focus){remote.focus()}
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = winName;
  return remote;
}

var xmlHttp

function GetXmlHttpObject(){
	var xmlHttp=null;
	try{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}catch (e){
		// Internet Explorer
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function parseScript(_source) {
	var source = _source;
	var scripts = new Array();
		
	// Strip out tags
	while(source.indexOf("<script") > -1 || source.indexOf("</script") > -1){
		var s = source.indexOf("<script");
		var s_e = source.indexOf(">", s);
		var e = source.indexOf("</script", s);
		var e_e = source.indexOf(">", e);
//		alert("s_e: " + s_e + " e_e:" + e_e);
		// Add to scripts array
		scripts.push(source.substring(s_e+1, e));
		// Strip from source
		source = source.substring(0, s) + source.substring(e_e+1);
	}
	
	// Loop through every script collected and eval it
	for(var i=0; i<scripts.length; i++){
		alert(scripts[i]);
		try {
			eval(scripts[i]);
		}
		catch(ex) {
			// do what you want here when a script fails
		}
	}
		
	// Return the cleaned source
	return source;
}//end parseScript

function statecalcChanged(div){
	if (xmlHttp.readyState==4){
//		document.getElementById('page-wrap').style.opacity = '1';
//		document.getElementById('page-wrap').style.filter = "alpha(opacity=100)";
//		alert(xmlHttp.responseText);
		alert("ready");
//		document.getElementById(div).innerHTML=xmlHttp.responseText;
		document.getElementById("popupwindow").innerHTML=xmlHttp.responseText;
	}else{
		alert("none");
//		document.getElementById('page-wrap').style.opacity = '.4';
//		document.getElementById('page-wrap').style.filter = "alpha(opacity=40)";
	}
}


function tableclothcalc(div, p, type, backURL,s,l,d,w,er){ 
//alert(str1);
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	}
//	alert(s + " " + l + " " + d + " " + w);
	if(type != 817){
		if(div != "popupwindow"){
			var url="include/tablecloth-calc.html";
		}else{
			var url="include/tablecloth-calc-pop.html";
		}
	}else if(div != "popupwindow"){
		var url="include/runner-custom-calc.html";
	}else{
		var url="include/runner-custom-calc-pop.html";
	}//end if
	url=url+"?p="+p;
	url=url+"&div="+div;
	url=url+"&id="+type;
	url=url+"&backURL="+backURL;
	url=url+"&length="+l;
	url=url+"&Drop="+d;
	url=url+"&width="+w;
	if(s=="Y"){
		url=url+"&submit=calculate";
	}
	if(er!=null){
		url=url+"&er="+er;
	}
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==4){
			document.getElementById(div).innerHTML=xmlHttp.responseText;
		}else{
		}
	};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function qa(div, q, e, p, c, s, pid){ 
//alert(str1);
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	}
//	alert(s + " " + l + " " + d + " " + w);
	var url="../include/questions-form.html";
	url=url+"?q="+q;
	url=url+"&e="+e;
	url=url+"&p="+p;
	url=url+"&div="+div;
	url=url+"&c="+c;
	url=url+"&pid="+pid
	if(s=="Y"){
		url=url+"&submit=Submit";
	}
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==4){
			document.getElementById(div).innerHTML=xmlHttp.responseText;
		}else{
		}
	};
	xmlHttp.open("get",url,true);
	xmlHttp.send(null);
}

function getWidth(){
	var y;

	if(self.pageYOffset){
		y = self.pageYOffset;
	}else if(document.documentElement && document.documentElement.scrollTop){
		y = document.documentElement.scrollTop;
	}else if(document.body){
		y = document.body.scrollTop;
	}

	y = new Array('',y);
	return y;
}


function getPgSize(){
	
	var x, y;
	
	if(window.innerHeight && window.scrollMaxY){
		x = document.body.scrollWidth;
		y = window.innerHeight + window.scrollMaxY;
	}else if(document.body.scrollHeight > document.body.offsetHeight){
		x = document.body.scrollWidth;
		y = document.body.scrollHeight;
	}else{
		x = document.body.offsetWidth;
		y = document.body.offsetHeight;
	}
	
	var winX, winY;
	if(self.innerHeight){
		winX = self.innerWidth;
		winY = self.innerHeight;
	}else if(document.documentElement && document.documentElement.clientHeight){
		winX = document.documentElement.clientWidth;
		winY = document.documentElement.clientHeight;
	}else if(document.body){
		winX = document.body.clientWidth;
		winY = document.body.clientHeight;
	}
	
	// for small pages with total height less then height of the viewport
	if(y < x){
		var pgH = winY;
	}else{ 
		var pgH = y;
	}

	// for small pages with total width less then width of the viewport
	if(x < winX){
		var pgW = winX;
	}else{
		var pgW = x;
	}

	var PgSize = new Array(pgW,pgH,winX,winY);
	return PgSize;
}

function stateChanged(){
	if(xmlHttp.readyState==4){
		var pgSize = getPgSize();
		var wide = getWidth();

		document.getElementById('page-wrap').style.opacity = '.4';
		document.getElementById('page-wrap').style.filter = "alpha(opacity=40)";
		document.getElementById('popupwindow').style.display = 'block';
		document.getElementById('closeimg').style.display = 'block';
		if(navigator.appVersion.search("MSIE 6") > -1){
			 document.getElementById('ieframe').style.display = 'block';
		}

		var popW = parseInt(document.getElementById('popupwindow').style.width);
		var popH = parseInt(document.getElementById('popupwindow').style.height);

		document.getElementById('popupwindow').style.top = (wide[1] + ((pgSize[3] - 35 - popH) / 2) + 'px');
		document.getElementById("popupwindow").style.left = (((pgSize[0] - 20 - popW) / 2) + 'px');
		if(navigator.appVersion.search("MSIE 6") > -1){
			document.getElementById('ieframe').style.top = (wide[1] + ((pgSize[3] - 35 - popH) / 2) + 'px');
			document.getElementById("ieframe").style.left = (((pgSize[0] - 20 - popW) / 2) + 'px');
		}
		var poptop = wide[1] + ((pgSize[3] - 35 - popH) / 2);
		var popleft = ((pgSize[0] - 20 - popW) / 2);
		
		document.getElementById('popupwindow').style.top = (poptop < 0) ? "0px" : poptop + "px";
		document.getElementById("popupwindow").style.left = (popleft < 0) ? "0px" : popleft + "px";
		var imgtop = poptop;
		var imgleft = popleft+popW-18;
		document.getElementById('closeimg').style.top = (poptop < 0) ? "0px" : imgtop + "px";
		document.getElementById("closeimg").style.left = (popleft < 0) ? "0px" : imgleft + "px";
		if(navigator.appVersion.search("MSIE 6") > -1){
			document.getElementById('ieframe').style.top = (poptop < 0) ? "0px" : poptop + "px";
			document.getElementById("ieframe").style.left = (popleft < 0) ? "0px" : popleft + "px";
		}

		document.getElementById("popupwindow").style.width = popW + 'px';
		var result = parseScript(xmlHttp.responseText);
//		alert(result);
		document.getElementById("popupwindow").innerHTML=result;
		this.blur();
		return false;
		}
}

function closepopup(){
		document.getElementById('page-wrap').style.opacity = '1';
		document.getElementById('page-wrap').style.filter = "alpha(opacity=100)";
		document.getElementById('popupwindow').style.display = 'none';
		document.getElementById('ieframe').style.display = 'none';
		document.getElementById('closeimg').style.display = 'none';
}//end if

$(document).ready(function(){
  $("#flash-photo").click(function(){
    htmlobj=$.ajax({url:"swatch-gallery.html?Category=Spun_Poly_Solids",
		success: function(data){$("#matrix-block").html(data);}, 
		error: function(xhr, status){alert('error');},
		complete: function(){alert('complete');}
		});
  this.blur();return false;
  });
});


function popUp(url, winName, wid, hgt){
//	newwindow=window.open(URL, winName,'resizable=yes, width='+wid+', height='+hgt+', scrollbars=yes');
//	if(window.focus){newwindow.focus()}
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	}
	document.getElementById('popupwindow').style.width = wid + "px";
	document.getElementById('popupwindow').style.height = hgt + "px";

	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

}

function showhide(area){
	if(document.getElementById(area).style.display == "none"){
		document.getElementById(area).style.display = "block";
	}else{
		document.getElementById(area).style.display = "none";
	}
}

function switchtab(num){
	tab = new Array("1","4","7","10");
	for(x=0; x<tab.length; x++){
		if(document.getElementById('tab'+tab[x])){
			if(tab[x] != num){
				document.getElementById('tabtext'+tab[x]).style.display = "none";
				document.getElementById('tab'+tab[x]).className = "";
			}else{
				document.getElementById('tabtext'+tab[x]).style.display = "block";
				document.getElementById('tab'+tab[x]).className = "active";
			}
		}
	}
}
//-->

