/* New Scripts */


//**********************************
// Onload - Unobtrusives
//**********************************

// Onload unobtrusive handler
// Dean Edwards/Matthias Miller/John Resig

/* for Mozilla/Opera9 */
if (document.addEventListener) {
	document.addEventListener("DOMContentLoaded", init, false);
}

/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
	document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
	var script = document.getElementById("__ie_onload");
	script.onreadystatechange = function() {
		if (this.readyState == "complete") {
			init(); // call the onload handler
		}
	};
/*@end @*/

/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
	var _timer = setInterval(function() {
		if (/loaded|complete/.test(document.readyState)) {
			init(); // call the onload handler
		}
	}, 10); 
}

/* for other browsers */
window.onload = init;



//**********************************
// Unobtrusive functions
//**********************************
function init() {
	if (arguments.callee.done) return;
	arguments.callee.done = true;
	if (_timer) clearInterval(_timer);
	
	// OnLoad stuff
	if (window.attachEvent && $('rollovermenu')) { sfHover(); } 	
	
}

//**********************************
// IE6 Menu hover events
//**********************************
sfHover = function() {
	var sfEls = document.getElementById("rollovermenu").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"), "");
		}
	}
}



function show_it(active){
	document.getElementById(active).style.display = "block";
}

function hide_it(active){
  	document.getElementById(active).style.display = "none";
}

var llun = null;


// This function will open a div and close all other open divs

function divCall(activeDiv) {
	var docLoc = document.getElementById(activeDiv);

	if (docLoc) {
		if ((docLoc.style.display == "none" || docLoc.style.display == "")) {
			docLoc.style.display = "block";
		} else {
			if (docLoc.style.display = "block") { docLoc.style.display = "none"; }
		}
		if (llun && docLoc != llun) { llun.style.display = "none"; }
		llun = docLoc;
	} else { llun = null; }
}


// This function will leave open the current div if clicked again

function divCall2(activeDiv) {
	var docLoc = document.getElementById(activeDiv);

	if (docLoc) {
		if ((docLoc.style.display == "none" || docLoc.style.display == "")) {
			docLoc.style.display = "block";
		} else {
			if (docLoc.style.display = "block") { docLoc.style.display = "block"; }
		}
		if (llun && docLoc != llun) { llun.style.display = "none"; }
		llun = docLoc;
	} else { llun = null; }
}
function divCalltwo(id) {
	var docLoc2 = document.getElementById(id);

	if (docLoc2) {
		if ((docLoc2.style.display == "none" || docLoc2.style.display == "")) {
			docLoc2.style.display = "block";
		} else {
			if (docLoc2.style.display = "block") { docLoc2.style.display = "none"; }
		}
		if (llun2 && docLoc2 != llun2) { llun2.style.display = "none"; }
		llun2 = docLoc2;
	} else { llun2 = null; }
}


// New and improved: Will open/close divs, but you need to specify behaviour of the same div clicked twice ie.. close="none" or open="block"

var divObj = new Object();
divObj.prev = null;

function divCall3(activeDiv, action) {
	var docLoc = document.getElementById(activeDiv);
	var divAction="none";
	if (action=="open") {divAction="block"}
	
	if (docLoc) {
		if ((docLoc.style.display == "none" || docLoc.style.display == "")) {
			docLoc.style.display = "block";
		} else {
			if (docLoc.style.display = "block") { docLoc.style.display = divAction; }
		}
		if (divObj.prev && docLoc != divObj.prev) { divObj.prev.style.display = "none"; }
		divObj.prev = docLoc;
	} else { divObj.prev = null; }
}

//**********************************
// Generic Framework || Unless you really know what your doing I'd say leave these as they are
//**********************************


// Object Accessibility || parent Object, objects to hide
function accessible(pObj, tObj){
	var tmp = getElementsByClassName(pObj, "*", tObj); 
	for(var i=0;i<tmp.length;i++){
		dsp(tmp[i],'none');
	}
}

// Event Delegations
function getTarget(x){ 
	x = x || window.event;
	return x.target || x.srcElement;
}
// Prototype Method to get the element based on ID
function $(d){
	return document.getElementById(d);
}

// set or get the current display style of the div
function dsp(d,v){
	if(v==undefined){
		return d.style.display;
	}else{
		d.style.display=v;
	}
}

// set or get the height of a div.
function sh(d,v){
	// if you are getting the height then display must be block to return the absolute height
	if(v==undefined){
		//if style = block
		if(dsp(d)!='none'&& dsp(d)!=''){
			return d.offsetHeight;
		}
		// else
		viz = d.style.visibility;
		d.style.visibility = 'hidden';
		o = dsp(d);
		dsp(d,'block');
		r = parseInt(d.offsetHeight);
		dsp(d,o);
		d.style.visibility = viz;
		return r;
	}else{
		d.style.height=v;
	}
}

// get elements by class name
function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/-/g, "\-");
	var oRegExp = new RegExp("(^|\s)" + strClassName + "(\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}






function WindowOpener(filename,openname,width,height)
{
window.open(filename,openname,"menubar=no,toolbar=no,location=no,menus=no,scrollbars,resizable=1,status=yes,top=5,width=" + width + ",height=" + height + "");
}
function Window1000(filename)
{
  window.open(filename,'1000','menubar=yes,toolbar=yes,location=yes,menus=yes,scrollbars,resizable=1,status=yes,top=5,width=1000,height=720');
}
function Window950(filename)
{
  window.open(filename,'950','menubar=no,toolbar=no,location=no,menus=no,scrollbars,resizable=1,status=yes,top=5,width=950,height=720');
}
function Window900(filename)
{
  window.open(filename,'900','menubar=no,toolbar=no,location=no,menus=no,scrollbars,resizable=1,status=yes,top=5,width=900,height=720');
}
function Window850(filename)
{
  window.open(filename,'850','menubar=no,toolbar=no,location=no,menus=no,scrollbars,resizable=1,status=yes,top=5,width=850,height=550');
}
function Window800(filename)
{
  window.open(filename,'800','menubar=no,toolbar=no,location=no,menus=no,scrollbars,resizable=1,status=yes,top=5,width=800,height=690');
}
function Window750(filename)
{
  window.open(filename,'750','menubar=no,location=no,menus=no,scrollbars,resizable=1,status=yes,top=5,width=740,height=640');
}
function Window700(filename)
{
  window.open(filename,'700','menubar=no,location=no,menus=no,scrollbars,resizable=1,status=yes,top=5,width=700,height=540');
}
function Window640(filename)
{
window.open(filename,'640','menubar=no,toolbar=no,location=no,menus=no,scrollbars,resizable=1,status=yes,top=5,width=640,height=560');
}
function Window500(filename)
{
  window.open(filename,'sec','menubar=no,location=no,menus=no,scrollbars=yes,resizable=1,status=yes,top=5,width=500,height=450');
}
function Window450(filename)
{
  window.open(filename,'450','menubar=no,location=no,menus=no,scrollbars=yes,resizable=1,status=yes,top=5,width=450,height=400');
}