function newXMLHttpRequest() {
	var xmlreq = false;			
	// Create XMLHttpRequest object in non-Microsoft browsers
	if (window.XMLHttpRequest)
		xmlreq = new XMLHttpRequest();
	else if (window.ActiveXObject) {
		try {
			// Try to create XMLHttpRequest in later versions
			// of Internet Explorer
			xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
			// Failed to create required ActiveXObject
			try {
				// Try version supported by older versions
				// of Internet Explorer
				xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				// Unable to create an XMLHttpRequest by any means
				xmlreq = false;
			}
		}
	}
	return xmlreq;
}
function getReadyStateHandler(req, responseXmlHandler) {
	// Return an anonymous function that listens to the XMLHttpRequest instance
	return function () {
	// If the request's status is "complete"
		if (req.readyState == 4)
			// Check that we received a successful response from the server
			if (req.status == 200)
				// Pass the XML payload of the response to the handler function.
				responseXmlHandler(req.responseXML);
			else
				// An HTTP problem has occurred
				alert("HTTP error " + req.status+": " + req.statusText);
	}
}
function updateConfig(configXML) {
	var config = configXML.getElementsByTagName("config")[0];
	var generated = config.getAttribute("generated");

	var items = config.getElementsByTagName("item");
	var img = document.getElementById("idImg");
	var item = items[0];
	//alert(item.getElementsByTagName("height")[0].firstChild.nodeValue);
	img.height = item.getElementsByTagName("height")[0].firstChild.nodeValue;
	img.width = item.getElementsByTagName("width")[0].firstChild.nodeValue;
}
function getSize(path, sel) {
	var AJAXpath = path + "/GetContent";
	var xhr = newXMLHttpRequest();

	xhr.onreadystatechange = getReadyStateHandler(xhr, updateConfig);
	xhr.open("POST",AJAXpath,true);
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xhr.send("step=" + sel);
}
function resizeBlank(path, objId, page, zoom) {
	var b1 = document.getElementById("idB1");
	var b2 = document.getElementById("idB2");			
	var sel = document.getElementById("select");
	var img = document.getElementById("idImg");

	b1.style.display = "none";
	b2.style.display = "block";

	getSize(path, sel.value);

	b2.style.background = "url("+path+"/GetContent?id="+objId+"&page="+page+"&step="+sel.value+") no-repeat;";
	//b2.style.background.repeat = "no-repeat;";
}
// From Electronic Order
function getOrders(ordid, usrid) {
	var AJAXpath = "/.Catalog/AllElectronicOrder";
	var xhr = newXMLHttpRequest();

  	xhr.open("POST",AJAXpath,true);
	xhr.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded");
	xhr.send("id="+ordid+"&usrid="+usrid);			
}
ff2=function(t)	{
	t.className=/\D/.test(t.value)?'err':'';
	if (/\D/.test(t.value)) {
		t.value=t.defaultValue;
    	if (self.ww) clearTimeout(ww);
	    o=t;
	    ww=setTimeout("o.className='';",999);
	} else t.defaultValue=t.value;
}