function ImgSwap(img_id,img_src){
	var img = document.getElementById(img_id);
	img.src = img_src;
}

function ShowHide(objparent,objclass,objid){
	var TheParent = document.getElementById(objparent);
	var TheChildren = TheParent.getElementsByTagName('*');
	for($i=0; $i<TheChildren.length; $i++){
		var TheChild = TheChildren[$i];
		if(TheChild.className==objclass && TheChild.id==objid){
			if(TheChild.style.display=='' || TheChild.style.display=='none'){
				TheChild.style.display = 'block';
			}else{
				TheChild.style.display = 'none';
			}
		}
	}
setTimeout('ddequalcolumns.resetHeights()',200);
}

function ShowOnly(objparent,objclass,objid){
	var parent = document.getElementById(objparent);
	var children = parent.getElementsByTagName('*');
	for($i=0; $i<children.length;$i++){
		var child = children[$i];
		if(child.className==objclass && child.id==objid){
			if(child.style.display=='' || child.style.display=='none'){
				child.style.display = 'block';
			}
		}else if(child.className==objclass){
			child.style.display = 'none';
		}
	}
}

function createXMLHttpRequest() {
  if(window.XMLHttpRequest) {
    try { 
      HttpObj = new XMLHttpRequest();
    } catch(e) { return null; }
  } else if(window.ActiveXObject) {
    try {
      HttpObj = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
      try {
        HttpObj = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) { return null; }
    }
  } else return null;
return HttpObj;
}

function processXMLHttpRequest(url,params,pricediv){
	var AjaxObj = new createXMLHttpRequest();
	AjaxObj.open("POST", url, true);
	AjaxObj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	AjaxObj.onreadystatechange = function(){
		if(AjaxObj.readyState == 4 && AjaxObj.status == 200) {
			ChangePrice(pricediv,AjaxObj.responseText);
		}
	}
	AjaxObj.send(params);
}

function TotalUp(sect){
var costdiv = document.getElementById(sect+'_cost');
var proddiv = document.getElementById(sect+'_prodcost');
var totaldiv = document.getElementById(sect+'_totalcost');
if(proddiv.parentNode.parentNode.style.display == "block"){
	var Production = (eval(proddiv.innerHTML));}else{Production=0;}
var DurationBlock = document.getElementById(sect+'_duration_block');
var inputs = DurationBlock.getElementsByTagName('input');
for(var i=0;i<inputs.length;i++){
	if(inputs[i].checked){var Duration = inputs[i].value;}else{var Duration = 1}
}
var Base = Duration*eval(costdiv.innerHTML);
//totaldiv.innerHTML = (Base+Production)+".00";
}

function PriceBySize(selectlist,sect,piecenum){
var rownum = selectlist.selectedIndex;
var params = ("sect="+sect+"&rownum="+rownum+"&piecenum="+piecenum);
var url = "pricebysize.php";
processXMLHttpRequest(url,params,sect+'_cost');
var url2 = "addproductioncost.php";
processXMLHttpRequest(url2,params,sect+'_prodcost');
}

function ChangePrice(obj,txt){
document.getElementById(obj).innerHTML = txt;
document.getElementById(obj+'_box').value = txt;
}

function ResetProdCost(obj){
if(obj.value!=='production'){
	document.getElementById('displayad_prodcost_box').value='0.00';
}else{
	PriceBySize(document.getElementById("displayad_size"),'displayad',1);
}
}

function ResetSLProdCost(obj){
if(obj.value!=='production'){
	document.getElementById('shoplocalad_prodcost_box').value='0.00';
}else{
	PriceBySize(document.getElementById("shoplocalad_size"),'shoplocalad',1);
}
}

function DurationSelect(sect,duration){
var selectmenu = document.getElementById(sect+'_size');
selectmenu.setAttribute('onchange', "PriceBySize(this,'"+sect+"',"+duration+");");
PriceBySize(selectmenu,sect,duration);
}

function DurationSelect2(sect,duration){
var params = ("sect="+sect+"&rownum=1&piecenum="+duration);
var url = "pricebysize.php";
processXMLHttpRequest(url,params,sect+'_cost');
}

function SwapZip(zip){
	var img = document.getElementById('zipimg');
	img.src = 'img/'+zip+'.jpg';
}