var DOM_OBJECTS = [];
var nav_off_regex = /(.+)[0](\.gif)$/;
var last_menu_open = null;
var scope = null;
var hide_timeout = null;

var is_safari = (navigator.userAgent.indexOf('AppleWebKit') > 0);
var is_iemac = ( (navigator.userAgent.indexOf('MSIE') > 0) && (navigator.userAgent.indexOf('Mac') > 0) );

// -----------------------------------------------------------------------------


sfHover = function()
{
	var sfEls = document.getElementById("SiteNav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function()
		{
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function()
		{
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

// -----------------------------------------------------------------------------

// attach this to the onfocus of an INPUT or TEXTAREA, passing the 'this'
// object as the argument
function textFieldStoreAndClear(el) {
	el.originalText = (el.originalText == null) ? el.value : el.originalText;
	if (el.value == el.originalText) el.value = '';
}

// attach this to the onblur of an INPUT or TEXTAREA, passing the 'this'
// object as the argument
function textFieldRestore(el) {
	el.value = (el.value == '') ? el.originalText : el.value;
}

// Show and Hide Text Toggle
function toggleLayer(whichLayer) {
	if (document.getElementById) {
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
	}
	else if (document.all) {
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
	else if (document.layers) {
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		};
	}
}

var randomProfile = function () {
	var target_div = document.getElementById('home_profiles');
	var available_profiles_list = document.getElementById('available_profiles');
	var available_profiles = available_profiles_list.getElementsByTagName('li');
	var profile_count = available_profiles.length;
	var offset = Math.floor(Math.random() * (profile_count));
	target_div.innerHTML = available_profiles[offset].innerHTML;
};
