﻿// JScript File
function toggleFooter()
{
    //document.getElementById('Master1_MainContent_TextBox1').innerText='howdy';
    if(document.getElementById("footer").style.visibility!="hidden")
    {
        document.getElementById("footer").style.visibility="hidden";
    }
    else
    {
        document.getElementById("footer").style.visibility="visible";
    }
}
//window.onload=function(){alert("howdy");}

function howdy()
{
    alert("howdy");
}
function OpenSearchHelp()
{
    window.open("SearchHelp.aspx","myHELPwindow","status=0,menubar=0, toolbar=0, location=0,scrollbars=1,width=650,height=500");
}
//feed in the filename such as "Help_ChooseApp.aspx"
function Open_Help_ChooseApp(filename)
{
    window.open(filename,"myHELPwindow","status=0,menubar=0, toolbar=1, location=0,scrollbars=1,width=700,height=500,resizable=1");
    //window.open("Help_ChooseApp.aspx","myHELPwindow","status=0,menubar=0, toolbar=0, location=0,scrollbars=1,width=600,height=500");
}
function Open_Window(filename)
{
    window.open(filename,"myWindow","status=0,menubar=0, toolbar=0, location=0,scrollbars=1,width=650,height=500, resizable=1");
    //window.open("Help_ChooseApp.aspx","myHELPwindow","status=0,menubar=0, toolbar=0, location=0,scrollbars=1,width=600,height=500");
}
function ClearSearchControls(pagePrefix)
{
    //document.getElementById("ctl00_MainContent_cbHubCode").value="";
    for (row = 0; row < arr.length; ++row)
    {
        document.getElementById(pagePrefix + arr[row]).value="";
    }
    document.getElementById(pagePrefix + "cbIPY").selectedIndex=0;
    document.getElementById(pagePrefix + "cbReportType").selectedIndex=0;
    //this to handle Mozilla to reset HUBCode and SubRegion dropdowns
    document.getElementById(pagePrefix + "cbHUBCode").selectedIndex=0;
    document.getElementById(pagePrefix + "cbSubRegion").selectedIndex=0;
}
 
var arr=new Array('cbHUBCode', 'txtRegion',
'cbSubRegion', 'txtSubRegion',
'cbFieldLocation', 'txtFieldLocation',
'cbFieldSeasonCode', 'txtFieldSeasonCode', 
'cbAgency', 'txtAgency', 
'cbDiscipline', 'txtDiscipline', 
'cbPropNum', 'txtPropNum', 
'PersonID', 'txtPI', 
'cbInstitute', 'txtInstitute',
'cbIPY', 'cbReportType');   //,'chkIPY');
     
function OpenReport(pagePrefix)
{
   
   //alert("Report will be opened");
 /* 
    var arr=new Array('cbHUBCode', 'txtRegion',
    'cbSubRegion', 'txtSubRegion',
    'cbFieldLocation', 'txtFieldLocation',
    'cbFieldSeasonCode', 'txtFieldSeasonCode', 
    'cbAgency', 'txtAgency', 
    'cbDiscipline', 'txtDiscipline', 
    'cbPropNum', 'txtPropNum', 
    'PersonID', 'txtPI', 
    'cbInstitute', 'txtInstitute',
    'cbIPY');   //,'chkIPY');
  */ 
	var arrPass =  new Array();
	var qryStr='';
	var valEntered='';
	var sMsg='';
	var ipy='';
	var iSelected=0; //variable to count the number of items selected by the user
	for (row = 0; row < arr.length; ++row)
	{
	    if (document.getElementById(pagePrefix + arr[row]).value.length>0)
	    {
            if(arr[row].indexOf("chkIPY")==0)
            {
                arrPass.push(arr[row] + '=' + document.getElementById(pagePrefix + arr[row]).checked);
                
            }
            else
            {
                valEntered=document.getElementById(pagePrefix + arr[row]).value;
                arrPass.push(arr[row] + '=' + valEntered);
                if (valEntered.length>0 && valEntered != " ") //cbHUBCode and cbSubRegion always show as " " as a minimum
                {
                    iSelected+=1;
                    sMsg += arr[row] + '="' + valEntered + '" ,';
                    if (arr[row]=='cbIPY')
                        ipy=valEntered;
                }
            }

        }
	}
	//cbHUBCode (1-space), cbSubRegion (1-space), cbIPY & cbReportType
	//alert("user entered data for " + iSelected + " controls: " + sMsg);
	if(iSelected<3 && (ipy=='-1' || ipy=='0'))
	//if(iSelected<5)
	{
	    //alert("ipy=" + ipy);
	    var answer = confirm ("Running without a filter will return a very large dataset and may take quite a while to download your report.\nWould you like to continue (click OK)\nor cancel (click CANCEL) - to make a filter selection to limit the amount of data to be returned?")
        if (! answer)   //user chose to cancel
            return 
    }
	for (row = 0; row < arrPass.length; ++row)
	{
	    //alert(arrPass[row]);
	    /**/
	    if(row==0)
	    {
	        qryStr = qryStr  + '?' + arrPass[row];  
	    }
	    else
	    {
	        qryStr = qryStr  + '&' + arrPass[row];
	    }
	    if(arrPass[row].indexOf("cbFieldLocation")==0)
	    {
	        //alert("cbFieldLocation found, adding ;");
	        qryStr=qryStr + ';';
	    }
	}
	//alert(qryStr);
	//return;
    var str = '';
	str += 'http://www.polar.ch2m.com/arlss_reports/arlss_projectsdetail.aspx' + qryStr //the ARLSS report on vecopolar.com
	//str += 'http://localhost/VECOPOLAR/arlss_reports/arlss_projectsdetail.asp' + qryStr
	//str += 'arlss_projectsdetail.asp' + qryStr
	
	//str += 'ARLSS_Report.aspx' + qryStr   //this site's ARLSS Report

	//Response.Write(str);
	//str += '?PersonID=' + document.getElementById('ctl00_MainContent_PersonID').value;
	window.open(str,"MapWindow","resizable=1,status=1,menubar=1, toolbar=1, location=1,scrollbars=1,width=800,height=500");
}
    /********menu image control code********/
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}
//Note: had to fix and code differently for the "links" images as they were 1px off for Mozilla,
//although worked and aligned perfectly for IE. 
//Note image files links_rev1, links-over_rev1 and links-down_rev1 in following code.
function changeImages() {

	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
            if(changeImages.arguments[i].indexOf("home")>=0 
            && window.location.href.toLowerCase().indexOf("home.aspx")>0)
                return false;
            if(changeImages.arguments[i].indexOf("demo")>=0 
            && window.location.href.toLowerCase().indexOf("demo.aspx")>0)
                return false;
            if(changeImages.arguments[i].indexOf("gallery")>=0 
            && window.location.href.toLowerCase().indexOf("mapgallery.aspx")>0)
                return false;
            if(changeImages.arguments[i].indexOf("search")>=0 
            && window.location.href.toLowerCase().indexOf("search.aspx")>0)
                return false;
            //101310
            if (changeImages.arguments[i].indexOf("services") >= 0
            && window.location.href.toLowerCase().indexOf("services.aspx") > 0)
                return false;
            if(changeImages.arguments[i].indexOf("links")>=0 
            && window.location.href.toLowerCase().indexOf("links.aspx")>0)
                return false;
            if(changeImages.arguments[i].indexOf("credits")>=0 
            && window.location.href.toLowerCase().indexOf("credits.aspx")>0)
                return false;
            if(changeImages.arguments[i].indexOf("contact")>=0 
            && window.location.href.toLowerCase().indexOf("contact.aspx")>0)
                return false;
            

//            if(changeImages.arguments[i].indexOf("links")>=0  && !document.all)
//            {
////                if(changeImages.arguments[i+1].indexOf("links-over")>0)
////                {
//                    document.images["links"].src="images/links-over.gif";
////                }
////                else
////                {
////                    document.images["links"].src="images/links_rev1.gif";
////                }
//                return false;
//            }
                   		
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}



//function changeImages() {
//    //alert('x' + changeImages.arguments[0] + 'x');
//    //alert('x' + changeImages.arguments[2] + 'x');
//	//if (document.images && (preloadFlag == true)) {
//	if(changeImages.arguments[0]!=changeImages.arguments[2])
//	{
//	    //alert("Changing images");
//	    if (document.images) {
//	        document[changeImages.arguments[0]].src = changeImages.arguments[1];
//		    //for (var i=0; i<changeImages.arguments.length; i+=2) {
//		    //	document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
//		    //}
//	    }
//	}
//}

var preloadFlag = false;
function preloadImages() {

        //return;
	if (document.images) {
		home_over = newImage("images/home-over.gif");
		home_down = newImage("images/home-down.gif");
		demo_over = newImage("images/demo-over.gif");
		demo_down = newImage("images/demo-down.gif");
		gallery_over = newImage("images/gallery-over.gif");
		gallery_down = newImage("images/gallery-down.gif");
		search_over = newImage("images/search-over.gif");
		search_down = newImage("images/search-down.gif");
		//101310
		webservices_over = newImage("images/webservices-over.gif");
		webservices_down = newImage("images/webservices-down.gif");		
//		var browserName=navigator.appName;
//		//alert(browserName);
//		//if(document.all)
//		if(browserName=="Microsoft Internet Explorer")
//		{
		    links_over = newImage("images/links-over.gif");
		    links_down = newImage("images/links-down.gif");
//		    document.images["links"].src="images/links.gif"
//		}
//		else
//		{
//		    links_over = newImage("images/links-over_rev1.gif");
//		    links_down = newImage("images/links-down_rev1.gif");
//		    document.images["links"].src="images/links_rev1.gif"
//		}
		credits_over = newImage("images/credits-over.gif");
		credits_down = newImage("images/credits-down.gif");
		contact_over = newImage("images/contact-over.gif");
		contact_down = newImage("images/contact-down.gif");
		preloadFlag = true;
		var page=window.location.href;
        if (page.toLowerCase().indexOf("home.aspx")>0)
        {
            document.images["home"].src="images/home-down.gif";
        }
        if (page.toLowerCase().indexOf("demo.aspx")>0)
        {
            //alert(document.location.href);
            document.images["demo"].src="images/demo-down.gif";
        }
        if (page.toLowerCase().indexOf("mapgallery.aspx")>0)
        {
            //alert(document.location.href);
            document.images["gallery"].src="images/gallery-down.gif";
        }	
        if (page.toLowerCase().indexOf("search.aspx")>0)
        {
            //alert(document.location.href);
            document.images["search"].src="images/search-down.gif";
        }
        //101310
        if (page.toLowerCase().indexOf("armap_services.aspx") > 0) {
            //alert(document.location.href);
            document.images["webservices"].src = "images/webservices-down.gif";
        }
        
        if (page.toLowerCase().indexOf("links.aspx")>0)
        {
//            if(document.all)
//            {
//                //alert(document.location.href);
                document.images["links"].src="images/links-down.gif";
//            }
//            else
//            {
//                document.images["links"].src="images/links-down_rev1.gif";
//            }
        }
        if (page.toLowerCase().indexOf("credits.aspx")>0)
        {
            //alert(document.location.href);
            document.images["credits"].src="images/credits-down.gif";
        }	
        if (page.toLowerCase().indexOf("contact.aspx")>0)
        {
            //alert(document.location.href);
            document.images["contact"].src="images/contact-down.gif";
        }			
	}
}
/********menu image control code********/

function CheckForJS()
{
    //If browser does not have JavaScript enabled, these buttons will be visible, otherwise hidden
    document.getElementById("btnHUBCode").style.visibility="hidden";
    document.getElementById("btnSubRegion").style.visibility="hidden";
}
