var pwaitblur = document.getElementById("pwaitblur");
var confirmResponse="";

function removeItem(cart_id) {
	document.getElementById("editCart").style.visibility = "hidden";
	pwait(0, 1, 'black');
	window.location = "editCart.asp?func=del&cart_id="+cart_id
}

function moveLocation(cart_id, newloc) {
	document.getElementById("moveLoc").style.visibility = "hidden";
	document.getElementById("editCart").style.visibility = "hidden";
	pwait(0, 1, 'black');
	window.location = "editCart.asp?func=move&cart_id="+cart_id+"&loc="+newloc;
}

function updateQty(cart_id, qty) {
	document.getElementById("chQty").style.display = "none";
	document.getElementById("editCart").style.display = "none";
	pwait(0, 1, 'black');
	window.location = "editCart.asp?func=qty&cart_id="+cart_id+"&qty="+qty;
}

function doUpload(val) {
	var upload=document.getElementById("Upload");
	objh = parseFloat(upload.style.height)/2;
	objw = parseFloat(upload.style.width)/2;
	if (val=="show") {
		pwaitblur.style.visibility = "visible";
		upload.style.visibility = "visible";
		upload.style.top = Math.floor(Math.round((document.documentElement.offsetHeight/2)+document.body.scrollTop)-objh)+'px';
		upload.style.left = Math.floor(Math.round((document.documentElement.offsetWidth/2)+document.body.scrollLeft)-objw)+'px';
	} else {
		upload.style.visibility = "hidden";
		pwaitblur.style.visibility = "hidden";
	}
}

function chQty(val) {
    var chQty=document.getElementById("chQty");
	objh = parseFloat(chQty.style.height)/2;
	objw = parseFloat(chQty.style.width)/2;
	if (val=="show") {
		pwaitblur.style.visibility = "visible";
		chQty.style.visibility = "visible";
		chQty.style.top = Math.floor(Math.round((document.documentElement.offsetHeight/2)+document.body.scrollTop)-objh)+'px';
		chQty.style.left = Math.floor(Math.round((document.documentElement.offsetWidth/2)+document.body.scrollLeft)-objw)+'px';
	} else {
		chQty.style.visibility = "hidden";
	}
}



function editCart(cart_id, iname, qty) {
	if (iname!="") { document.getElementById("itemname").innerHTML = "<b>"+iname; }
	document.getElementById("ecCart_id").value = cart_id;
	document.getElementById("ecQty").value = qty;
	var editCart=document.getElementById("editCart");
	objh = parseFloat(editCart.style.height)/2;
	objw = parseFloat(editCart.style.width)/2;
	if (cart_id != "hide") {
	pwaitblur.style.visibility = "visible";
	editCart.style.visibility = "visible";
	} else {
	pwaitblur.style.visibility = "hidden";
	editCart.style.visibility = "hidden";
	}
	editCart.style.top = Math.floor(Math.round((document.documentElement.offsetHeight/2)+document.body.scrollTop)-objh)+'px';
	editCart.style.left = Math.floor(Math.round((document.documentElement.offsetWidth/2)+document.body.scrollLeft)-objw)+'px';
}

function backOrder(val, title, from) {
	//if (from=="easy_add") { document.getElementById("cancelbtn").style.display="none"; }
    var backorder=document.getElementById("backorder");
    if (title!="" && title!=null) { document.getElementById("btitle").style.display="inline"; document.getElementById("btitle").style.visibility="visible"; document.getElementById("btitle").innerHTML=title; } else { document.getElementById("btitle").style.display="none"; document.getElementById("btitle").style.visibility="hidden"; document.getElementById("btitle").innerHTML=""; }
	objh = parseFloat(backorder.style.height)/2;
	objw = parseFloat(backorder.style.width)/2;
	if (val=="show") {
		pwaitblur.style.visibility = "visible";
		backorder.style.visibility = "visible";
		backorder.style.top = Math.floor(Math.round((document.documentElement.offsetHeight/2)+document.body.scrollTop)-objh)+'px';
		backorder.style.left = Math.floor(Math.round((document.documentElement.offsetWidth/2)+document.body.scrollLeft)-objw)+'px';
	} else if (val=="hide1") { 
		pwaitblur.style.visibility = "hidden";
		backorder.style.visibility = "hidden"; 
	} else {
		pwaitblur.style.visibility = "hidden";
		backorder.style.visibility = "hidden";
		if (document.getElementById("showAlts")) {
			fullReset("false");
		}
		if (document.getElementById("qtyavail")) {
			document.getElementsByName("qty")[0].value = document.getElementById("qtyavail").value;
			AddCart();
		}
	}
}

function holdBack(val) {
    /// <summary>
    ///     "show" will display 'hold backorder' popup, any other value will hide it
    /// </summary>
    /// <param name="val" type="String">
    ///     1: "show" or "" (empty string)
    /// </param>

    var hold=document.getElementById("hold");
	objh = parseFloat(hold.style.height)/2;
	objw = parseFloat(hold.style.width)/2;
	if (val=="show") {
		pwaitblur.style.visibility = "visible";
		hold.style.visibility = "visible";
		hold.style.top = Math.floor(Math.round((document.documentElement.offsetHeight/2)+document.body.scrollTop)-objh)+'px';
		hold.style.left = Math.floor(Math.round((document.documentElement.offsetWidth/2)+document.body.scrollLeft)-objw)+'px';
	} else {
		pwaitblur.style.visibility = "hidden";
		hold.style.visibility = "hidden";
	}
}

function moveLoc(val) {
    var alt=document.getElementById("moveLoc");
	objh = parseFloat(alt.style.height)/2;
	objw = parseFloat(alt.style.width)/2;
	if (val=="show") {
		pwaitblur.style.visibility = "visible";
		alt.style.visibility = "visible";
		alt.style.top = Math.floor(Math.round((document.documentElement.offsetHeight/2)+document.body.scrollTop)-objh)+'px';
		alt.style.left = Math.floor(Math.round((document.documentElement.offsetWidth/2)+document.body.scrollLeft)-objw)+'px';
		document.getElementById("editCart").style.visibility = "hidden";
	} else {
		alt.style.visibility = "hidden";
		document.getElementById("editCart").style.visibility = "visible";
	}
}


function altLoc(val) {
    var alt=document.getElementById("alt");
	objh = parseFloat(alt.style.height)/2;
	objw = parseFloat(alt.style.width)/2;
	if (val=="show") {
		pwaitblur.style.visibility = "visible";
		alt.style.visibility = "visible";
		alt.style.top = Math.floor(Math.round((document.documentElement.offsetHeight/2)+document.body.scrollTop)-objh)+'px';
		alt.style.left = Math.floor(Math.round((document.documentElement.offsetWidth/2)+document.body.scrollLeft)-objw)+'px';
		document.getElementById("backorder").style.visibility = "hidden";
	} else {
		alt.style.visibility = "hidden";
		document.getElementById("backorder").style.visibility = "visible";
	}
}

function setheight() {
	pwaitblur.style.height = document.body.scrollHeight+"px";
}


function cConfirm(msg) {
	var cb=document.getElementById("confirmBox");
	objh = parseFloat(cb.style.height)/2;
	objw = parseFloat(cb.style.width)/2;
	document.getElementById("confirmMessage").innerHTML=msg;
	cb.style.visibility = "visible";
	cb.style.top = Math.floor(Math.round((document.documentElement.offsetHeight/2)+document.body.scrollTop)-objh)+'px';
	cb.style.left = Math.floor(Math.round((document.documentElement.offsetWidth/2)+document.body.scrollLeft)-objw)+'px';
}

function doConfirm(opt) {
	var cb=document.getElementById("confirmBox");
	cb.style.visibility = "hidden";
	if (opt) { validateList(true); }
		/*var parts=document.getElementsByName("partnum");
		var price=document.getElementsByName("price");
		for (var i=0; i<parts.length; i++) {
			if (price[i]=="$0") {
				validatePart(parts[i].value, parts[i].getAttribute("loc"));
			}
		}
	}*/

}
