// JavaScript Document

// For the Quick links pulldown-menu of the left hand side menu of the site
function changepage(formObject)
{
    var url;
    
    url = formObject.options[formObject.options.selectedIndex].value;
    if(url != "empty"){
        window.location = url;
        url = "";
    }
}   

// For the Header Search form
function goto_url(form) 
{

    if (form.search_text.value == ""){
        alert("Please enter some text and then press Search");
        return false;
    }

    var url = form.search_select[form.search_select.selectedIndex].value +
    escape(form.search_text.value);


    // Uncomment this lines if you want the current window to change
    document.location = url;

    // Uncomment this line if you want the search in a new window
    //search_window = window.open(url);

    return false;
}

/* ROTATING CONTENT */

var curcontentindex=0;
var messages=new Array();

function getElementByClass(classname){
    var inc=0;
    var alltags=document.all? document.all : document.getElementsByTagName("*");
    for (i=0; i<alltags.length; i++){
    if (alltags[i].className==classname)
        messages[inc++]=alltags[i];
    }
}

var second_curcontentindex=0;
var second_messages=new Array();

function second_getElementByClass(classname){
    var inc=0;
    var alltags=document.all? document.all : document.getElementsByTagName("*");
    for (i=0; i<alltags.length; i++){
    if (alltags[i].className==classname)
        second_messages[inc++]=alltags[i];
    }
}

function rotatecontent(){
    //get current message index (to show it):
    curcontentindex=(curcontentindex<messages.length-1)? curcontentindex+1 : 0;
    //get previous message index (to hide it):
    prevcontentindex=(curcontentindex==0)? messages.length-1 : curcontentindex-1;
    messages[prevcontentindex].style.display="none"; //hide previous message
    messages[curcontentindex].style.display="block"; //show current message
}

function second_rotatecontent(){
    //get current message index (to show it):
    second_curcontentindex=(second_curcontentindex<second_messages.length-1)? second_curcontentindex+1 : 0;
    //get previous message index (to hide it):
    second_prevcontentindex=(second_curcontentindex==0)? second_messages.length-1 : second_curcontentindex-1;
    second_messages[second_prevcontentindex].style.display="none"; //hide previous message
    second_messages[second_curcontentindex].style.display="block"; //show current message
}
// LOAD ALL OF THE EVENTS
window.onload = function() { 
    if (document.all || document.getElementById){
        getElementByClass("dyncontent");
        setInterval("rotatecontent()", 5000);
        second_getElementByClass("second_dyncontent");
   		setInterval("second_rotatecontent()", 7500);
    }
}