// Create Pseudo Hover Class for IE 6 For Main Menu
var sfHover = function() {
	var sfEls = document.getElementById("nav").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); // window attach works for IE only

// Add 'BACK TO TOP' if overflow sufficient
var addBackToTopIfOverflow = function addBackToTopIfOverflow() {
	var viewportheight;
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	if (typeof window.innerWidth != 'undefined') viewportheight = window.innerHeight
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) viewportheight = document.documentElement.clientHeight
	// older versions of IE
	else viewportheight = document.getElementsByTagName('body')[0].clientHeight;
	// If window scroll insert a 'return to top of page'
	if(viewportheight < (document.body.clientHeight - 200)) {
		var el = document.getElementById('back_to_top_wrap');
		if(el) el.innerHTML = '<a href="#top">Return To Page Top</a>';	
	}	
}

function focusControl(field, placeholder) {
	if(field.value == placeholder) {
		field.value = '';
	}
}
function blurControl(field, placeholder) {
	if(field.value == '' || field.value == ' ') {
		field.value = placeholder;
	}
}

// Email 
function ebd(obj, var1, var2, var3, var4, var5, var6) {
	var string = '';
	var element = document.getElementById(obj);
	if(var2!='') string = var1+"."+var2+"@"; else string = var1+"@";
	if(var4!='') string = string+var3+"."+var4+"."+var5; else string=string+var3+"."+var5;
	if(var6=='') var6 = string;
	if(element) element.innerHTML = "<a href='mailto:"+string+"'>" + var6 + "</a>";
}
function ebd2(obj, var1, var2, var3, var4, var5) {
	var string = '';
	var element = document.getElementById(obj);
	if(var2!='') string = var1+"."+var2+"@"; else string = var1+"@";
	if(var4!='') string = string+var3+"."+var4+"."+var5; else string=string+var3+"."+var5;
	if(element) element.innerHTML = string;
}

function addbookmark() {
	general = "First click OK and then hit CTRL+D to bookmark this page.";
	opera = "First click OK and then hit CTRL+T to bookmark this page.";
	if ((navigator.userAgent).indexOf("Opera")!=-1) alert(opera);
	else alert(general);
}
function page_tool_hover(text) {
	el = document.getElementById('page_tool_hover');
	el.innerHTML = text;
}

// Ext JS Scripts
Ext.onReady(function() {
   addBackToTopIfOverflow();
});
