/* ------------------ Browser Sniffer ----------------------- */

ns4 = (document.layers)? true:false
NS4 = ns4
ie4 = (document.all && !document.getElementById)? true:false
ie5 = (document.all && document.getElementById)? true:false
ns6 = (!document.all && document.getElementById)? true:false

// Define helper function -- Used if getElementById is not defined, but document.all is
if(document.all && !document.getElementById)
{
	document.getElementById = function(id) { return document.all[id]; }
}

/* ---------------------- Get_Date -------------------------- */

var today = new Date();
var year = today.getFullYear() + '';
var month = today.getMonth()+1;
var date = today.getDate();
var day = today.getDay();
var Year = year.substring(year.length-2,year.length);
var dayName = new Array('SUN','MON','TUE','WED','THU','FRI','SAT');
var monthName = new Array('January','February','March','April','May','June','July','August','September','October','November','December');


function Get_Year() {
 document.write('20'+Year);
}

function Get_Date() {
 if (month < 10) {Month = '0' + month;} else {Month = month;}
 //if (date<10) {Date='0'+date;} else {Date=date;}
 Date = date;
 //document.write(monthName[month-1] + '&nbsp;' + Date + ', 20' + Year);
 document.write(monthName[month-1] + '&nbsp;' + Date + ', ' + year);
}


/* ---------------------- Cookies -------------------------- */

function getCookie (name)
{
    var dcookie = document.cookie; 
    var cname = name + "=";
    var clen = dcookie.length;
    var cbegin = 0;
//alert('Retrieved cookie: ' + unescape(dcookie));		

    while (cbegin < clen)
    {
		var vbegin = cbegin + cname.length;
        
        if (dcookie.substring(cbegin, vbegin) == cname)
        { 
			var vend = dcookie.indexOf (";", vbegin);
            if (vend == -1) vend = clen;
//alert('Retrieved cookie: ' + name + '=' + unescape(dcookie.substring(vbegin, vend)));		
			return unescape(dcookie.substring(vbegin, vend));
        }
		cbegin = dcookie.indexOf(" ", cbegin) + 1;
        if (cbegin == 0) break;
    }
    return null;
}

function setCookie (name, value, expires)
{
	var strCookie;
	
	if (name)
	{
		strCookie = name + '=' + escape(value) +
			( (expires) ? ';expires=' + expires.toGMTString() : '') +
			"; path=/"; 
//alert('Setting cookie: ' + strCookie);		
	    document.cookie = strCookie;
	}
}
    
function deleteCookie (name)
{
	if (getCookie(name))
	{
		document.cookie = name + "=" +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT" +  "; path=/";
	}
}


/* ------------------ Start Hide / Show Layer ----------------------- */

function show(id) {
 if (ns4) document.layers[id].visibility = "show"
 else if (ie4) document.all[id].style.visibility = "visible"
 else if (ie5 || ns6) document.getElementById([id]).style.visibility = "visible"
}

function hide(id) {
 if (ns4) document.layers[id].visibility = "hide"
 else if (ie4) document.all[id].style.visibility = "hidden"
 else if (ie5 || ns6) document.getElementById([id]).style.visibility = "hidden"
}


/* ------------------- Start Expand Menu -------------------------- */
var g_ChildMenuCookie = 'ChildMenu';

verOk = (ns4 || ie4 || ie5 || ns6) ? 1 : 0;

if (verOk)
{
	var displaySetting = 'none';
	var childStyle = '';
	
	if (!getCookie (g_ChildMenuCookie + '0'))
		displaySetting = 'block';	// May 2004: Menu's initial state should be open

	if (getCookie (g_ChildMenuCookie + '0') == 'show')
		displaySetting = 'block';
	// let cookie tell us how to set the initial style
	childStyle = '<STYLE type="text/css">'
    if (ns4)
    {
    //    childStyle = childStyle + '.parent {position:absolute;visibility:visible}';
    //    childStyle = childStyle + '.child {position:absolute;visibility:visible}';
    //    childStyle = childStyle + '.regular {position:absolute;visibility:visible}';
    }
    else
		childStyle = childStyle + '.child {display:' + displaySetting + '}';

	childStyle = childStyle + '</STYLE>';
	//alert(childStyle);
    document.write(childStyle);
}

function getIndex(el) {
    ind = null;
    for (i=0; i<document.layers.length; i++) {
        whichEl = document.layers[i];
        if (whichEl.id == el) {
            ind = i;
            break;
        }
    }
    return ind;
}

function arrange(menuNo) {
	whichEl.pageY = 156;
    nextY = document.layers[firstInd].pageY + document.layers[firstInd].document.height;
	whichEl.pageY = nextY;
	for (i=firstInd+1; i<document.layers.length; i++) {
        whichEl = document.layers[i];
        if (whichEl.visibility != "hide") {
			whichEl.pageY = nextY;
            nextY += whichEl.document.height;
        }
    }
	
	menuHeight = nextY-120;
}

function initIt(){

    if (!verOk) return;

	if (getCookie (g_ChildMenuCookie) == 'show')
		expandIt(0);

    if( typeof window.initControls == "function" ) 
    // Set up the product search drop-down boxes on the appropriate pages
		initControls();
}

function expandIt(el)
{
    if (!verOk) return;
    // not used
}

function toggleIt(el)
{
    if (!verOk) return;

    var sCookieName = '';
    
    if (g_ChildMenuCookie)						// global value
		sCookieName = g_ChildMenuCookie + el;

//alert('Calling toggleIt, cookie name is ' + sCookieName);
    
    if (ns4 || NS4)
    {
		// NS4 menu expansion not supported
	}
	else
	{
		if (ie4)
	        whichEl = eval("elChild" + el);
		else
		{  
			el = "elChild" + el
			whichEl = document.getElementById(el);
        }
        
		if (!getCookie(sCookieName))
			whichEl.style.display = 'block';	// May 2004: Menu's initial state should be open
			
		if (getCookie(sCookieName) == 'show')
			whichEl.style.display = 'block';
			
//alert('style.display=' + whichEl.style.display);
        if (!whichEl.style.display || whichEl.style.display == "none")
        {
			whichEl.style.display = "block";
			setCookie (sCookieName, 'show', '')
        }
        else
        {
			whichEl.style.display = "none";
			setCookie (sCookieName, 'hide', '')
        }	
    }
}


/* ------------------- End Expand Menu -------------------------- */

function gogetpage(){
	if (document.getpage.select_page.options[document.getpage.select_page.selectedIndex].value != "none") {
	location = document.getpage.select_page.options[document.getpage.select_page.selectedIndex].value
	}
}
