// JavaScript Document

/*             GLOBAL VARIABLES          */

var LATEST_REQUEST_TIME;
var oldMe;


/*         END GLOBAL VARIABLES          */

function getRequestObject(){
try
	{
		xmlhttp = new XMLHttpRequest();
		//alert("Using XMLHttpRequest Object");
	}
	catch(err1)
	{
		var ieXmlHttpVersions = new Array();
		ieXmlHttpVersions[ieXmlHttpVersions.length] = "MSXML2.XMLHttp.6.0";
		ieXmlHttpVersions[ieXmlHttpVersions.length] = "MSXML2.XMLHttp.5.0";
		ieXmlHttpVersions[ieXmlHttpVersions.length] = "MSXML2.XMLHttp.4.0";
		ieXmlHttpVersions[ieXmlHttpVersions.length] = "MSXML2.XMLHttp.3.0";
		ieXmlHttpVersions[ieXmlHttpVersions.length] = "MSXML2.XMLHttp";
		ieXmlHttpVersions[ieXmlHttpVersions.length] = "Microsoft.XMLHttp";
		
		var i;
		for (i=0; i < ieXmlHttpVersions.length; i++)
		{
			try
			{
				var xmlhttp = new ActiveXObject(ieXmlHttpVersions[i]);
				//alert("Using " + ieXmlHttpVersions[i]);
				//break;
			}
			catch (err2)
			{
				alert(ieXmlHttpVersions[i] + " not supported.");
			}
		}
	};
	return xmlhttp;
};

	function getValidPos(me){
			if (me==oldMe){
				return
			}
			oldMe=me;
			xmlhttp = getRequestObject();
			if (typeof xmlhttp == "undefined"){
				alert("XMLHttp cannot be created!");
			} else {
				xmlhttp.open("GET", "positionnumber_xml.asp?dummy=" + new Date().getTime());
				//alert("TEST");
				xmlhttp.onreadystatechange=function(){
				//alert(xmlhttp.readyState)
					if(xmlhttp.readyState==4 && xmlhttp.status==200){
						//createAreaRows();
						//alert("it works")
						
						var xmlDocument = xmlhttp.responseXML;
						var zipRoot = xmlDocument.documentElement;
						var zips = xmlDocument.getElementsByTagName("position");
						var zipCount = zips.length;
						//alert(zipCount)
						for (var i = 0;i<zipCount;i++){
							if (me==zips[i].childNodes[0].nodeValue){
								document.getElementById("frmSubmitBtn").disabled=true;
								alert("You cannot apply for this position using this form")
								
								//return false;
								break;
							}else{
								document.getElementById("frmSubmitBtn").disabled=false;
							}	
						}
						//alert(zips[0].childNodes[0].nodeValue);
						//var divisor = document.getElementById("zipCount").value;
						//var rowCount = roundNumber(divisor / 5);
						//var tbl = document.getElementById("zipTable");
						//var tbody = tbl.getElementsByTagName("tbody")[0];
						//var tbody = tbl.tBodies[0];
						/*for(var i=0;i<rowCount;i++){
							var row = document.createElement("tr");
							row.setAttribute("id", "tr"+i);
							var jumper = i;
							for(var j=0;j<5;j++){
								if (jumper>i){jumper=jumper+rowCount-1;};
								if (jumper >= divisor - 1) {break};
								var zip = document.createElement("td");
								var check = document.createElement("input");
								var currentZip = zips[jumper].childNodes[0].nodeValue
								check.setAttribute("type", "checkbox");
								check.setAttribute("class", "zipcodes");//Mozilla
								check.setAttribute("className", "zipcodes");//IE
								check.setAttribute("name", currentZip);
								check.setAttribute("id", currentZip);
								check.setAttribute("value", currentZip);
								check.setAttribute("onclick", "getChecked()");
								check.onclick = function(){getChecked();};
								zip.appendChild(check)
								var text = document.createTextNode(" " + currentZip);
								zip.appendChild(text);
								jumper = jumper + 1
								row.appendChild(zip);
								//zip.setAttribute("", "");
							};//for(var j=0;j<5;j++){
							tbody.appendChild(row);
							tbl.appendChild(tbody);
						};//for(var i=0;i<rowCount;i++){*/
					};//if(xmlhttp.readyState==4 && xmlhttp.status==200){
				}//xmlhttp.onreadystatechange=function(){
				xmlhttp.send(null);
			};//if (typeof xmlhttp == "undefined"){
			
		};//function createRows(){

