﻿// JScript File
  
    function clearText(textBox) 
    { 
		if(textBox.value == "search this site:")
		textBox.value = "";
    }

    function resetText(textBox) 
    {
		if(textBox.value == "")
		textBox.value = "search this site:";
    }
    
    function ShowHideSpan(id)
    {
		if (document.getElementById(id + "span").style.display=="block")
	    {
		document.getElementById(id + "span").style.display="none";
	    }
	else
	    {
		document.getElementById(id + "span").style.display="block";
	    }
    }
    
    function ShowHideDiv(id)
    {
         //alert(id);
		if (document.getElementById(id).style.display=="block")
	    {
		  document.getElementById(id).style.display="none";
	    }
	else
	    {
		  document.getElementById(id).style.display="block";
	    }
    }
    
    
// I have combined multiple functions into one function. This function is called
//  when the 'clear' button is clicked. 
// In addition to clearing text from all text boxes on the form except the Search text box,
//  this function also hides the Validation Div (the div that holds validations error messages)
//  and hides the results label. 
function clearAllTextBoxes(validationDivId) {
    var inputs = document.getElementsByTagName('input');
    
    //clears all text boxes
    for (var i=0; i<inputs.length;i++)
    {
        if (inputs[i].type == "text")
            if (inputs[i].id != "ctl00_txtSearch")
                inputs[i].value = "";
    }
    
    //.NET creates a textarea element for multiline text boxes so
    // check for those just in case
    var textareas = document.getElementsByTagName('textarea');
    for (var i=0; i<textareas.length;i++)
    {
        textareas[i].value = "";
    }
    
    var test = document.getElementById(validationDivId);
    test.style.display = "none";
    
    //this is an asp:label control that describes the result of the submit operation.
    var resultText = document.getElementById("ctl00_ContentPlaceHolder1_result");
    if (!resultText)
        resultText = document.getElementById("result");
    
    if (resultText)
        resultText.style.display = "none";

    return false;
}

//calls onLoad function for various content pages depending on the name of the content page
function load(){ 
    var fileName=FileName() 
    switch (fileName.toUpperCase())
    {
        case 'HOME.ASPX': 
            homeOnLoad();
            break; 
//        case 'FUNDING.ASPX':
//            initial_update();
//            document.getElementById("pD4F").focus();
//            document.getElementById("pD4F").select();
//            break;
    }
}

function FileName() 
{ 
    var fileName = "";
    if (location.href.lastIndexOf('/') !=-1) 
    // Check whether '/' exists. 
    { 
        // If it does then we ... 
        firstpos=location.href.lastIndexOf('/')+1; 

        // Find the first position (the file starts after this) 
        lastpos=location.href.length; 
        /* Normally, the last position of the filename will be at the end of the complete URL - although it could have a # and a name at the end!*/ 
        fileName=location.href.substring(firstpos,lastpos); 
    } 
    return fileName 
} 

function homeOnLoad()
{
    var j,l="",m="",p="",q="",z="",list= new Array()
    var image = document.getElementById('homeRotateImg');
 
    list[list.length]='img/TrafficLookingWest.jpg?&width=275&height=375&name=homepic&alt=Traffic looking west.&border=0';
    list[list.length]='img/nightStreetTraffic.jpg?&width=275&height=375&name=homepic&alt=Looking east at night time traffic.&border=0';
    list[list.length]='img/three_bridges.jpg?&width=275&height=375&name=homepic&alt=A railroad bridge, along with the Marion and Center Street Bridges span the Willamette River.&border=0';   
    list[list.length]='img/UnderBridge.jpg?&width=275&height=375&name=homepic&alt=Looking under the Marion Street bridge.&border=0';   
    list[list.length]='img/sternwheeler_and_bridges.jpg?&width=275&height=375&name=homepic&alt=Sternwheeler on the river with the Center Street Bridge behind.&border=0';   

    j=parseInt(Math.random()*list.length);
    j=(isNaN(j))?0:j;
   
    image.src = list[j];
    if (list[j].indexOf('?')==-1) {
        image.src = list[j];//document.write("<img src='"+list[j]+"'>");
    }
    else {
        
        nvp=list[j].substring(list[j].indexOf('?')+2).split('&');
        for(var i=0;i<nvp.length;i++) {
            sub=nvp[i].split('=');
   	        switch(sub[0]) {
 	            case 'alt':
                    image.alt = unescape(sub[1]);
		            break;
	            case 'width':
                    image.width = unescape(sub[1]);
  		            break;
  	            case 'height':
  	                image.height = unescape(sub[1]);
  		            break;
  		      
            } //switch
        } //for
    } //else
} //function end

//funding js



