/*dw_main.js*/
/*shared functions for site*/

function buildStateSelect() {
/*this function creates the United States dropdown list*/
var stateList = ["AK","AL","AR","AZ","CA","CO","CT","DC","DE","FL","GA","HI","IA","ID","IL","IN","KS","KY","LA","MA","MD","ME","MI","MN","MO","MS","MT","NC","ND","NE","NH","NJ","NM","NY","NV","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VA","VT","WA","WI","WV","WY"];
document.write("<option value=\"\"></option>");
for (x = 0; x < stateList.length; x++) {
	document.write("<option value=\""+stateList[x]+"\">"+stateList[x]+"</option>");
	}
}
						
function passvalues() {
/* this function passes the contact email address and order id to the payment form*/
/* set the unique order key */
document.dw_orderform.elements['orderkey'].value =  Math.floor(Math.random()* 999999999 );
var basenew = baseurl;
/* pass the values*/
document.dw_orderform.elements['_redirectURL'].value = basenew + "_secure_pay.html?_from_ContactEmail=" + document.dw_orderform.elements['_req,from_ContactEmail'].value + "&orderkey=" + document.dw_orderform.elements['orderkey'].value + "&ServiceOrdered=" + escape(document.dw_orderform.elements['ServiceOrdered'].value) + "&ThanksPage=" + basenew + document.dw_orderform.elements['ThanksPage'].value + "&ThanksText=" + document.dw_orderform.elements['ThanksText'].value;
}

function getParams() {
/*this function passes the values posted to the form into an array named params*/
var idx = document.URL.indexOf('?');
var params = new Array();
if (idx != -1) {
var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
for (var i=0; i<pairs.length; i++) {
nameVal = pairs[i].split('=');
params[nameVal[0]] = nameVal[1];
   }
}
return params;
}

/*the below functions are necessary for the floating left rail to work*/
var ns4 = (document.layers) ? true : false;
var ie4 = (document.all && !document.getElementById) ? true : false;
var ie5 = (document.all && document.getElementById) ? true : false;
var ns6 = (!document.all && document.getElementById) ? true : false;

// if the navigationLayer changes at all, the following three values may need adjusting..

var wHt = 450; // height of window 
var tp = 150; // top margin 
var bt = 110; // bottom margin

var minWin = wHt + bt;
var maxWin = wHt + tp + bt;

// function which positions navigationLayer

		function dw_setLayerPosition() {
			var topLeft = testTop();
		    if (ie5) {
		        document.getElementById("dw_stayput").style.top = (window.pageYOffset ? window.pageYOffset + topLeft : document.body.scrollTop + topLeft);
			} else if (ns6) {
		     	document.getElementById("dw_stayput").style.top = (window.pageYOffset ? window.pageYOffset + topLeft : window.pageYOffset + topLeft + 40);
		    } else if (ns4) {     
				document.layers.dw_stayput.top = window.pageYOffset + topLeft + (tp-50);
		    } else if (ie4) {
				document.all.dw_stayput.style.pixelTop = document.body.scrollTop + topLeft;
		    }
		}

// heres the function which generates the topLeft value:

			function testTop() {
			var aux = 0;
			var win = wHt + bt;
			var topLeft = 150;
			if (ns4 || ns6)  {
				var height = self.innerHeight;
				var maxNum = (ns6) ? document.body.offsetHeight - height + 24 : 0;
				var num = window.pageYOffset;
				var diff = (maxNum > 0) ? maxNum - num : 0;
				var aux = 40;
			} else if (ie4 || ie5) {
				var height = document.body.clientHeight;
				var maxNum = document.body.scrollHeight - height;
				var num = document.body.scrollTop;
				var diff = maxNum - num;
			}
			if (maxNum > 0) {
				if (diff >= (maxNum - tp)) {
					topLeft = tp - aux;
				} else if (diff < bt) {
					topLeft = height - minWin - aux;
				} else {
					if (height <= wHt) {
						topLeft = height - wHt;
					} else if (height > wHt) {
						if ((height - wHt) > tp) {
							topLeft = tp;
						} else {
							topLeft = parseInt((height - wHt) / 2);
						}
					}
				}
			} else if (maxNum == 0) {
				if (height <= minWin) {
					topLeft = height - minWin;
				} else if (height > minWin) {
					d = height - minWin;
						if (d >= tp) {
							topLeft = tp
						} else if (d < tp) {
							topLeft = parseInt(d / 2);
						}
				}
				topLeft = topLeft - 20;
			}
			return topLeft;
			}
			
/*the above functions are necessary for the floating left rail to work*/