
// Generic JavaScript utility functions       

    function setSelectedValue(selectName, val)
   // Sets the selectedIndex of the given Select object according to the value given
    { 
        selectObject= document.getElementById(selectName);
        var len = selectObject.options.length;
        for(var i=0; i<len; i++){
            if (selectObject.options[i].value == val){
                selectObject.selectedIndex = i;
                break;
            }
        } 
    }

    function getSelectedValue(selectName) 
   // Returns the value of the selected item in the given Select object
    {
        selectObject= document.getElementById(selectName);
        return selectObject.options[selectObject.selectedIndex].value
    }
   
    function disableControl(targetId)
    // 
    { 
        target= document.getElementById(targetId);
        if (typeof(target) != 'undefined' && target != null) 
        {
           target.disabled = true;
        }
    }

    function enableControl(targetId)
    // 
    { 
        target= document.getElementById(targetId);
        if (typeof(target) != 'undefined' && target != null)
        {
            target.disabled = false;
        }
    }
 
    // toggle visibility 
    // source: zeldman

    function toggle( targetId ){
      if (document.getElementById){
  		    target = document.getElementById( targetId );
  			    if (target.className == "Hidden"){
  				    target.className = "Visible";
  			    } else {
  				    target.className = "Hidden";
  			    }
  	    }
    }
 
    function hide( targetId ){
      if (document.getElementById){
  		    target = document.getElementById( targetId );
		    target.className = "Hidden";
  	    }
    } 
   
    function show( targetId ){
      if (document.getElementById){
  		    target = document.getElementById( targetId );
		    target.className = "Visible";
  	    }
    }
   
       /////////// centering code
    // Code below taken from - http://www.evolt.org/article/document_body_doctype_switching_and_more/17/30655/ *
    // Gets the full width/height because it's different for most browsers.
    function getViewportHeight() {
        if (window.innerHeight!=window.undefined) return window.innerHeight;
        if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
        if (document.body) return document.body.clientHeight; 
        return window.undefined; 
    }

    function getViewportWidth() {
        if (window.innerWidth!=window.undefined) return window.innerWidth; 
        if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
        if (document.body) return document.body.clientWidth; 
        return window.undefined; 
    }
 