function hideshow(which,arrow){
	if (!document.getElementById)
	return
	if (which.style.display=="block") {
		which.style.display="none"
		arrow.src = "/graphics/arrow.gif"
	} else {
		which.style.display="block"
		arrow.src = "/graphics/arrow_open.gif"
	}
}

function setVisible(obj) {
	obj = document.getElementById(obj);
	obj.style.visibility = (obj.style.visibility == 'visible') ? 'hidden' : 'visible';
}

updateflag = 0

function setupdateflag() {
	updateflag = 1
}

function updatecart() {
	document.cart.submit()
	updateflag = 0
}

function checkout() {
	if (updateflag == 0) {
		//location.href = "https://www.smithandtruslow.com/order_form.php"
		location.href = "/order_form.php"
	} else {
		alert("You have change your cart. Please select \"Update\" before checking out.")
	}
}

function confirm_order() {
	document.order.submit()
}

function addtocart() {
	document.giftcert.submit()
}

function updateshipping() {
	location.href = "/order_update_shipping.php?s=" + document.cart.shipping.value
}

function popup(p,x,y) {
	self.name="main"
	var popup = window.open( p, "popup", "toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+x+",height="+y)
	popup.focus()
}

function ordernow() {
	count = 0;
	for (var i = 0; i < document.standard.box.length; i++)
		if (document.standard.box[i].checked) count++;

	if (count > 0) {
		document.standard.submit();
	} else {
		alert("You must select one or more boxes first.")
	}
}

function holiday_card_ordernow() {
	count = 0;
	for (var i = 0; i < document.holidaycards.hc.length; i++)
		if (document.holidaycards.hc[i].checked) count++;

	if (count > 0) {
		document.holidaycards.submit();
	} else {
		alert("You must select one or more boxes first.")
	}
}

var orderplaced = 0;

function placeorder() {
	if (orderplaced == 0) {
		placeorder.src = "/graphics/processing.gif";
		orderplaced = 1;
		location.href = "/order_place.php";
	}

}



function newslettersignup(x,y) {
	getpage("/newslettersignup.php","?signupfield="+x+"&cf="+y)
}

function getpage(page,parms) {
	if (page.length == 0) {
		document.getElementById("signup").innerHTML = "";
		return;
	}
	xmlHttp = zGetXmlHttpObject();
	if (xmlHttp == null) {
		alert ("Your browser does not support AJAX!");
		return;
	}
	url = page + parms;
	xmlHttp.onreadystatechange = zstateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function zGetXmlHttpObject() {
	var xmlHttp = null;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {h
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function zstateChanged() {
	if (xmlHttp.readyState == 4) {
		document.getElementById("signup").innerHTML = xmlHttp.responseText;
	}
}
