﻿

drawProductSelect.allProductsValues = new Array("capplan_sewer","capplan_water","capplan_xl","floodworks","h2ocalc","h2omap_sewer","h2omap_surge","h2omap_swmm","h2omap_swmm_pdm","h2omap_swmm_rdii","h2omap_water","h2omap_water_pzm","h2onet","h2onet_pzm","h2osurge","infonet","infonet_mobile","infosewer","infosurge","infoswmm","infoswmm_pdm","infoswmm_rdii","infowater","infowater_ldm","infowater_pzm","infowater_slm","infowater_udf","eval_infoworks","infoworks_cs","infoworks_icm","infoworks_rs","free_infoworks_rs","infoworks_sd","infoworks_ws","netview","pipeplan","licence_server","sustainability","swmm_converter","network_driver","standalone_driver");
drawProductSelect.allProductsNames = new Array("CapPlan Sewer","CapPlan Water","CapPlan XL","FloodWorks","H2OCalc","H2OMAP Sewer","H2OMAP Surge","H2OMAP SWMM","H2OMAP SWMM PDM","H2OMAP SWMM RDII","H2OMAP Water","H2OMAP Water PZM","H2ONET","H2ONET PZM","H2OSurge","InfoNet","InfoNet Mobile","InfoSewer","InfoSurge","InfoSWMM","InfoSWMM PDM","InfoSWMM RDII","InfoWater","InfoWater LDM","InfoWater PZM","InfoWater SLM","InfoWater UDF","Infoworks Evaluation","InfoWorks CS","InfoWorks ICM","InfoWorks RS","InfoWorks RS Free Edition","InfoWorks SD","InfoWorks WS","NetVIEW","PipePlan","Stand-alone Floating Licence Server","Sustainability","SWMM Converter","Workgroup Network Dongle Driver","Workgroup Stand-alone Dongle Driver");
drawProductSelect.waterProductsValues = new Array("h2omap_surge","h2omap_water","h2omap_water_pzm","h2onet","h2onet_pzm","h2osurge","infosurge","infowater","infowater_ldm","infowater_pzm","infowater_slm","infowater_udf","eval_infoworks","infoworks_ws","sustainability");
drawProductSelect.waterProductsNames = new Array("H2OMAP Surge","H2OMAP Water","H2OMAP Water PZM","H2ONET","H2ONET PZM","H2OSurge","InfoSurge","InfoWater","InfoWater LDM","InfoWater PZM","InfoWater SLM","InfoWater UDF","Infoworks Evaluation","InfoWorks WS","Sustainability");
drawProductSelect.wasteProductsValues = new Array("h2omap_sewer","h2omap_swmm","h2omap_swmm_pdm","h2omap_swmm_rdii","infosewer","infoswmm","infoswmm_pdm","infoswmm_rdii","eval_infoworks","infoworks_cs","infoworks_icm","swmm_converter")
drawProductSelect.wasteProductsNames = new Array("H2OMAP Sewer","H2OMAP SWMM","H2OMAP SWMM PDM","H2OMAP SWMM RDII","InfoSewer","InfoSWMM","InfoSWMM PDM","InfoSWMM RDII","Infoworks Evaluation","InfoWorks CS","InfoWorks ICM","SWMM Converter")
drawProductSelect.riversProductsValues = new Array("floodworks","infoworks_icm","infoworks_rs","free_infoworks_rs","infoworks_sd","eval_infoworks")
drawProductSelect.riversProductsNames = new Array("FloodWorks","InfoWorks ICM","InfoWorks RS","InfoWorks RS Free Edition","InfoWorks SD","Infoworks Evaluation")
drawProductSelect.assetProductsValues = new Array("capplan_sewer","capplan_water","capplan_xl","infonet","infonet_mobile")
drawProductSelect.assetProductsNames = new Array("CapPlan Sewer","CapPlan Water","CapPlan XL","InfoNet","InfoNet Mobile")
drawProductSelect.pipeProductsValues = new Array("pipeplan")
drawProductSelect.pipeProductsNames = new Array("PipePlan")
drawProductSelect.specialityProductsValues = new Array("h2ocalc","netview")
drawProductSelect.specialityProductsNames = new Array("H2OCalc","NetVIEW")
drawProductSelect.evalProductsValues = new Array("eval_infoworks","free_infoworks_rs")
drawProductSelect.evalProductsNames = new Array("InfoWorks Evaluation","InfoWorks RS Free Edition")
drawProductSelect.utilitiesValues = new Array("licence_server","network_driver","standalone_driver")
drawProductSelect.utilitiesNames = new Array("Stand-alone Floating Licence Server","Workgroup Network Dongle Driver","Workgroup Stand-alone Dongle Driver")


var username = "";
var password = "";
var theProduct = "";
var theParent = "";
var codeType = "";

function drawProductSelect(theList){

    selectHtml = ""
    selectHtml = selectHtml + "<select size='11' style='width:300px;' onclick='productSelect(this);' onchange='productSelect(this);'>";
    for (i=0;i<drawProductSelect[theList+"Values"].length;i++){
        selectHtml = selectHtml + "<option value='" + drawProductSelect[theList+"Values"][i] + "' "
        if (theProduct == drawProductSelect[theList+"Values"][i]){
            selectHtml = selectHtml + " selected=selected";
        }
        selectHtml = selectHtml + ">"  + drawProductSelect[theList+"Names"][i] + "</option>";
    }
    selectHtml = selectHtml + "</select>";
    
    if (document.getElementById){
        document.getElementById("productSelect").innerHTML = selectHtml;
        
    }

    if (theProduct != ""){
        getDetail();    
    }
}

function areaSelect(theObject){
    drawProductSelect(theObject.value);
}


function productSelect(theList){
   theProduct = theList.value;
   codeType = "primary";
   getDetail();
}

function versionLink(theLink){
    theParent = theProduct;
    theProduct = theLink;
    codeType = "secondary";
    getDetail();
}

function parentProduct(){
    theProduct = theParent
    codeType = "primary"
    getDetail();
}

function getDetail(){
    
      
    
     toSend = "user=" + username + "&pass=" + password + "&code=" + theProduct + "&type=" + codeType
     
    
     if (window.XMLHttpRequest){
         // browser has native support for XMLHttpRequest object
         req = new XMLHttpRequest();
     }
     else if (window.ActiveXObject){
         // try XMLHTTP ActiveX (Internet Explorer) version
         req = new ActiveXObject("Microsoft.XMLHTTP");
     }
     
     if(req){
		 req.onreadystatechange = detailResponse;
         req.open("POST", "/updates/detail.aspx", true);
         req.setRequestHeader("content-type","application/x-www-form-urlencoded");
         req.send(toSend);
     }
     else{
         alert('Your browser does not seem to support XMLHttpRequest.');
     }
     
}


function detailResponse(){


	if (req.readyState == 4) {
   		if (req.status == 200) {
   		    if (req.responseText != ""){
   			    document.getElementById("updatesDisplay").innerHTML =  req.responseText;
   			}
		} else {
		    // there was a problem with the request
		}
	} else {
   		// still not ready
	}
}

function passKeyCheck(e,theField){
    password = theField.value;
    if (e.keyCode){
        if (e.keyCode == 13){
            getDetail();
        }
    }
}