var url = "wood_get_quote_ajax.php";
var size_url = "wood_get_size_ajax.php";

var min_width = 10;
var min_length = 10;
var max_width = 96;
var max_length = 120;

function getSize()
{
	loadXMLDoc(size_url, setSize, false);
}

function setSize() 
{
	var size = resultXML;
	size = size.split("|");
	min_width = size[0];
	min_length = size[2];
	max_width = size[1];
	max_length = size[3];
}

function getQuote()
{
	var wid = document.myForm.blind_width.value
	var len = document.myForm.blind_length.value
	if(wid == max_width)



	{



		document.myForm.blind_width_fraction.value = "0.000";



	}







	if(len == max_length)



	{



		document.myForm.blind_length_fraction.value = "0.000";



	}



	



	if(wid != "" && len != "")



	{



		wid = parseInt(wid);



		if(wid < min_width || wid > max_width || isNaN(wid))



		{



			alert("Please enter the correct Blind Width.");



			document.myForm.blind_width.focus();



			return false;



		}



		wid = wid + parseFloat(document.myForm.blind_width_fraction.value);



	



		len = parseInt(len);



		if(len < min_length || len > max_length || isNaN(len))



		{



			alert("Please enter the correct Blind Length.");



			document.myForm.blind_length.focus();



			return false;



		}



		len = len + parseFloat(document.myForm.blind_length_fraction.value);



	



		var get_url = url + "?width=" + wid + "&length=" + len;



		loadXMLDoc(get_url, setQuote, false);



	}



}







function setQuote() 



{



	var quote = resultXML;



	quote = quote.split("|");




//	Sunrise Wood	



	document.getElementById("twopaints").innerHTML = quote[0];



	document.getElementById("twostains").innerHTML = quote[1];



	document.getElementById("twotextured").innerHTML = quote[2];



	document.getElementById("onewood").innerHTML = quote[3];
	document.getElementById("shutterblind_normal").innerHTML = quote[4];
	document.getElementById("shutterblind_routeless").innerHTML = quote[5];



}







function loadXMLDoc(url, callFunc, ignoreWhite) 



{



	functionToCall = callFunc;



	stripWS = ignoreWhite;



	xmlRequestObj = window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP")



	xmlRequestObj.onreadystatechange = proccessXML;



	xmlRequestObj.open("GET", url, true);



	xmlRequestObj.send(null);



}







function is_ws(nod) 



{



	return !(/[^\t\n\r ]/.test(nod.data));



}







function findWhiteSpace(node, nodeNo) 



{



	for (i=0; i<node.childNodes.length; i++) 



	{



		if (node.childNodes[i].nodeType == 3 && is_ws(node.childNodes[i])) 



		{



			nodesToDelete[nodesToDelete.length] = node.childNodes[i]



		}



		if (node.childNodes[i].hasChildNodes()) 



		{



			findWhiteSpace(node.childNodes[i], i);



		}



	}



	node = node.parentNode;



	i = nodeNo;



}







function stripWhiteSpace(node) 



{



	nodesToDelete = Array();



	findWhiteSpace(node, 0);



	for(i=nodesToDelete.length-1;i>=0;i--) 



	{



		nodeRef = nodesToDelete[i];



		nodeRef.parentNode.removeChild(nodeRef)



	}



}







function proccessXML() 



{



	if (xmlRequestObj.readyState == 4 && (xmlRequestObj.status == 200 || xmlRequestObj.status == 304)) 



	{



		if(stripWS) 



		{



			stripWhiteSpace(xmlRequestObj.responseText);



		}



		resultXML = xmlRequestObj.responseText;



		functionToCall()



	}



}



