// 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 tag names if needed
// 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 */

	if (source.className == 'add' || source.className == 'btnSearch') {
		source.style.background='';
	}
	else 
	{
		source.style.backgroundColor='#80e1ff';
	}
}

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 */

	if (source.className == 'add' || source.className == 'btnSearch') {
		source.style.background='';
	}
	else
	{
		source.style.backgroundColor='';
	}
}
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);


//Frame escape
if (top.location != self.location) {
	top.location.href = self.location.href;
}

/*********************	BEGIN FUNCTIONS USED BY THE KeepMeUpdated COMPONENT	***********************/
function KeepMeUpdated_ValidateEmail(source, arguments)
{
	var emailRegEx = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;	
	var matches = emailRegEx.exec(arguments.Value);
	if ((matches == null) || (matches.length == 0))
		arguments.IsValid = false;
	else
		arguments.IsValid = true;
}
/*********************	END FUNCTIONS USED BY THE KeepMeUpdated COMPONENT	***********************/