function getNumbers()
{

	try {

		objXMLHTTP = new XMLHttpRequest();

	} catch(e) {

		objXMLHTTP = new ActiveXObject('Microsoft.XMLHTTP');

	}

    try {
    
	objXMLHTTP.onreadystatechange = GetCount;
	    objXMLHTTP.open('POST', 'http://fishandgame.idaho.gov/ifwis/hdms/SteelheadCounts/service.asmx', true);
	    objXMLHTTP.setRequestHeader('SOAPAction','http://fishandgame.idaho.gov/hdms/SendData');
	    objXMLHTTP.setRequestHeader('Content-Type','text/xml');
	    objXMLHTTP.send(buildSoap('Everything'));



	} catch(e) {
	
	    alert('Code failed ' + e.message);
	
	}
	

	    function buildSoap(IWant) {
	
	        var strSOAP = '<?xml version="1.0" encoding="utf-8"?>';
	        strSOAP += '<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">';
	        strSOAP += '<soap12:Body>';
	        strSOAP += '<SendData xmlns="http://fishandgame.idaho.gov/hdms">';
	        strSOAP += '<Iwant>' + IWant + '</Iwant>';
	        strSOAP += '</SendData>';
	        strSOAP += '</soap12:Body>';
	        strSOAP += '</soap12:Envelope>';
            return strSOAP;

	    }

	    function GetCount() {
	
	        if (objXMLHTTP.readyState == 4) {
	        
	            var myXML = objXMLHTTP.responseText;
	            parseXML(myXML);
	    
	        }
	    }

	function parseXML(myXML) {

	    var found = false;
	    var junk = myXML.split(">");
        junk = junk[5].split("<");
        var line = junk[0];
    	//alert('Line is ' + line);
	    junk = line.split(",");
	    var totalh = 0;
	    var totaln = 0;
	    var dd = junk[0];
	    if (dd != "1/1/0001") found = true;
	    var dh = junk[1];
	    var dn = junk[2];
	    var crd = junk[3];
	    if (crd != "1/1/0001") found = true;
	    var crh = junk[4];
	    var crn = junk[5];
	    var redd = junk[6];
	    if (redd != "1/1/0001") found = true;
	    var redh = junk[7];
	    var redn = junk[8];
	    var kd = junk[9];
	    if (kd != "1/1/0001") found = true;
	    var kh = junk[10];
	    var kn = junk[11];
	    var od = junk[12];
	    if (od != "1/1/0001") found = true;
	    var oh = junk[13];
	    var on = junk[14];
	    var pd = junk[15];
	    if (pd != "1/1/0001") found = true;
	    var ph = junk[16];
	    var pn = junk[17];
	    var rrd = junk[18];
	    if (rrd != "1/1/0001") found = true;
	    var rrh = junk[19];
	    var rrn = junk[20];
	    var sd = junk[21];
	    if (sd != "1/1/0001") found = true;
	    var sh = junk[22];
	    var sn = junk[23];
	    var efd = junk[24];
	    if (efd != "1/1/0001") found = true;
	    var efh = junk[25];
	    var efn = junk[26];
	    var sqd = junk[27];
	    if (sqd != "1/1/0001") found = true;
	    var sqh = junk[28];
	    var sqn = junk[29];

	    if (!found) {

	        alert("No steelhead have been trapped yet for 2011");
	        return;

	    }

        // Crooked River

	    if (crd != "1/1/0001") document.getElementById('crd').innerHTML = crd;
	    var nf = new NumberFormat(crh);
	    nf.setPlaces(0);
	    nf.setCommas(true);
	    var num = nf.toFormatted();
	    totalh = totalh + parseInt(crh);
        document.getElementById('crh').innerHTML=num;
        nf = new NumberFormat(crn);
        nf.setPlaces(0);
        nf.setCommas(true);
        num = nf.toFormatted();
        totaln = totaln + parseInt(crn);
        document.getElementById('crn').innerHTML = num;
        if (parseInt(crh) > 0 || parseInt(crn) > 0) document.getElementById('crl').innerHTML = '<a href="http://fishandgame.idaho.gov/ifwis/hdms/steelhead/charts.html?site=Crooked%20River&rid=30">Crooked River</a>';

        // Dworshak

        if (dd != "1/1/0001") document.getElementById('dd').innerHTML = dd;
        nf = new NumberFormat(dh);
        nf.setPlaces(0);
        nf.setCommas(true);
        num = nf.toFormatted();
        totalh = totalh + parseInt(dh);
        document.getElementById('dh').innerHTML = num;
        nf = new NumberFormat(dn);
        nf.setPlaces(0);
        nf.setCommas(true);
        num = nf.toFormatted();
        totaln = totaln + parseInt(dn);
        document.getElementById('dn').innerHTML = num;
        if (parseInt(dh) > 0 || parseInt(dn) > 0) document.getElementById('dl').innerHTML = '<a href="http://fishandgame.idaho.gov/ifwis/hdms/steelhead/charts.html?site=Dworshak&rid=32">Dworshak Hatchery Trap</a>';

        // East Fork

        if (efd != "1/1/0001") document.getElementById('efd').innerHTML = efd;
        nf = new NumberFormat(efh);
        nf.setPlaces(0);
        nf.setCommas(true);
        num = nf.toFormatted();
        totalh = totalh + parseInt(efh);
        document.getElementById('efh').innerHTML = num;
        nf = new NumberFormat(efn);
        nf.setPlaces(0);
        nf.setCommas(true);
        num = nf.toFormatted();
        totaln = totaln + parseInt(efn);
        document.getElementById('efn').innerHTML = num;
        if (parseInt(efh) > 0 || parseInt(efn) > 0) document.getElementById('efl').innerHTML = '<a href="http://fishandgame.idaho.gov/ifwis/hdms/steelhead/charts.html?site=East%20Fork&rid=46">East Fork Salmon River Trap</a>';

        // Kooskia

        if (kd != "1/1/0001") document.getElementById('kd').innerHTML = kd;
        nf = new NumberFormat(kh);
        nf.setPlaces(0);
        nf.setCommas(true);
        num = nf.toFormatted();
        totalh = totalh + parseInt(kh);
        document.getElementById('kh').innerHTML = num;
        nf = new NumberFormat(kn);
        nf.setPlaces(0);
        nf.setCommas(true);
        num = nf.toFormatted();
        totaln = totaln + parseInt(kn);
        document.getElementById('kn').innerHTML = num;
        if (parseInt(kh) > 0 || parseInt(kn) > 0) document.getElementById('kl').innerHTML = '<a href="http://fishandgame.idaho.gov/ifwis/hdms/steelhead/charts.html?site=Kooskia&rid=33">Kooskia Hatchery Trap</a>';

        // Oxbow

        if (od != "1/1/0001") document.getElementById('od').innerHTML = od;
        nf = new NumberFormat(oh);
        nf.setPlaces(0);
        nf.setCommas(true);
        num = nf.toFormatted();
        totalh = totalh + parseInt(oh);
        document.getElementById('oh').innerHTML = num;
        nf = new NumberFormat(on);
        nf.setPlaces(0);
        nf.setCommas(true);
        num = nf.toFormatted();
        totaln = totaln + parseInt(on);
        document.getElementById('on').innerHTML = num;
        if (parseInt(oh) > 0 || parseInt(on) > 0) document.getElementById('ol').innerHTML = '<a href="http://fishandgame.idaho.gov/ifwis/hdms/steelhead/charts.html?site=Hells%20Canyon/Oxbow&rid=31">Hells Canyon/Oxbow Dam Trap</a>';

        // Pahsimeroi

        if (pd != "1/1/0001") document.getElementById('pd').innerHTML = pd;
        nf = new NumberFormat(ph);
        nf.setPlaces(0);
        nf.setCommas(true);
        num = nf.toFormatted();
        totalh = totalh + parseInt(ph);
        document.getElementById('ph').innerHTML = num;
        nf = new NumberFormat(pn);
        nf.setPlaces(0);
        nf.setCommas(true);
        num = nf.toFormatted();
        totaln = totaln + parseInt(pn);
        document.getElementById('pn').innerHTML = num;
        if (parseInt(ph) > 0 || parseInt(pn) > 0) document.getElementById('pl').innerHTML = '<a href="http://fishandgame.idaho.gov/ifwis/hdms/steelhead/charts.html?site=Pahsimeroi&rid=23">Pahsimeroi Hatchery Trap</a>';

        // Rapid River

        if (rrd != "1/1/0001") document.getElementById('rrd').innerHTML = rrd;
        nf = new NumberFormat(rrh);
        nf.setPlaces(0);
        nf.setCommas(true);
        num = nf.toFormatted();
        totalh = totalh + parseInt(rrh);
        document.getElementById('rrh').innerHTML = num;
        nf = new NumberFormat(rrn);
        nf.setPlaces(0);
        nf.setCommas(true);
        num = nf.toFormatted();
        totaln = totaln + parseInt(rrn);
        document.getElementById('rrn').innerHTML = num;
        if (parseInt(rrh) > 0 || parseInt(rrn) > 0) document.getElementById('rrl').innerHTML = '<a href="http://fishandgame.idaho.gov/ifwis/hdms/steelhead/charts.html?site=Rapid%20River&rid=53">Rapid River Hatchery Trap</a>';

        // Red River

        if (redd != "1/1/0001") document.getElementById('redd').innerHTML = redd;
        nf = new NumberFormat(redh);
        nf.setPlaces(0);
        nf.setCommas(true);
        num = nf.toFormatted();
        totalh = totalh + parseInt(redh);
        document.getElementById('redh').innerHTML = num;
        nf = new NumberFormat(redn);
        nf.setPlaces(0);
        nf.setCommas(true);
        num = nf.toFormatted();
        totaln = totaln + parseInt(redn);
        document.getElementById('redn').innerHTML = num;
        if (parseInt(redh) > 0 || parseInt(redn) > 0) document.getElementById('redl').innerHTML = '<a href="http://fishandgame.idaho.gov/ifwis/hdms/steelhead/charts.html?site=Red%20River&rid=29">Red River Trap</a>';

        // Sawtooth

        if (sd != "1/1/0001") document.getElementById('sd').innerHTML = sd;
        nf = new NumberFormat(sh);
        nf.setPlaces(0);
        nf.setCommas(true);
        num = nf.toFormatted();
        totalh = totalh + parseInt(sh);
        document.getElementById('sh').innerHTML = num;
        nf = new NumberFormat(sn);
        nf.setPlaces(0);
        nf.setCommas(true);
        num = nf.toFormatted();
        totaln = totaln + parseInt(sn);
        document.getElementById('sn').innerHTML = num;
        if (parseInt(sh) > 0 || parseInt(sn) > 0) document.getElementById('sl').innerHTML = '<a href="http://fishandgame.idaho.gov/ifwis/hdms/steelhead/charts.html?site=Sawtooth&rid=21">Sawtooth Hatchery Trap</a>';

        // Squaw Creek

        if (sqd != "1/1/0001") document.getElementById('sqd').innerHTML = sqd;
        nf = new NumberFormat(sqh);
        nf.setPlaces(0);
        nf.setCommas(true);
        num = nf.toFormatted();
        totalh = totalh + parseInt(sqh);
        document.getElementById('sqh').innerHTML = num;
        nf = new NumberFormat(sqn);
        nf.setPlaces(0);
        nf.setCommas(true);
        num = nf.toFormatted();
        totaln = totaln + parseInt(sqn);
        document.getElementById('sqn').innerHTML = num;
        if (parseInt(sqh) > 0 || parseInt(sqn) > 0) document.getElementById('sql').innerHTML = '<a href="http://fishandgame.idaho.gov/ifwis/hdms/steelhead/charts.html?site=Squak%20Creek&rid=56">Squaw Creek Trap</a>';

        // Publish Totals

        nf = new NumberFormat(totalh);
        nf.setPlaces(0);
        nf.setCommas(true);
        num = nf.toFormatted();
        document.getElementById('toth').innerHTML = num;
        nf = new NumberFormat(totaln);
        nf.setPlaces(0);
        nf.setCommas(true);
        num = nf.toFormatted();
        document.getElementById('totn').innerHTML = num;
        
    }
}


function getDetails(recordid) {


try {

		objXMLHTTP = new XMLHttpRequest();

	} catch(e) {

		objXMLHTTP = new ActiveXObject('Microsoft.XMLHTTP');

	}

    try {
    
	objXMLHTTP.onreadystatechange = GetCount;
	    objXMLHTTP.open('POST', 'http://fishandgame.idaho.gov/ifwis/hdms/SteelheadCounts/service.asmx', true);
	    objXMLHTTP.setRequestHeader('SOAPAction','http://fishandgame.idaho.gov/hdms/GetDetails');
	    objXMLHTTP.setRequestHeader('Content-Type','text/xml');
	    objXMLHTTP.send(buildSoap(recordid));



	} catch(e) {
	
	    alert('Code failed ' + e.message);
	
	}
	

	    function buildSoap(IWant) {
	
	        var strSOAP = '<?xml version="1.0" encoding="utf-8"?>';
	        strSOAP += '<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">';
	        strSOAP += '<soap12:Body>';
	        strSOAP += '<GetDetails xmlns="http://fishandgame.idaho.gov/hdms">';
	        strSOAP += '<ID>' + recordid + '</ID>';
	        strSOAP += '</GetDetails>';
	        strSOAP += '</soap12:Body>';
	        strSOAP += '</soap12:Envelope>';

            return strSOAP;

	    }

	    function GetCount() {
	
	        if (objXMLHTTP.readyState == 4) {
	        
			
	            var responseText = objXMLHTTP.responseText;
		alert(responseText);
		var parents = responseText.split(">");
		var details = parents[5].split("<");
		alert(details[0]);
		var detail = details[0];	
return detail;
	        }
	    }
}

