// netAJ.js

ajHOST=window.location.hostname;
ajPROTOCOL=window.location.protocol;
ajDOMAIN=ajPROTOCOL+"//"+ajHOST+"/";

function GotAj() {
    return PostGet("GOTAJ","","","","","","","","","","");
}
function PostGet( pgTASK,pgPARAM1,pgPARAM2,pgPARAM3,pgPARAM4,pgPARAM5,pgPARAM6,pgPARAM7,pgPARAM8,pgPARAM9,pgPARAM10 ) {
	pgURL=ajDOMAIN+"netAJ.aspx";
	pgForm="TASK="+pgTASK+"&p1="+pgPARAM1+"&p2="+pgPARAM2+"&p3="+pgPARAM3+"&p4="+pgPARAM4+"&p5="+pgPARAM5+"&p6="+pgPARAM6+"&p7="+pgPARAM7+"&p8="+pgPARAM8+"&p9="+pgPARAM9+"&p10="+pgPARAM10;
	sReturn="";
	try {
    	if(window.XMLHttpRequest) {
		    req=new XMLHttpRequest();
		    req.open("POST",pgURL,false);
		    req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		    req.send(pgForm);
		    sReturn=req.responseText;
	    } else if(window.ActiveXObject) {
    		req=new ActiveXObject("Microsoft.XMLHTTP");
		    if (req) {
    			req.open("POST",pgURL,false);
			    req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			    req.send(pgForm);
			    sReturn=req.responseText;
		    }
	    }
	}
	catch(dwe) { sReturn="N"; }
	if(pgTASK=="GOTAJ" && sReturn=="") { sReturn="N"; }
	//alert(sReturn);
	if( pgTASK=="ADDRESS" ) {
        sAR = sReturn.split("||");
        document.getElementById("xfname").value="";
        document.getElementById("xlname").value="";
        document.getElementById("xemail").value="";
        document.getElementById("xphone").value="";
        document.getElementById("xcell").value="";
        document.getElementById("xaddress").value="";
        document.getElementById("xcity").value="";
        document.getElementById("xstate").value="";
        document.getElementById("xzip").value="";
        document.getElementById("xcountry").value="";
        if( sAR[10]=="1" ) {
            document.getElementById("xfname").value=sAR[0];
            document.getElementById("xlname").value=sAR[1];
            if( sAR[12]=="1" ) {
                document.getElementById("xemail").value=sAR[2];
            }
            if( sAR[14]=="1" ) {
                document.getElementById("xphone").value=sAR[3];
            }
            if( sAR[13]=="1" ) {
                document.getElementById("xcell").value=sAR[4];
            }
            if( sAR[11]=="1" ) {
                document.getElementById("xaddress").value=sAR[5];
                document.getElementById("xcity").value=sAR[6];
                document.getElementById("xstate").value=sAR[7];
                document.getElementById("xzip").value=sAR[8];
                document.getElementById("xcountry").value=sAR[9];
            }
        }
	}
	return sReturn;
}

