



//////////////////////////
////  department.js   ////
////////////////////////// 



// Choose between the statewide search and your own local site search.

function selectSearch() { 
	if (document.getElementById("control").which[0].checked) {
	  document.getElementById("ca_form").q.value = document.getElementById("search").value;
	  document.getElementById("ca_form").submit();
	} else {
		// Change the 'q' to the parameter your search engine uses for its text field
	  document.getElementById("local_form").q.value = document.getElementById("search").value;
	  document.getElementById("local_form").submit();
	}
  return false;
}

// End of selectSearch javascript


function AdjunctWindow(myURL)
	{
	  strFeatures = "menubar=yes,toolbar=yes,location=yes,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,top=20,left=30,width=550,height=300";
	  objNewWindow = window.open(myURL, "AdjunctWindow", strFeatures);
	  objNewWindow.focus();
	}
	
function FieldDefinition(myURL)
	{
	  strFeatures = "menubar=no,toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,top=70,left=150,width=350,height=100";
	objNewWindow = window.open(myURL, "AdjunctWindow", strFeatures);
	objNewWindow.focus();
	}
	
	
/* To call this function use: <a href="javascript:OpenCalculator();">Calculate Numbers</a> */
function OpenCalculator()
	{
	  var ret;
	  var spanTag;
	
	  ret = window.showModalDialog("/JS/calculator.htm", "","dialogHeight:285px;dialogWidth:215px;resizable:yes;");
	  spanTag = document.all.tags("span").item("numbers");
	  spanTag.innerText = ret;
	}
	
//////////////////////////
//// Tab Panel Module ////
//////////////////////////

function tabpanel_mouseover(node)
{
  var panel_1_width = document.getElementById("tabpanel_1_sublist").offsetWidth; // Needed for IE
  document.getElementById("tabpanel_1").className = ""; // De-activate default item
  node.className = "tabpanel_default"; // Activate the hovered item
  if (panel_1_width) {
    if (document.getElementById("tabpanel_2_sublist"))
      document.getElementById("tabpanel_2_sublist").style.width = (panel_1_width - 2) + "px"; // Needed for IE
    if (document.getElementById("tabpanel_3_sublist"))
      document.getElementById("tabpanel_3_sublist").style.width = (panel_1_width - 2) + "px"; // Needed for IE
  }
}

function tabpanel_mouseout(node)
{
  node.className = ""; // De-activate this item
  document.getElementById("tabpanel_1").className = "tabpanel_default"; // Activate default item
}

function randomImage() // Random Image function
{
var iNumImages = 5; // Number of images
var aSource = new Array(iNumImages); // Path to the images
var aAlttext = new Array(iNumImages); // Alt text
var iRandomNumber = Math.floor(Math.random() * iNumImages);

// Enter the root-relative paths to your images
aSource = [
"/images/SouthTahoe.jpg",
"/images/YosemiteValley.jpg",
"/images/RitterBanner.jpg",
"/images/CalEPABldg.jpg",
"/images/BigSur.jpg",
];

// Enter the alt tags for your images
aAlttext = [
"South Tahoe",
"Yosemite Valley",
"Ritter Banner",
"CalEPA Building",
"Big Sur",
];

if ((document.getElementById) && document.getElementById('random_image'))
document.getElementById('random_image').innerHTML = '<img src="' + aSource[iRandomNumber] + '" alt="' + aAlttext[iRandomNumber] + '" />';
}

addLoadEvent(randomImage); // Add randomImage to the page onload event handler


//////////////////////////
////  Carousel Module ////
//////////////////////////


var Carousel = {
	isMouseBtnPressed: 0, // Is the mouse button being pressed?
	currentSpeed: 0, // current carousel speed
	minimumSpeed: 2, // minimum speed
	maximumSpeed: 30, // maximum speed
	hitTheBrakes: 0, // Did the user move the mouse off the arrow?
	scrollThis: null, // the "caro_images2" element
	scrolldelay: null, // timer ID

	// This function updates the position of the "caro_images2" element. It calls itself
	// recursively during movement.
	caroScroll:function (sDirection) {
		var iDirection = (sDirection == "Left") ? 1 : -1; // Left arrow moves in positive direction, right arrow negative

		if (Carousel.isMouseBtnPressed && !Carousel.hitTheBrakes) { // "!Carousel.hitTheBrakes" needed in case user clicks and drags off arrow
			Carousel.currentSpeed += iDirection; // Accelerate
			if (Math.abs(Carousel.currentSpeed) > Carousel.maximumSpeed) // Are we exceeding the speed limit?
				Carousel.currentSpeed = iDirection * Carousel.maximumSpeed; // Set speed to maximum
		} else { // mouseup or mouseout
			Carousel.currentSpeed -= iDirection; // Decelerate
			if (iDirection == 1) { // Left arrow
				if (Carousel.currentSpeed < Carousel.minimumSpeed) { // too slow?
					if (Carousel.hitTheBrakes) { // mouse out?
						Carousel.currentSpeed = 0; // come to a stop
					} else {
						Carousel.currentSpeed = Carousel.minimumSpeed; // set speed to minimum
					}
				}
			} else { // Right arrow
				if (Carousel.currentSpeed > -Carousel.minimumSpeed) { // too slow?
					if (Carousel.hitTheBrakes) { // mouse out?
						Carousel.currentSpeed = 0; // come to a stop
					} else {
						Carousel.currentSpeed = -Carousel.minimumSpeed; // set speed to minimum
					}
				}
			}
		}

		if (iDirection == 1) { // left arrow
			if (parseInt(Carousel.scrollThis.style.left) < 0) { // not at the left edge?
				updatePosition();
			} else { // we're at the left edge
				document.getElementById("caro_left").style.backgroundPosition = '-40px 0px'; // grey left arrow
			}
		} else { // right arrow
			if ( ( document.getElementById("caro_images1").offsetWidth - parseInt(Carousel.scrollThis.style.left) ) < Carousel.scrollThis.offsetWidth ) { // not at the right edge?
				// (width of container) - (position of scroller) < (full width of the content)
				updatePosition();
			} else { // we're at the right edge
				document.getElementById("caro_right").style.backgroundPosition = '-102px 0px'; // grey right arrow
			}
		}

		function updatePosition() {
			document.getElementById("caro_left").style.backgroundPosition = '-9px 0px'; // blue left arrow
			document.getElementById("caro_right").style.backgroundPosition = '-71px 0px'; // blue right arrow
			Carousel.scrollThis.style.left=parseInt(Carousel.scrollThis.style.left) + Carousel.currentSpeed + 'px'; // Update position of scrollThis
			if (Carousel.currentSpeed) {
				clearTimeout(Carousel.scrolldelay); // fix problem where user moves mouse quickly from one arrow to the other
				Carousel.scrolldelay = setTimeout('Carousel.caroScroll("' + sDirection + '")',30); // scrolls every __ milliseconds
			}
		}
	},

	// This function inserts the arrows.  It is called on page load.
	initialize:function () {
		if (document.getElementById && document.getElementById("carousel")) { // Make sure browser supports getElementById and div "carousel" exists
			// Check to see if CSS is enabled
			var elementCaroRight = document.getElementById("caro_images1");
			if (elementCaroRight.currentStyle) { // for IE
				var styleCaroRight = elementCaroRight.currentStyle["position"];
			}
			else if (window.getComputedStyle) { // for FF
				var styleCaroRight = document.defaultView.getComputedStyle(elementCaroRight,null).getPropertyValue("position");
			}
			if (styleCaroRight == "relative") { /* CSS is enabled */

				var filenameArrows = "homepageimages/carousel/carousel.png";

				if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ // Check for IE
					var ieversion=new Number(RegExp.$1)
					if (ieversion <= 6){
						filenameArrows = "homepageimages/carousel/carousel.gif"; // IE6 doesn't support transparent png, so use gif
					}
				}

				Carousel.scrollThis = document.getElementById("caro_images2");
				Carousel.scrollThis.style.left = "0px";

				document.getElementById("caro_images1").style.overflow="hidden"; /* Hide the scrollbars */

				document.getElementById("caro_left").style.background = 'transparent url(' + filenameArrows + ') -40px 0px no-repeat'; // left arrow starts grey
				document.getElementById("caro_left").style.width = '23px';
				document.getElementById("caro_left").style.height = '50px';

				document.getElementById("caro_right").style.background = 'transparent url(' + filenameArrows + ') -71px 0px no-repeat'; // right arrow starts blue
				document.getElementById("caro_right").style.width = '23px';
				document.getElementById("caro_right").style.height = '50px';

			}
		}
	}
}

addLoadEvent(Carousel.initialize);

// -->












//////////////////////////
////  dropdowntabs.js ////
////////////////////////// 













var tabdropdown = {
    disappeardelay: 200, //set delay in miliseconds before menu disappears onmouseout
    disablemenuclick: false, //when user clicks on a menu item with a drop down menu, disable menu item's link?
    enableiframeshim: 1, //1 or 0, for true or false

    //No need to edit beyond here////////////////////////
    dropmenuobj: null, ie: document.all, firefox: document.getElementById && !document.all, previousmenuitem: null,
    currentpageurl: window.location.href.replace("http://" + window.location.hostname, "").replace(/^\//, ""), //get current page url (minus hostname, ie: http://www.dynamicdrive.com/)

    getposOffset: function(what, offsettype) {
        var totaloffset = (offsettype == "left") ? what.offsetLeft : what.offsetTop;
        var parentEl = what.offsetParent;
        while (parentEl != null) {
            //totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop - .5;
            totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
            parentEl = parentEl.offsetParent;
        }
        return totaloffset;
    },

    showhide: function(obj, e, obj2) { //obj refers to drop down menu, obj2 refers to tab menu item mouse is currently over
        if (this.ie || this.firefox)
            this.dropmenuobj.style.left = this.dropmenuobj.style.top = "-500px"
        if (e.type == "click" && obj.visibility == hidden || e.type == "mouseover") {
            if (obj2.parentNode.className.indexOf("default") == -1) //if tab isn't a default selected one
                obj2.parentNode.className = "selected"
            obj.visibility = "visible"
        }
        else if (e.type == "click")
            obj.visibility = "hidden"
    },

    iecompattest: function() {
        return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body
    },

    clearbrowseredge: function(obj, whichedge) {
        var edgeoffset = 0
        if (whichedge == "rightedge") {
            var windowedge = this.ie && !window.opera ? this.standardbody.scrollLeft + this.standardbody.clientWidth - 15 : window.pageXOffset + window.innerWidth - 15
            this.dropmenuobj.contentmeasure = this.dropmenuobj.offsetWidth
            if (windowedge - this.dropmenuobj.x < this.dropmenuobj.contentmeasure)  //move menu to the left?
                edgeoffset = this.dropmenuobj.contentmeasure - obj.offsetWidth
        }
        else {
            var topedge = this.ie && !window.opera ? this.standardbody.scrollTop : window.pageYOffset
            var windowedge = this.ie && !window.opera ? this.standardbody.scrollTop + this.standardbody.clientHeight - 15 : window.pageYOffset + window.innerHeight - 18
            this.dropmenuobj.contentmeasure = this.dropmenuobj.offsetHeight
            if (windowedge - this.dropmenuobj.y < this.dropmenuobj.contentmeasure) { //move up?
                edgeoffset = this.dropmenuobj.contentmeasure + obj.offsetHeight
                if ((this.dropmenuobj.y - topedge) < this.dropmenuobj.contentmeasure) //up no good either?
                    edgeoffset = this.dropmenuobj.y + obj.offsetHeight - topedge
            }
            this.dropmenuobj.firstlink.style.borderTopWidth = (edgeoffset == 0) ? 0 : "1px" //Add 1px top border to menu if dropping up
        }
        return edgeoffset
    },

    dropit: function(obj, e, dropmenuID) {
        if (this.dropmenuobj != null) { //hide previous menu
            this.dropmenuobj.style.visibility = "hidden" //hide menu
            if (this.previousmenuitem != null && this.previousmenuitem != obj) {
                if (this.previousmenuitem.parentNode.className.indexOf("default") == -1) //If the tab isn't a default selected one
                    this.previousmenuitem.parentNode.className = ""
            }
        }
        this.clearhidemenu()
        if (this.ie || this.firefox) {
            obj.onmouseout = function() { tabdropdown.delayhidemenu(obj) }
            obj.onclick = function() { return !tabdropdown.disablemenuclick } //disable main menu item link onclick?
            this.dropmenuobj = document.getElementById(dropmenuID)
            this.dropmenuobj.onmouseover = function() { tabdropdown.clearhidemenu() }
            this.dropmenuobj.onmouseout = function(e) { tabdropdown.dynamichide(e, obj) }
            this.dropmenuobj.onclick = function() { tabdropdown.delayhidemenu(obj) }
            this.showhide(this.dropmenuobj.style, e, obj)
            this.dropmenuobj.x = this.getposOffset(obj, "left")
            this.dropmenuobj.y = this.getposOffset(obj, "top")
            this.dropmenuobj.style.left = this.dropmenuobj.x - this.clearbrowseredge(obj, "rightedge") + "px"
            this.dropmenuobj.style.top = this.dropmenuobj.y - this.clearbrowseredge(obj, "bottomedge") + obj.offsetHeight + 1 + "px"
            this.previousmenuitem = obj //remember main menu item mouse moved out from (and into current menu item)
            this.positionshim() //call iframe shim function
        }
    },

    contains_firefox: function(a, b) {
        while (b.parentNode)
            if ((b = b.parentNode) == a)
            return true;
        return false;
    },

    dynamichide: function(e, obj2) { //obj2 refers to tab menu item mouse is currently over
        var evtobj = window.event ? window.event : e
        if (this.ie && !this.dropmenuobj.contains(evtobj.toElement))
            this.delayhidemenu(obj2)
        else if (this.firefox && e.currentTarget != evtobj.relatedTarget && !this.contains_firefox(evtobj.currentTarget, evtobj.relatedTarget))
            this.delayhidemenu(obj2)
    },

    delayhidemenu: function(obj2) {
        this.delayhide = setTimeout(function() { tabdropdown.dropmenuobj.style.visibility = 'hidden'; if (obj2.parentNode.className.indexOf('default') == -1) obj2.parentNode.className = '' }, this.disappeardelay) //hide menu
    },

    clearhidemenu: function() {
        if (this.delayhide != "undefined")
            clearTimeout(this.delayhide)
    },

    positionshim: function() { //display iframe shim function
        if (this.enableiframeshim && typeof this.shimobject != "undefined") {
            if (this.dropmenuobj.style.visibility == "visible") {
                this.shimobject.style.width = this.dropmenuobj.offsetWidth + "px"
                this.shimobject.style.height = this.dropmenuobj.offsetHeight + "px"
                this.shimobject.style.left = this.dropmenuobj.style.left
                this.shimobject.style.top = this.dropmenuobj.style.top
            }
            this.shimobject.style.display = (this.dropmenuobj.style.visibility == "visible") ? "block" : "none"
        }
    },

    hideshim: function() {
        if (this.enableiframeshim && typeof this.shimobject != "undefined")
            this.shimobject.style.display = 'none'
    },

    isSelected: function(menuurl) {
        var menuurl = menuurl.replace("http://" + menuurl.hostname, "").replace(/^\//, "")
        return (tabdropdown.currentpageurl == menuurl)
    },

    init: function(menuid, dselected) {
        this.standardbody = (document.compatMode == "CSS1Compat") ? document.documentElement : document.body //create reference to common "body" across doctypes
        var menuitems = document.getElementById(menuid).getElementsByTagName("a")
        for (var i = 0; i < menuitems.length; i++) {
            if (menuitems[i].getAttribute("rel")) {
                var relvalue = menuitems[i].getAttribute("rel")
                document.getElementById(relvalue).firstlink = document.getElementById(relvalue).getElementsByTagName("a")[0]
                menuitems[i].onmouseover = function(e) {
                    var event = typeof e != "undefined" ? e : window.event
                    tabdropdown.dropit(this, event, this.getAttribute("rel"))
                }
            }
            if (dselected == "auto" && typeof setalready == "undefined" && this.isSelected(menuitems[i].href)) {
                menuitems[i].parentNode.className += " selected default"
                var setalready = true
            }
            else if (parseInt(dselected) == i)
                menuitems[i].parentNode.className += " selected default"
        }
    }

}




