/* Content Loader (common): Standard Menu Script
Title: JavaScript Menus
File: [com]/scripts/menus.js
File Ver.:0.1
Date Created: 09-03-07
Updated: 18-Mar-2007

Description:
	Standard CL menus
*/
var IS_MOZILA;

// firstClick
var firstClick = "";

// -== Functions ==-
// event_overRootItem(obj)
// event_outRootItem(obj)
// event_overItem(obj)
// event_outItem(obj)

// -== Definitions ==-

/*
// swaps an objects style with one with the extention '_ov'
*/
function event_overItem(obj)
{
    // save the 'in-active' & 'active' styleName's
    if (obj.orig_class == null)
    {
        obj.orig_class = obj.className;
        obj.act_class = obj.orig_class + '-ov';
    }
	
	// apply the 'active' style
	obj.className = obj.act_class;
	
	// show the floating table
	var objFloat;
	if ((objFloat = (MM_findObj(obj.id + "-float"))) != null)
	{
	    // make visible
		objFloat.style.visibility = "visible";
		
		// save a ref. to the parent object
		objFloat.parent = obj;
	}
	
	// reset firstClick
	firstClick = "";
	
//	alert("over: " + obj.id + "style = " + obj.className);
}

/*
// replaces and objects original style
*/
function event_outItem(obj)
{
	// restore 'in-active' style
	obj.className = obj.orig_class;
	
	// hide the floating table
	var objFloat;
	if ((objFloat = (MM_findObj(obj.id + "-float"))) != null)
	{
	    // make hidden
		objFloat.style.visibility = "hidden";
	}
	
//	alert("out: " + obj.id + "style = " + obj.className);
}

function event_showMenu(obj)
{
    // restore (keep) the parents 'active' style
    obj.parent.className = obj.parent.act_class;

    // make the sub menu visible
    obj.style.visibility = "visible";
}

function event_hideMenu(obj)
{
    // restore the parents original class
    obj.parent.className = obj.parent.orig_class;

    // make the sub menu hidden
    obj.style.visibility = "hidden";
}

function event_clickItem(loc_id)
{
	// first click is first!!
	if (firstClick == "")
	{
		window.location.href = "?loc=" + loc_id;
		firstClick = loc_id;
	} else {
//	    alert("firstClick = " + firstClick);
    }
}

function event_back(back_val)
{
	if (back_val < 0)
	{
    	window.history.go(back_val);
    }
    else
    {
    	window.history.go(-1);
	}
}

// returns a CSS "style" object's style text from a class name
function getCSS_text(className)
{
	var str = "", style_str;
	var ss_x, r_x, style_x;

	if (IS_MOZILA)
	{
		// Mozilla / Netscape
		for (ss_x in document.styleSheets)
		{
			for (r_x in document.styleSheets[ss_x].cssRules)
			{
				if (document.styleSheets[ss_x].cssRules[r_x].selectorText == className)
					return(document.styleSheets[ss_x].cssRules[r_x].style.cssText);
			}
		}
	}
	else
	{
		// MS-IE 5+
		for (ss_x in document.styleSheets)
		{
			for (r_x in document.styleSheets[ss_x].rules)
			{
				if (document.styleSheets[ss_x].rules[r_x].selectorText == className)
					return(document.styleSheets[ss_x].rules[r_x].style.cssText);
			}
		}
	}

	return(0);
}

// change the innerHTML of a list of object id's
function multi_innerHTML(list, html)
{
    var i;
    
    for (i in list)
    {
        MM_findObj(list[i]).innerHTML = html;
    }
}

// findObj (c) Macromedia / Adobe
function MM_findObj(n, d)
{
	var p,i, x;
	if (!d)
		d=document;
	if((p=n.indexOf("?")) > 0 && parent.frames.length)
	{
		d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	if (!(x = d[n]) && d.all)
		x=d.all[n];
	if (d.forms)
	{
		for (i=0; !x && i < d.forms.length; i++)
			x = d.forms[i][n];
	}
	for (i=0; !x && d.layers && i < d.layers.length; i++)
		x=MM_findObj(n,d.layers[i].document);
	if (!x && d.getElementById)
		x = d.getElementById(n);
	return x;
}

// Get browser type.
function getBrowser()
{
	var agt=navigator.userAgent.toLowerCase();
	var nav	= ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1)));
	IS_MOZILA = nav;
}

// init
getBrowser();
