﻿// Function for changing the rollover state in the Secondary Nav
function navRollOver(el) {
    foundDiv = false
    divId = ""
    count = 0
    //set count to max 10 to avoid looping too long
    while(!foundDiv && el.parentNode.parentNode && count < 10){
        el = el.parentNode.parentNode
        if (el.tagName.toLowerCase() == "div"){
            foundDiv = true
            divId = el.id
        }    
        count++
    }

	n = document.getElementById(divId);
	
	if (n.className == "secondNavBtn") {
		n.className = "secondNavBtnOn";
	} else {
		n.className = "secondNavBtn";
	}
}

// Function for changing the rollover state in the Inner Nav
function innerNavRollOver(el) {
    
    foundDiv = false
    divId = ""
    count = 0
    //set count to max 10 to avoid looping too long
    while(!foundDiv && el.parentNode.parentNode && count < 10){
        el = el.parentNode.parentNode
       
        if (el.tagName.toLowerCase() == "div"){
            foundDiv = true
            divId = el.id
            //alert(divId);
        }    
        
        count++
    }

	n = document.getElementById(divId);
	//alert(n.className);
	if (n.className == "innerNavBtn") {
		n.className = "innerNavBtnOn";
		
	} else {
		n.className = "innerNavBtn";
	}
}

// Function for toggling the tab on the homepage
function toggleHomeTab(el) {
    n = document.getElementById("divTabNews");
    b = document.getElementById("divTabBlog");
    e = document.getElementById("imgTabEmpty");
    
    nOn = document.getElementById("divNewsOn");
    bOn = document.getElementById("divBlogOn");
    
    if (el == "linkTabBtnNewsOn" || el == "linkTabBtnNewsOff") {
        n.style.display = "";
        b.style.display = "none";
        nOn.style.display = "";
        bOn.style.display = "none";
    } else if (el == "linkTabBtnBlogOn" || el == "linkTabBtnBlogOff") {
        n.style.display = "none";
        b.style.display = "";
        nOn.style.display = "none";
        bOn.style.display = "";
    }
}

function change(what){
    //show previous div
    arrDivs = new Array();
    arrDivs[0] = "quote0";
    arrDivs[1] = "quote1";
    arrDivs[2] = "quote2"; //change
    //arrDivs[3] = "quote3";
    //arrDivs[4] = "quote4"; //no
    //arrDivs[5] = "quote5";
    //arrDivs[6] = "quote6";
    //figure out which one is on
    for(x=0;x<arrDivs.length;x++){
        if(document.getElementById(arrDivs[x]).style.display != "none"){
            curSlide = x;
            break;
        }
        
    }
    //hide current
    document.getElementById(arrDivs[curSlide]).style.display = "none";
    document.getElementById(arrDivs[curSlide]).style.visibility = "hidden";

    if(what=="next"){
        
        nextSlide = curSlide + 1
        if(nextSlide > arrDivs.length-1){
            nextSlide = 0;
        }
        
    }
    if(what=="prev"){
        nextSlide = curSlide - 1;
        if(nextSlide < 0){
            nextSlide = arrDivs.length -1;
        }
    }
    //display next/prev
    document.getElementById("quote" + nextSlide).style.visibility = "visible";
    document.getElementById("quote" + nextSlide).style.display = "";

}

function forceClick(e, elemId) {
                var elem = document.getElementById(elemId);
                var evt = (e) ? e : window.event;
                var intKey = (evt.which) ? evt.which : evt.keyCode;
                
                if(intKey == 13) {
                    elem.click();
                    return false;
                }

                return true;
            }
function submitMyForm(){
                var st = document.getElementById("q").value;
                location.replace("/Search.aspx?cx=014371337218559157175:_obsb9liy-y&cof=FORID:11;NB:1&ie=UTF-8&q=" + st + "&sa=Search#1009");
               
            }