// begin New window
var newWindow
function openPopupWindow(theURL,theWindow,theWidth,theHeight) {
	if (!newWindow || newWindow.closed) { // checks if window exist, if not --> create
		var w = theWidth;
		var h = theHeight;
		var x = (screen.width - w) / 2;
		var y = (screen.height - h) / 2;
		newWindow = window.open(theURL,theWindow,'top='+y+',left='+x+',width='+w+',height='+h+',resizable=yes,scrollbars=1,menubar=no,toolbar=no,directories=no,location=no,status=no');
	} else { // if print window is cretaed --> focus
			newWindow.focus();
			}
}
// end New window

function setFocus(sId) 
{
	document.getElementById(sId).focus();
}


// General function to highlight form elements 
// This code will higlight: INPUT and SELECT
// Just add new variables for new tag names
// Credits to: Simon Willison, http://www.sitepoint.com/article/simple-tricks-usable-forms/2 
addEvent(window, 'load', function() {
    var input;
    var inputs = document.getElementsByTagName('input');
    for (var i = 0; (input = inputs[i]); i++) {
        addEvent(input, 'focus', oninputfocus);
        addEvent(input, 'blur', oninputblur);
    }
    var selects = document.getElementsByTagName('select');
    for (var i = 0; (select = selects[i]); i++) {
        addEvent(select, 'focus', oninputfocus);
        addEvent(select, 'blur', oninputblur);
    }
});
function oninputfocus(e) {
    /* Cookie-cutter code to find the source of the event */
    if (typeof e == 'undefined') {
        var e = window.event;
    }
    var source;
    if (typeof e.target != 'undefined') {
        source = e.target;
    } else if (typeof e.srcElement != 'undefined') {
        source = e.srcElement;
    } else {
        return;
    }
    /* End cookie-cutter code */
//    source.style.border='1px solid #666';
    source.style.background='#F0E68C';
}
function oninputblur(e) {
    /* Cookie-cutter code to find the source of the event */
    if (typeof e == 'undefined') {
        var e = window.event;
    }
    var source;
    if (typeof e.target != 'undefined') {
        source = e.target;
    } else if (typeof e.srcElement != 'undefined') {
        source = e.srcElement;
    } else {
        return;
    }
    /* End cookie-cutter code */
//    source.style.border='1px solid #000';
    source.style.background='#FFF';
}
function addEvent(obj, evType, fn){
    if (obj.addEventListener){
        obj.addEventListener(evType, fn, true);
        return true;
    } else if (obj.attachEvent){
        var r = obj.attachEvent("on"+evType, fn);
        return r;
    } else {
        return false;
    }
}
// end General function to highlight form elements 


// Makes IE recognise :focus
// from: http://htmldog.com/articles/suckerfish/focus/example/links.html 

sfFocus = function() {
	var sfEls = document.getElementsByTagName("A");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onfocus=function() {
			this.className+=" sffocus";
		}
		sfEls[i].onblur=function() {
			this.className=this.className.replace(new RegExp(" sffocus\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfFocus);


// Fly-out menu, secNavContainer
/*
startList = function() 
{
	if (document.all&&document.getElementById) 
	{
		navRoot = document.getElementById("nav");
		// peterb, make sure the navRoot object actually exists on the page
		if (navRoot!=null){
			for (i=0; i<navRoot.childNodes.length; i++) 
			{
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") 
				{
				node.onmouseover=function() 
					{
					this.className+=" over";
					}
				node.onmouseout=function() 
					{
					this.className=this.className.replace(" over", "");
					}
				}
			}
		}
	}
}
*/
// Changed because we need a body onload="" on ShowCat.aspx
//	window.onload=startList;
//if (window.attachEvent) window.attachEvent("onload", startList);


//Frame escape
if (top.location != self.location) {
	top.location.href = self.location.href;
}
