var contextRoot = "/ecatalog";

function inputEvent(e){
	var el = Event.element(e);
	el.removeClassName('txtError');
	el.addClassName('txt');
}
function initMessage(el,mess){
	if(el.value == mess)
		el.value = '';
	else if(el.value == '')
		el.value = mess;
}
function check(el, mess){
	// trim out blanks
	var inputValue = trim($(el).value);
	var messValue = trim(mess);
	if(inputValue == '' || inputValue == messValue)
	{
		alert(mess);
		$(el).focus();
		return false;
	}	
	return true;
}
function isWhitespace(value){
	// Is value empty?
	if (isEmpty(value))
		return true;

	// Search through string's characters one by one
	// until we find a non-whitespace character.
	// When we do, return false; if we don't, return true.

	for (var i = 0; i < value.length; i++)
	{
		// Check that current character isn't whitespace.
		var c = value.charAt(i);

		if (whitespace.indexOf(c) == -1)
			return false;
	}

	// All characters are whitespace.
	return true;
}	
function handleKeyEvent(e){
	var code;
	var targ;
	if (!e) var e = window.event;
	if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;
	
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) 
		targ = targ.parentNode;
		
}
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function getWindowSize(){
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
	    myWidth = window.innerWidth;
	    myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    //IE 6+ in 'standards compliant mode'
	    myWidth = document.documentElement.clientWidth;
	    myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 4 compatible
	    myWidth = document.body.clientWidth;
	    myHeight = document.body.clientHeight;
	}
	var dim = {width:myWidth,height:myHeight};
	return dim;
}
