var _wsgWindowFadeAnimation = true;
var _ns6 = document.getElementById && !document.all;
var _wsgTrashObjectId = '_wsgTrashObj';
var _windowTimeOut = 0;
var _windowBlockerTimeOut = 0;
var _wsgBlockers = new Array();
if (_ie) _wsgWindowFadeAnimation = false;
var _ESCAPE_KEY_CODE = 27;
var _ENTER_KEY_CODE = 13;
var _DELETE_KEY_CODE = 46;
// TO USE _wsgWindowFadeAnimation MIND THAT IE WHEN CHANGING ALHA OF PNG SHOW BLACK BORDER... USE BACKGROUND COLOR TO FIX IT...

function HashMap() {
	this.put = function(foo,bar) {this[foo] = bar;};
	this.get = function(foo) {return this[foo];};
};

function ArrayList() {
	this.array = new Array();
	this.add = function(obj){
		this.array[this.array.length] = obj;
	};
	this.iterator = function (){
		return new Iterator(this);
	};
	this.length = function (){
		return this.array.length;
	};
	this.get = function (index){
		return this.array[index];
	};
	this.addAll = function (obj) {
		if (obj instanceof Array){
			for (var i=0;i<obj.length;i++) {
				this.add(obj[i]);
			}
		} else if (obj instanceof ArrayList){
			for (var i=0;i<obj.length();i++) {
				this.add(obj.get(i));
			}
		}
	};
};

function Iterator (arrayList){
	this.arrayList;
	this.index = 0;
	this.hasNext = function (){
		return this.index < this.arrayList.length();
	};
	this.next = function() {
		return this.arrayList.get(index++);
	};
};

function StringBuffer() {
	this.buffer = []; 
};

StringBuffer.prototype.append = function(string) {
	this.buffer.push(string);
	return this;
};

StringBuffer.prototype.toString = function() {
	return this.buffer.join("");
};

String.prototype.trim = function() {
	a = this.replace(/^\s+/, '');
	return a.replace(/\s+$/, '');
};

String.prototype.startsWith = function(str) {
	return (this.match("^"+str)==str);
};

String.prototype.endsWith = function(str) {
	return (this.match(str+"$")==str);
};


function WSGUtils() {
	this.allSpaces = function(value) {
		if (value != undefined) {
			value = value.toString();
			for (var i = 0; i < value.length; i++) {
				if (value.charAt(i) != ' ') {
					return false;
				}
			}		
		}
		return true;
	};
	this.showSystemMessage = function(_moduleNamespace, type, text) {
		this.hideSystemMessage(_moduleNamespace);
		if (type == null) {
			type = WSG_MESSAGE_TYPE_ERROR;
		}
		var icon = ((WSG_MESSAGE_TYPE_INFO == type) ? this.getInfoIcon() : ((WSG_MESSAGE_TYPE_WARNING == type) ? this.getWarningIcon() : this.getErrorIcon()));	
		document.getElementById(_moduleNamespace + '_msgIcon').innerHTML = '<img src="' + icon + '" border="0">';
		document.getElementById(_moduleNamespace + '_msg').className='show-message';
		document.getElementById(_moduleNamespace + '_MsgTxt').innerHTML = text;
	};
	this.hideSystemMessage = function(moduleNamespace) {		
		if (document.getElementById(moduleNamespace + '_msg') != undefined && document.getElementById(moduleNamespace + '_msg').className == 'show-message') {		
			document.getElementById(moduleNamespace + '_MsgTxt').innerHTML = '';
			document.getElementById(moduleNamespace + '_msgIcon').innerHTML = '';
			document.getElementById(moduleNamespace + '_msg').className='hide-message';
		}
	};
	
	this.fieldIsEmptySetMsgToField = function (moduleNamespace, field, type,  text) {
		if (field != undefined) {
			if (this.allSpaces(field.value)) {						
				this.showSystemMessage(moduleNamespace, type, text);
				field.focus();
				return true;
			}
		}
		return false;
	};

	this.fieldIsTooShortSetMsgToField = function (moduleNamespace, field, type, text, length) {
		if (field != undefined) {
			if (this.allSpaces(field.value) || field.value.trim().length < length) {		
				this.showSystemMessage(moduleNamespace, type, text);
				field.focus();
				return true;
			}
		}
		return false;
	};

	this.valueIsTooShortSetMsgToField = function (moduleNamespace, value, type, text, length) {
		if (value != null) {
			if (this.allSpaces(value) || value.trim().length < length) {		
				this.showSystemMessage(moduleNamespace, type, text);				
				return true;
			} 
			return false;			
		}
		return true;
	};
	
	this.fieldIsTooLongSetMsgToField = function (moduleNamespace, field, type, text, length) {
		if (field != undefined) {
			if (field.value.trim().length > length) {		
				this.showSystemMessage(moduleNamespace, type, text);
				field.focus();
				return true;
			}
		}
		return false;
	};
	
	this.fieldsNotMatchSetMsgToField = function (moduleNamespace, field, field2, type, text) {
		if (field != undefined && field2 != undefined) {
			if (field.value.trim() != field2.value.trim()) {		
				this.showSystemMessage(moduleNamespace, type, text);
				field.focus();
				return true;
			}
		}
		return false;
	};
	
	this.fieldIsNotAllDigitSetMsgToField = function (moduleNamespace, field, type, text) {
		if (field != undefined) {
			if (!this.isAllDigitNoAlert(field)) {						
				this.showSystemMessage(moduleNamespace, type, text);
				field.focus();
				return true;
			}
		}
		return false;
	};
	
	this.validateGoToNavigationPage = function (field, text1, text2) {			
	    if (this.fieldIsEmpty(field, text1)) return false;
	    else if (!this.isAllDigit(field, text2)) return false;     		
		return true;
	};
	
	this.fieldIsEmpty = function (field, text) {
		if (field != undefined) {
			if (this.allSpaces(field.value)) {
				alert(text);
				field.focus();
				return true;
			}
		}
		return false;
	};

	this.fieldIsEmptyNoAlert = function (field) {
		if (field != undefined) {
			if (this.allSpaces(field.value)) {
				field.focus();
				return true;
			}
		}
		return false;
	};
	
	this.fieldIsNotDateShowMessage = function (moduleNamespace, field, type, text) {
		if (field != undefined) {
			if (!this.checkDate(field.value)) {
				this.showSystemMessage(moduleNamespace, type, text);
				field.focus();
				return true;
			}
		}
		return false;
	};
	
	this.fieldIsNotDate = function (field, text) {
		if (field != undefined) {
			if (!this.checkDate(field.value)) {
				alert(text);
				field.focus();
				return true;
			}
		}
		return false;
	};
	
	this.fieldDatesItervalNotValidNoAlert = function (field, field2) {
		if (field != undefined && field2 != undefined) {
			if (!this.checkDateInterval(field.value, field2.value)) {
				field.focus();
				return true;
			}
		}
		return false;
	};
	
	this.checkDate = function (value) {
		if (value != null) {
			value = value.trim();
			var tmp = value.split(".");
			if (tmp.length != 3) return false;
			year = tmp[2];
			if (isNaN(parseFloat(year)) || year.length != 4) return false;
			// format D(D)/M(M)/YYYY
			var dateFormat = /^\d{1,4}[\.|\/|-]\d{1,2}[\.|\/|-]\d{1,4}$/;
			if (dateFormat.test(value)) {
				// remove any leading zeros from date values
				value = value.replace(/0*(\d*)/gi,"$1");
				var dateArray = value.split(/[\.|\/|-]/);
				// correct month value
				dateArray[1] = dateArray[1]-1;
				// correct year value
				if (dateArray[2].length<4) {
					// correct year value
					dateArray[2] = (parseInt(dateArray[2]) < 50) ? 2000 + parseInt(dateArray[2]) : 1900 + parseInt(dateArray[2]);
				}
				var testDate = new Date(dateArray[2], dateArray[1], dateArray[0]);
				if (testDate.getDate()!=dateArray[0] || testDate.getMonth()!=dateArray[1] || testDate.getFullYear()!=dateArray[2]) {
					return false;
				} else {
					return true;
				}
			} else {
				return false;
			}
		}
		return false;
	};
	
	this.checkDateInterval = function (value1, value2) {
		if (parseFloat(value1.substring(6, 10)) > parseFloat(value2.substring(6, 10))) {
			return false;
		} else if (parseFloat(value1.substring(6, 10)) == parseFloat(value2.substring(6, 10))) { // if years are equal
			if (parseFloat(value1.substring(3, 5)) > parseFloat(value2.substring(3,5))) {
				return false;
			} else if (parseFloat(value1.substring(3, 5)) == parseFloat(value2.substring(3, 5))) { // if months are equal
				if (parseFloat(value1.substring(0, 2)) > parseFloat(value2.substring(0, 2))) {
					return false;
				}
			}
		}
		return true;
	};
	
	this.fieldIsNotDigitENLetterOrSymbolsSetMsgToField = function (moduleNamespace, field, symbols, type,  text) {
		if (field != undefined) {
			if (!this.isDigitENLetterOrSymbols(field.value, symbols)) {						
				this.showSystemMessage(moduleNamespace,type, text);
				field.focus();
				return true;
			}
		}
		return false;
	};
	
	this.fieldIsNotDigitENLetterOrSymbols = function (field, symbols) {
		if (field != undefined) {
			if (!this.isDigitENLetterOrSymbols(field.value, symbols)) {	
				return true;
			}
		}
		return false;
	};
	
	this.fieldIsNotDigitLetterOrSymbolsSetMsgToField = function (moduleNamespace, field, symbols, type,  text) {
		if (field != undefined) {
			if (!this.isDigitLetterOrSymbols(field.value, symbols)) {						
				this.showSystemMessage(moduleNamespace,type, text);
				field.focus();
				return true;
			}
		}
		return false;
	};

	this.fieldIsNotDigitLetterOrSymbols = function (field, symbols) {
		if (field != undefined) {
			if (!this.isDigitLetterOrSymbols(field.value, symbols)) {						
				field.focus();
				return true;
			}
		}
		return false;
	};
	
	this.fieldIsNotDigitLetterOrDashSetMsgToField = function (moduleNamespace, field, type,  text) {
		if (field != undefined) {
			if (!this.isDigitLetterOrDash(field.value)) {						
				this.showSystemMessage(moduleNamespace,type, text);
				field.focus();
				return true;
			}
		}
		return false;
	};
	
	this.fieldIsNotCorrectDigitSetMsgToField = function (moduleNamespace, field, type,  text) {
		if (field != undefined) {
			if (!this.hasOnlyDigits(field.value)) {						
				this.showSystemMessage(moduleNamespace,type, text);
				field.focus();
				return true;
			}
		}
		return false;
	};
	
	this.fieldNotContainsLetterOrDigitOrUnderscore = function (moduleNamespace, field, type,  text) {
		if (field != undefined) {
			var str = field.value;
			if (!this.allSpaces(str)) {
				var foundLeft = false;
				var fL = -1;
				var foundRight = false;
				var fR = -1;
				for (var i = 0; i < str.length; i++) {
					if (str.charAt(i) == '\\') {
						if (foundLeft && i == (fL + 1)) {
							this.showSystemMessage(moduleNamespace, type, text);
							field.focus();
							return true;	
						} else {
							foundLeft = true;
							fL = i;
						}			
					} 
					if (str.charAt(i) == '/') {
						if (foundRight && i == (fR + 1)) {
							this.showSystemMessage(moduleNamespace, type, text);
							field.focus();
							return true;	
						} else {
							foundRight = true;
							fR = i;	
						}			
					}  
				}
				
				for (var i = 0; i < str.length; i++) {
					if (this.isLetterOrDigit(str.charAt(i)) || str.charAt(i) == '_') {
						return false;			
					} 	
				}
				this.showSystemMessage(moduleNamespace, type, text);
				field.focus();
				return true;	
			}
		}
		return false;
	};
	
	this.isLetterOrDigit = function (pword) {
		return (this.isENLetter(pword) || this.isDigit(pword));
	};
	
	this.isAllDigitNoAlert = function (field) {
		if (field != undefined) {
			value = field.value;	
			for ( var i = 0; i < value.length; i++) {
				if (!this.isDigit(value.charAt(i))) {					
					field.focus();
					return false;
				}
			}
			return true;
		} 
		return false;		
	};
	
	this.isAllDigit = function (field, text) {
		if (field != undefined) {
			value = field.value;	
			for ( var i = 0; i < value.length; i++) {
				if (!this.isDigit(value.charAt(i))) {
					alert(text);	
					field.focus();
					return false;
				}
			}
			return true;
		} 
		return false;		
	};
	
	this.isDigitENLetterOrSymbols = function (value, symbols) {
		if (value != null && value.length > 0) {
			value = value.trim();
			var found = false;
			for (var i = 0; i < value.length; i++) {
				found = false;
				if (!(this.isDigit(value.charAt(i)) || this.isENLetter(value.charAt(i)))) {	
					for (var j = 0; j < symbols.length; j++) {
						if (symbols[j] == value.charAt(i)) {
							found = true;
							break;
						}
					}			
					if (!found) return false;
				}
			}
			return true;
		}
		return false;
	};
	
	this.isDigitLetterOrSymbols = function (value, symbols) {
		if (value != null && value.length > 0) {
			value = value.trim();
			var found = false;
			for (var i = 0; i < value.length; i++) {
				found = false;
				if (!(this.isDigit(value.charAt(i)) || this.isLetter(value.charAt(i)))) {	
					for (var j = 0; j < symbols.length; j++) {
						if (symbols[j] == value.charAt(i)) {
							found = true;
							break;
						}
					}			
					if (!found) return false;
				}
			}
			return true;
		}
		return false;
	};
	
	this.isDigitLetterOrDash = function (value) {
		if (value != null && value.length > 0) {
			for ( var i = 0; i < value.length; i++) {
				if (!(this.isDigit(value.charAt(i)) || this.isENLetter(value.charAt(i)) || '-' == value.charAt(i))) {									
					return false;
				}
			}
			return true;
		}
		return false;
	};
	
	this.hasOnlyDigits = function (value) {
		if (value != null && value.length > 0) {
			for ( var i = 0; i < value.length; i++) {
				if (!this.isDigit(value.charAt(i))) {									
					return false;
				}
			}
			return true;
		}
		return false;
	};

	this.isDigit = function (pword) {
		return ((pword >= "0") && (pword <= "9"));
	};
	
	this.isENLetter = function(pword) {
		return (((pword >= "a") && (pword <= "z")) || ((pword >= "A") && (pword <= "Z")));
	};
		
	this.isLetter = function(pword) {
		return (((pword >= "a") && (pword <= "z")) || ((pword >= "A") && (pword <= "Z")) || ((pword >= "а") && (pword <= "я")) || ((pword >= "А") && (pword <= "Я")));
	};
	
	this.clearSelect = function (element) {
		if (element != undefined) {
			for ( var i = element.length; i > 0; i--) {
				element.options[i] = null;
			}		
		}
	};
	
	this.selectValueNotChosen = function (moduleNamespace, field, type,  text) {
		if (field != undefined) {
			if (this.allSpaces(field.value)) {
				this.showSystemMessage(moduleNamespace, type, text);
				field.focus();	
				return true;
			}
		}
		return false;
	};
	
	this.selectValueNotSelected = function (moduleNamespace, field, type,  text) {
		if (field != undefined) {
			if (field.value == "-1") {
				this.showSystemMessage(moduleNamespace, type, text);
				field.focus();	
				return true;
			}
		}
		return false;
	};
	
	this.selectHasNoValues = function (moduleNamespace, field, type,  text) {
		if (field != undefined) {
			if (field.options.length == 0) {
				this.showSystemMessage(moduleNamespace, type, text);
				field.focus();				
			} else {
				return false;
			}
		}
		return true;
	};
	
	this.fieldNotEndsWith = function (moduleNamespace, field, type, endsStr, text) {		
		if (field != undefined) {
			if (field.value.trim().length > 0) {
				if (endsStr != null && endsStr.length > 0) {
					for ( var i = 0; i < endsStr.length; i++) {
						if (!field.value.trim().endsWith(endsStr[i])) {
							this.showSystemMessage(moduleNamespace, type, text);
							field.focus();				
							return true;
						} else {
							return false;
						}
					}
					return false;
				}
			} 
		}
		return true;
	};
	
	this.fieldNotStartsWith = function (moduleNamespace, field, type, startStr, text) {		
		if (field != undefined) {
			if (field.value.trim().length > 0) {
				if (startStr != null && startStr.length > 0) {
					for ( var i = 0; i < startStr.length; i++) {
						if (!field.value.trim().startsWith(startStr[i])) {
							this.showSystemMessage(moduleNamespace, type, text);
							field.focus();				
							return true;
						} else {
							return false;
						}
					}
					return false;
				}
			} 
		}
		return true;
	};
	
	this.fieldValueDifferentFromExpected = function (moduleNamespace, field, type, value, text) {		
		if (field != undefined) {
			if (field.value.trim().length > 0) {
				if (value != null && value.length > 0) {
					if (field.value.trim() != (value.trim())) {
						this.showSystemMessage(moduleNamespace, type, text);
						field.focus();				
						return true;
					} else {
						return false;
					}
				}
			} 
		}
		return true;
	};
	
	this.checkAllRequiredFields = function(formId, fields) {
		var f = document.getElementById(formId);
		var field = null;
		if (fields != null && fields.length > 0) {
			for (var i = 0; i < fields.length; i++) {
				field = f.elements[fields[i]];				
				if (field != undefined && this.allSpaces(field.value)) {					
					return false;
				}
			}
		}
		return true;
	};
	this.isHasEmail = function (pword) {
		return ((pword == '-') || (pword == '.') || (pword == '@') || (pword == '_') || this.isLetterOrDigit(pword));
	};
	
	this.fieldIsEmailInvalid = function(moduleNamespace, field, type,  text){
		if (field != undefined) {
			if (!this.checkEmailValidity(field.value)) {	
				this.showSystemMessage(moduleNamespace, type, text);
				field.focus();		
				return true;
			}
		}
		return false;
	};
	this.checkEmailValidity = function (str) {
		var dot = 0;
		var mail = 0;
		if (str == "")
			return true;
		for ( var i = 0; i < str.length; i++) {
			if ((str.charAt(i) == " " && i != (str.length - 1))
					|| (!this.isHasEmail(str.charAt(i))))
				return false;
			else if ((str.charAt(i) == "@" && i == 0)
					|| (str.charAt(i) == "@" && i == (str.length - 1))
					|| str.charAt(i) == "\"")
				return false;
			if (str.charAt(i) == "@")
				mail = 1;
			if (mail == 1)
				if (str.charAt(i) == "."
						&& (i >= (str.length - 2) || str.charAt(i - 1) == "@"))
					return false;
			if (str.charAt(i) == ".")
				if (mail == 1)
					dot = 1;
		}
		if (dot == 0 || mail == 0)
			return false;
		else
			return true;
	};
	this.checkAllRequiredFields = function(formId, fields) {
		var f = document.getElementById(formId);
		var field = null;
		if (fields != null && fields.length > 0) {
			for (var i = 0; i < fields.length; i++) {
				field = f.elements[fields[i]];				
				if (field != undefined && this.allSpaces(field.value)) {					
					return false;
				}
			}
		}
		return true;
	};
	this.generateUUID = function() {
		 var chars = '0123456789abcdef'.split('');
		 var uuid = [], rnd = Math.random, r;
		 for (var i = 0; i < 36; i++) {
		      if (!uuid[i]) {
		         r = 0 | rnd()*16;
		         uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r & 0xf];
		      }
		 }
		 return uuid.join('');
	};
	this.getY = function ( oElement ) {
		var iReturnValue = 0;
		while( oElement != null ) {
			iReturnValue += oElement.offsetTop;
			oElement = oElement.offsetParent;
		}
		return iReturnValue;
	};

	this.getX = function ( oElement ) {
		var iReturnValue = 0;
		while( oElement != null ) {
			iReturnValue += oElement.offsetLeft;
			oElement = oElement.offsetParent;
		}		
		return iReturnValue;
	};
	this.checkEnter = function (evt) {
		evt = (evt) ? evt : ((window.event) ? event : null);
		if (evt) {
			var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
			if (elem) {
				var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);
				if (charCode == 13) {
					return true;
				} else {
					return false;
				}
			}
		}
		return false;
	};

	this.getWindowAjaxLoader = function (text) {
		var sb = new StringBuffer();
		sb.append('<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">');	
		sb.append('<tr height="50%" valign="bottom">');									
		sb.append('<td width="100%" align="center"><img src="' + wsgImagesLocation + 'w-ajax-loader.gif" width="32" height="32" border="0"></td>');
		sb.append('</tr>');
		sb.append('<tr valign="top" height="50%">');
		sb.append('<td width="100%" align="center">');
		sb.append('<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">');
		sb.append('<tr valign="top">');	
		sb.append('<td height="10"></td>');
		sb.append('</tr>');	
		sb.append('<tr valign="top">');	
		sb.append('<td width="100%" align="center" class="text11">' + text + '</td>');
		sb.append('</tr>');	
		sb.append('</table>');	
		sb.append('</td>');
		sb.append('</tr>');		
		sb.append('</table>');			
		return sb.toString();
	};
	this.getWindowAjaxLoaderWithHeight = function (text, height) {
		var sb = new StringBuffer();
		sb.append('<table cellpadding="0" cellspacing="0" border="0" width="100%" height="' + height + '">');	
		sb.append('<tr height="50%" valign="bottom">');									
		sb.append('<td width="100%" align="center"><img src="' + wsgImagesLocation + 'w-ajax-loader.gif" width="32" height="32" border="0"></td>');
		sb.append('</tr>');
		sb.append('<tr valign="top" height="50%">');
		sb.append('<td width="100%" align="center">');
		sb.append('<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">');
		sb.append('<tr valign="top">');	
		sb.append('<td height="10"></td>');
		sb.append('</tr>');	
		sb.append('<tr valign="top">');	
		sb.append('<td width="100%" align="center" class="text11">' + text + '</td>');
		sb.append('</tr>');	
		sb.append('</table>');	
		sb.append('</td>');
		sb.append('</tr>');		
		sb.append('</table>');			
		return sb.toString();
	};
	this.getAjaxLoader = function () {
		return '<img src="' + wsgImagesLocation + 'progress-anim.gif" width="16" height="16" border="0">';
	};
	this.getErrorIcon = function () {
		return wsgImagesLocation + 'icon_error.png';
	};
	this.getWarningIcon = function(){
		return wsgImagesLocation + 'icon_warning.png';
	};
	this.getInfoIcon = function () {
		return wsgImagesLocation + 'icon_info.png';
	};
	this.submitForm = function (formId) {
		if (document.getElementById(formId) != undefined) {
			if (!_eventListener.hasRegisteredClickEvent()) {
				_eventListener.registerClickEvent();
				document.getElementById(formId).submit();
			}
		}
	};
	this.showItem = function(id) {
		if (document.getElementById(id) != undefined) {
			document.getElementById(id).style.visibility = "visible";
		}
	};
	this.hideItem = function (id) {
		if (document.getElementById(id) != undefined) {
			document.getElementById(id).style.visibility = "hidden";
		}
	};
	this.navigate = function (location) {
		if (!_eventListener.hasRegisteredClickEvent()) {
			_eventListener.registerClickEvent();			
			document.body.style.cursor='wait';
			document.location.href = location;
		}
	};	
	this.checkKeyPressed = function (evt, code) {
		evt = (evt) ? evt : ((window.event) ? event : null);
		if (evt) {
			var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
			if (elem) {
				var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);
				if (charCode == code) {
					return true;
				} else {
					return false;
				}
			}
		}
		return false;
	};	
	this.getXMLFromText = function (xml) {
		var xmlDoc = null;
		if (window.DOMParser) {
		  parser=new DOMParser();
		  xmlDoc=parser.parseFromString(xml,"text/xml"); 
		} else  {// Internet Explorer
		  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		  xmlDoc.async="false";
		  xmlDoc.loadXML(xml);
		} 
		return xmlDoc;
	};
	// THIS METHOD USE SYNCHRONOUSLY AJAX CALL...
	this.checkSession = function() {
		var wsgXMLHttpRequestObject = new WSGXMLHttpRequestObject();	
		var xmlHttpRequestObject = wsgXMLHttpRequestObject.getXMLHttpRequestObject();	
		if (xmlHttpRequestObject) {			
			var _url = encodeURI(chkSessionUrl + '?&sync=' + Math.random());
			// CHECK SYNCHRONOUSLY
			xmlHttpRequestObject.open("GET", _url, false);
			xmlHttpRequestObject.send();
			if (xmlHttpRequestObject.responseText != null) {
				var response = null;					
	            if (_ie) xmlHttpRequestObject.responseXML.loadXML(xmlHttpRequestObject.responseText);                
	            response = xmlHttpRequestObject.responseXML.documentElement;    
	            try {
	            	if (response != null && response.childNodes.length > 0) {
	                	if (response.getElementsByTagName("error") != undefined && response.getElementsByTagName("error")[0] != undefined) {
	                		if (response.getElementsByTagName("errorURL") != undefined && response.getElementsByTagName("errorURL")[0] != undefined) {
	                			document.location.href = response.getElementsByTagName("errorURL")[0].childNodes[0].nodeValue;	                			
	                		}
	                	} else if (response.getElementsByTagName("success") != undefined && response.getElementsByTagName("success")[0] != undefined) {
	                		return true;
	                	} 		                		                	
	                }	                	
	                return false;
	            } catch(e) {
	            	alert(e);
	            }
			}
			return true;
		}
	};	
	this.classExists = function (c) {
	    return (typeof(c) == "function" && typeof(c.prototype) == "object") ? true : false;
	};
	this.escapeBackSlash = function(str) {
		return str.replace(/\\/g,"\\\\");
	};
	this.escapeQuote = function(str) {
		return str.replace(/'/g,"\\'");
	};
};

BrowserDimensions.prototype = new Object();
BrowserDimensions.prototype.constructor = BrowserDimensions;
BrowserDimensions.superclass = null;

function BrowserDimensions() {
	this.body = document.body;
	if (this.isStrictDoctype() && !this.isSafari()) {
		this.body = document.documentElement;
	}
};

BrowserDimensions.prototype.getScrollFromLeft = function(){
	return this.body.scrollLeft;
};

BrowserDimensions.prototype.getScrollFromTop = function(){
	return this.body.scrollTop;
};

BrowserDimensions.prototype.getViewableAreaWidth = function(){
	return this.body.clientWidth;
};

BrowserDimensions.prototype.getViewableAreaHeight = function(){
	return this.body.clientHeight;
};

BrowserDimensions.prototype.getHTMLElementWidth = function(){
	if (this.isIE()) {
		return document.body.offsetWidth;
	} else {
		return this.body.scrollWidth;
	}		
};

BrowserDimensions.prototype.getHTMLElementHeight = function(){
	if (this.isIE()) {
		return document.body.offsetHeight;
	} else {
		return this.body.scrollHeight;
	}	
};

BrowserDimensions.prototype.isStrictDoctype = function(){
	return (document.compatMode && document.compatMode != "BackCompat");
};

BrowserDimensions.prototype.isSafari = function(){
	return (navigator.userAgent.toLowerCase().indexOf("safari") >= 0);
};	

BrowserDimensions.prototype.isIE = function(){
	return (navigator.appName == "Microsoft Internet Explorer");
};	

WSGDOMObject.prototype = new Object();
WSGDOMObject.prototype.constructor = WSGDOMObject;
WSGDOMObject.superclass = null;

function WSGDOMObject(obj) {
	this.obj = obj;
};

WSGDOMObject.prototype.display = function () {
	if (this.obj != undefined) {
		this.obj.style.display = '';
	}
};

WSGDOMObject.prototype.displayNone = function () {
	if (this.obj != undefined) {		
		this.obj.style.display = 'none';
	}
};

WSGDOMObject.prototype.displayBlock = function () {
	if (this.obj != undefined) {
		this.obj.style.display = 'block';
	}
};

WSGDOMObject.prototype.setClassName = function(className) {
	if (this.obj != undefined) {
		this.obj.className = className;
	}
};

WSGDOMObject.prototype.setAlpha = function(value) {		
	var alpha = value;
	if (_wsgUtils.allSpaces(alpha)) return;	
	alpha = alpha.toString();
	if (_ns6) {
		if (alpha == "100") {
			alpha = "1";
		} else {
			alpha = "0." + alpha.charAt(0);
		}
	}
	
	if (this.obj != undefined) {
		this.obj.style.opacity = alpha;
		if (_ie) {
			this.obj.style.filter = 'alpha(opacity=' + alpha + ')';
		} else if (_mozilla) {
			this.obj.style.MozOpacity = alpha;
		}
	}
};	

WSGDOMObject.prototype.setDisabledAlphaNotAllowedCursor = function () {
	if (this.obj != undefined) {
		this.obj.style.opacity = 0.3;
		this.obj.style.cursor = "not-allowed";
		if (_ie) {
			this.obj.style.filter = "alpha(opacity=30)";
		} else if (_mozilla) {
			this.obj.style.MozOpacity = "0.3";
		}
	}
};

WSGDOMObject.prototype.setCustomDisabledAlphaNotAllowedCursor = function (value) {
	var alpha = value.toString();
	if (alpha == null || alpha.trim().length == 0) return;	
	alpha = alpha.toString();
	if (_ns6) {
		if (alpha == "100") {
			alpha = "1";
		} else {
			alpha = "0." + alpha.charAt(0);
		}
	}
	if (this.obj != undefined) {
		this.obj.style.opacity = alpha;
		this.obj.style.cursor = "not-allowed";
		if (_ie) {
			this.obj.style.filter = 'alpha(opacity=' + alpha + ')';
		} else if (_mozilla) {
			this.obj.style.MozOpacity = alpha;
		}
	}
};

WSGDOMObject.prototype.setNormalAlphaPointerCursor = function () {
	if (this.obj != undefined) {
		this.obj.style.opacity = 1;
		this.setPointerCursor();
		if (_ie) {
			this.obj.style.filter = "alpha(opacity=100)";
		} else if (_mozilla) {
			this.obj.style.MozOpacity = "1";
		}
	}
};
WSGDOMObject.prototype.setNormalAlphaDefaultCursor = function () {
	if (this.obj != undefined) {
		this.obj.style.opacity = 1;
		this.setDefaultCursor();
		if (_ie) {
			this.obj.style.filter = "alpha(opacity=100)";
		} else if (_mozilla) {
			this.obj.style.MozOpacity = "1";
		}
	}
};
WSGDOMObject.prototype.setZeroAlphaDefaultCursor = function () {
	if (this.obj != undefined) {
		this.obj.style.opacity = 0;
		this.setDefaultCursor();
		if (_ie) {
			this.obj.style.filter = "alpha(opacity=0)";
		} else if (_mozilla) {
			this.obj.style.MozOpacity = "0";
		}	
	}
};
WSGDOMObject.prototype.setWaitCursor = function () {
	if (this.obj != undefined) {
		this.obj.style.cursor = 'wait';
	}
};
WSGDOMObject.prototype.setMoveCursor = function () {
	if (this.obj != undefined) {
		this.obj.style.cursor = 'move';
	}
};
WSGDOMObject.prototype.setDefaultCursor = function () {
	if (this.obj != undefined) {
		this.obj.style.cursor = 'default';
	}
};
WSGDOMObject.prototype.setNotAllowedCursor = function () {
	if (this.obj != undefined) {
		this.obj.style.cursor = 'not-allowed';
	}
};
WSGDOMObject.prototype.setPointerCursor = function () {
	if (this.obj != undefined) {
		this.obj.style.cursor = 'pointer';
	}
};

WSGSearchBox.prototype = new Object();
WSGSearchBox.prototype.constructor = WSGSearchBox;
WSGSearchBox.superclass = null;

function WSGSearchBox(formId, objId, text, emptyMsg, tooShortMsg, syncId) {
	this.formId = formId;
	this.objId = objId;
	this.text = text;
	this.msg = emptyMsg;
	this.tooShortMsg = tooShortMsg;
	this.syncId = syncId;
};

WSGSearchBox.prototype.focus = function () {
	if (this.objId != null) {
		obj = document.getElementById(this.objId);
		if (obj != undefined) {
			if (obj.value.trim() == this.text) {
				obj.value='';
			}
		}		
	}
};

WSGSearchBox.prototype.blur = function () {
	if (this.objId != null) {
		obj = document.getElementById(this.objId);
		if (obj != undefined) {
			if (obj.value.trim().length == 0) {
				obj.value=this.text;
			}
		}		
	}
};

WSGSearchBox.prototype.click = function () {	
	if (this.objId != null) {	
		obj = document.getElementById(this.objId);
		if (obj != undefined) {			
			if (obj.value.trim() != this.text) {
				if (obj.value.trim().length < 2) {
					alert(this.tooShortMsg);
					obj.focus();
					return;
				}
				if (document.getElementById(this.formId).elements[this.syncId] != undefined) {
					document.getElementById(this.formId).elements[this.syncId].value = _wsgUtils.generateUUID();
				}
				_wsgUtils.submitForm(this.formId);				
			} else {
				alert(this.msg);
				obj.focus();
			}
		}		
	}
};

EventListener.prototype = new Object();
EventListener.prototype.constructor = EventListener;
EventListener.superclass = null;

function EventListener() {
	this.onclickFunctions = new Array();
	this.onLoadFunctions = new Array();
	this.windows = new Array();
	this.clickEvent = false;
};

EventListener.prototype.registerOnClickFunction = function(functionName, parameters) {
	this.onclickFunctions[this.onclickFunctions.length] = functionName;
	this.onclickFunctions[this.onclickFunctions.length] = parameters;
};

EventListener.prototype.getOnClickFunctions = function() {
	return (this.onclickFunctions != null) ? this.onclickFunctions : new Array();
};

EventListener.prototype.setOnClickFunctions = function(functions) {
	return this.onclickFunctions = functions;
};
EventListener.prototype.registerWindow = function(window) {	
	var founded = false;
	for (var i = 0; i < this.windows.length; i++) {
		if (this.windows[i].id == window.id) {
			founded = true;
			break;
		}
	}
	if (!founded) this.windows[this.windows.length] = window;
};
EventListener.prototype.releaseWindow = function(windowId) {
	var filtered = new Array();
	for (var i = 0; i < this.windows.length; i++) {		
		if (this.windows[i].id != windowId) {
			filtered[filtered.length] = this.windows[i];
		}
	}
	this.windows = filtered;
};
EventListener.prototype.hasWindow = function(windowId) {
	for (var i = 0; i < this.windows.length; i++) {	
		if (this.windows[i].id == windowId) {
			return true;
		}
	}
	return false;
};
EventListener.prototype.getWindow = function(windowId) {
	for (var i = 0; i < this.windows.length; i++) {	
		if (this.windows[i].id == windowId) {
			return this.windows[i];
		}
	}
	return false;
};
EventListener.prototype.registerClickEvent = function() {
	this.clickEvent = true;
};
EventListener.prototype.releaseClickEvent = function() {
	this.clickEvent = false;
};
EventListener.prototype.hasRegisteredClickEvent = function() {
	return this.clickEvent;
};
EventListener.prototype.addOnloadFunction = function(func) {
	this.onLoadFunctions[this.onLoadFunctions.length] = func;	
};
EventListener.prototype.getOnloadFunctions = function() {
	return this.onLoadFunctions;	
};
EventListener.prototype.removeOnloadFunction = function(func) {
	var tmp = new Array();
	if (this.hasOnloadFunction()) {		
		for ( var i = 0; i < this.onLoadFunctions.length; i++) {
			if (this.onLoadFunctions[i] == func) continue;
			tmp[tmp.length] = this.onLoadFunctions[i];
		}
	}	
};
EventListener.prototype.hasOnloadFunction = function() {
	return (this.onLoadFunctions.length > 0);
};

ContextMenu.prototype = new Object();
ContextMenu.prototype.constructor = ContextMenu;
ContextMenu.superclass = null;
	
function ContextMenu(instanceName) {
	this.id = "id_" + _wsgUtils.generateUUID();
	this.tableId = "tID_" + _wsgUtils.generateUUID();
	this.menucontents = new Array();
	this.menuWidth = 0;
	this.menuHeight = 0;
	this.disappearDelay = 700;
	this.hidemenu_onclick = "yes";
	this.delayHide = 0;
	this.menu = null;
	this.over = false;
	this.instanceName = instanceName;
};

ContextMenu.prototype.createDIV = function() {
	var newdiv = document.createElement('div');
	newdiv.setAttribute('id', this.id);
	newdiv.style.visibility = 'hidden';
	newdiv.style.position = "absolute";
	newdiv.style.zIndex = 100;	
	newdiv.style.top = 0;
	newdiv.style.left = 0;
	document.body.appendChild(newdiv);
	this.menu = newdiv;
};

ContextMenu.prototype.showContextMenu = function(url, object, event) {	
	// EVENT OBJECT IS NOT ACTIVE WITHIN AJAX FUNCTION FOR IE...
	if (this.menu != null && this.menu.style.visibility == "visible") {		
		this.menu.style.visibility = "hidden";
		return;
	}	
	var wsgXMLHttpRequestObject = new WSGXMLHttpRequestObject();	
	var xmlHttpRequestObject = wsgXMLHttpRequestObject.getXMLHttpRequestObject();	
	var _this = this;
	var _src = object.src;
	if (xmlHttpRequestObject) {	
		var _url = encodeURI(url + '?&sync=' + Math.random());
		xmlHttpRequestObject.open("GET", _url);
		xmlHttpRequestObject.onreadystatechange = function() {
			if (xmlHttpRequestObject.readyState == 4 && xmlHttpRequestObject.status == 200) {				
				var response = null;					
				var msgTxt = null;				
				var msgType = null;							
                if (_ie) xmlHttpRequestObject.responseXML.loadXML(xmlHttpRequestObject.responseText);                
                response = xmlHttpRequestObject.responseXML.documentElement;    
                new WSGDOMObject(object).setPointerCursor();
                try {                              	
                	var results = null;                                  	   
                	if (response != null && response.childNodes.length > 0) {
	                	if (response.getElementsByTagName("error") != undefined && response.getElementsByTagName("error")[0] != undefined) {
	                		if (response.getElementsByTagName("errorURL") != undefined && response.getElementsByTagName("errorURL")[0] != undefined) {
	                			document.location.href = response.getElementsByTagName("errorURL")[0].childNodes[0].nodeValue;
	                			return;
	                		}
	                		_this.menucontents = new Array();
	                		_this.add("#", response.getElementsByTagName("error")[0].childNodes[0].nodeValue, false);
	                	} else if (response.getElementsByTagName("success") != undefined && response.getElementsByTagName("success")[0] != undefined) {	                		
	                		var title;
		                    var url;
		                    var internalCall;
		                    var confirmAlert;
		                    var i = 0;
		                    _this.menucontents = new Array();
		                    while (i >= 0) {	  
		                    	if (i == 0) {
		                    		i++;
		                    		continue;
		                    	}
		                        link = response.childNodes[i];
		                        if (link != null) {		                        	
		                        	title = (link.childNodes[0] != undefined && link.childNodes[0].firstChild != undefined) ? link.childNodes[0].firstChild.data : null;
		                        	url = (link.childNodes[1] != undefined && link.childNodes[1].firstChild != undefined) ? link.childNodes[1].firstChild.data : "#";				                        	
		                        	internalCall = (link.childNodes[2] != undefined && link.childNodes[2].firstChild != undefined) ? link.childNodes[2].firstChild.data : null;
		                        	confirmAlert = (link.childNodes[3] != undefined && link.childNodes[3].firstChild != undefined) ? link.childNodes[3].firstChild.data : null;
		                        	if (title != null) {		                        		
		                        		_this.add(url, title, ((true == internalCall) ? true : false), confirmAlert);
		                        	}
		                        	i++;
		                        } else {
		                            i = -1;
		                        }
		                    }
	                	} 
	                }
                	_this.show(object, event);	
	                wsgXMLHttpRequestObject.killXML(xmlHttpRequestObject);	                             
                } catch(e) {
                	alert(e);
                }                                
                _this.showLauncher(object.id, _src);
			} else if (xmlHttpRequestObject.readyState != 0) {						
				_this.showLoadingLauncher(object.id, wsgImagesLocation);
				new WSGDOMObject(object).setWaitCursor();				
			} else {
				alert("There was a problem retrieving the XML data!");
				new WSGDOMObject(object).setPointerCursor();
			}
		};
		xmlHttpRequestObject.send(null);
	}
};

ContextMenu.prototype.add = function(link, title, type) {
	this.menucontents[this.menucontents.length] = new Array(link, title, type, null);
};

ContextMenu.prototype.add = function(link, title, type, confirmAlert) {
	this.menucontents[this.menucontents.length] = new Array(link, title, type, confirmAlert);
};

ContextMenu.prototype.showHide = function(obj, e, visible, hidden){
	var evtType = (_ie) ? e : e.type;
	if (evtType == "click" && obj.visibility == hidden || evtType == "mouseover") {		
		obj.visibility = visible;
	} else if (evtType == "click") {		
		obj.visibility = hidden;
	}
};

ContextMenu.prototype.populate = function () {
	var str = new StringBuffer();
	var maxMenuWidth = 0;
	var maxMenuHeight = 0;	
	if (this.menucontents != undefined && this.menucontents.length > 0) { 			
		str.append('<table class="context-menu-table" id="' + this.tableId + '" onmouseover="_wsgDynContextMenuContainer.get(\'' + this.instanceName + '\').clearHideMenu();" onmouseout="_wsgDynContextMenuContainer.get(\'' + this.instanceName + '\').dynamicHide(event);">');
		for ( var i = 0; i < this.menucontents.length; i++) {
			link = this.menucontents[i][0];			
			title = this.menucontents[i][1];
			internalScope = this.menucontents[i][2];
			confirmAlert = this.menucontents[i][3];
			if (confirmAlert != null) {
				if (internalScope) {				
					str.append('<tr><td nowrap="nowrap" onclick="if (confirm(\'' + confirmAlert + '\')) {' + link + ';}" onmouseover="this.className=\'context-menu-row-hover\';" onmouseout="this.className=\'context-menu-row\';">');
				} else {
					str.append('<tr><td nowrap="nowrap" onclick="if (confirm(\'' + confirmAlert + '\')) {document.location.href=\'' + link + '\';}" onmouseover="this.className=\'context-menu-row-hover\';" onmouseout="this.className=\'context-menu-row\';">');
				}
			} else {
				if (internalScope) {
					str.append('<tr><td nowrap="nowrap" onclick="' + link + ';" onmouseover="this.className=\'context-menu-row-hover\';" onmouseout="this.className=\'context-menu-row\';">');
				} else {
					str.append('<tr><td nowrap="nowrap" onclick="document.location.href=\'' + link + '\';" onmouseover="this.className=\'context-menu-row-hover\';" onmouseout="this.className=\'context-menu-row\';">');
				}
			}
			if (title.indexOf('<') != -1) {
				str.append('<span>' + title + '</span>');
			} else {				
				str.append('<span class="context-menu-item" title="' + title + '">' + title + '</span>');
			}
			str.append('</td></tr>');
		} 						
		str.append('</table>');
		this.menu.innerHTML = str.toString();		
		this.menuWidth = document.getElementById(this.tableId).offsetWidth;
		this.menuHeight = document.getElementById(this.tableId).offsetHeight;			
	}
	
// wsgObject = new WSGDOMObject(document.getElementById(this.tableId));
// wsgObject.setAlpha(94);
};

ContextMenu.prototype.show = function (obj, e){	
	// CHECK SESSION...
	if (!_wsgUtils.checkSession()) return false;
	if (this.hidemenu_onclick = "yes") {		
		_eventListener.registerOnClickFunction("_wsgDynContextMenuContainer.get('" + this.instanceName + "')" + ".hide", this.id);
	}	
	if (window.event) {
		event.cancelBubble = true;
	} else if (e.stopPropagation) {
		e.stopPropagation();
	}
	this.clearHideMenu();
	this.createDIV();
	this.populate();	
	if (_ie || _ns6){		
		var bd = new BrowserDimensions();
		var maxX = bd.getScrollFromLeft() + bd.getViewableAreaWidth();
		var maxY = bd.getScrollFromTop() + bd.getViewableAreaHeight();
		var minX = bd.getScrollFromLeft();
		var minY = bd.getScrollFromTop();
		
		var posX = parseInt(_wsgUtils.getX(obj), 10);
		var posY = parseInt(_wsgUtils.getY(obj), 10);
		
		var imageWidth = obj.width;
		var imageHeight = obj.height;
		if (imageWidth == "") {
			imageWidth = obj.style.width;
			if (imageWidth == "") {
				imageWidth = 5;
			}
		}	
		if (imageHeight == "") {
			imageHeight = obj.style.height;
			if (imageHeight == "") {
				imageHeight = 5;
			}
		}	
		
		imageHeight = parseInt(imageHeight, 10);
		imageWidth = parseInt(imageWidth, 10);
		
		var type = "";
		if (posX + this.menuWidth + imageWidth > maxX) {
			if (posY + this.menuHeight + imageHeight > maxY) {
				type = "TL";
			} else {
				type = "BL";
			}
		} else {
			if (posY + this.menuHeight + imageHeight > maxY) {
				type = "TR";
			} else {
				type = "BR";
			}
		}						
//		this.showHide(this.menu.style, e, "visible", "hidden");
		this.menu.style.visibility = "visible";
		if (type == "TL") {
			this.menu.x = posX - this.menuWidth;	
			this.menu.y = posY - this.menuHeight + Math.floor(imageHeight/2) - 1;				
			this.menu.style.left = (posX - this.menuWidth) + "px";
			this.menu.style.top = (posY - this.menuHeight + Math.floor(imageHeight/2) - 1) + "px";	
		} else if (type  ==  "TR") {
			this.menu.x = posX + imageWidth + 1;	
			this.menu.y = posY - this.menuHeight + Math.floor(imageHeight/2) - 1;			
			this.menu.style.left = (posX + imageWidth + 1) + "px";
			this.menu.style.top = (posY - this.menuHeight + Math.floor(imageHeight/2) - 1) + "px";				
		} else if (type  ==  "BL") {
			this.menu.x = posX - this.menuWidth;	
			this.menu.y = posY + imageHeight - Math.floor(imageHeight/2) - 1;		
			this.menu.style.left = (posX - this.menuWidth) + "px";
			this.menu.style.top = (posY + imageHeight - Math.ceil(imageHeight/2) - 1) + "px";
		} else {
			this.menu.x = posX + imageWidth + 1;	
			this.menu.y = posY + imageHeight - Math.floor(imageHeight/2) - 1;			
			this.menu.style.left = (posX + imageWidth + 1) + "px";
			this.menu.style.top = (posY + imageHeight - Math.ceil(imageHeight/2) - 1) + "px";				
		}		
	}

	return this.clickReturnValue();
};

ContextMenu.prototype.clickReturnValue = function (){
	if (_ie || _ns6) return false;
	else return true;
};

ContextMenu.prototype.contains__ns6 = function (a, b) {
	if (b != undefined && b != null) {
		try {
			while (b.parentNode) {
				if ((b = b.parentNode) == a) {
					return true;
				}
			}	
		} catch (e) {};
	}
	return false;
};

ContextMenu.prototype.dynamicHide = function (e){
	obj = document.getElementById(this.tableId);
	if (_ie && obj != undefined && !obj.contains(e.toElement)) {		
		this.delayHideMenu();
	} else if (_ns6 && e.currentTarget != e.relatedTarget&& !this.contains__ns6(e.currentTarget, e.relatedTarget)) {
		this.delayHideMenu();
	}
};

ContextMenu.prototype.delayHideMenu = function(){
	if (_ie || _ns6) {		
		this.delayHide = setTimeout(new Function("_wsgDynContextMenuContainer.get('" + this.instanceName + "')" + ".hide('" + this.id + "')"), this.disappearDelay);
	}
};

ContextMenu.prototype.clearHideMenu = function(){
	if (typeof this.delayHide != "undefined") {		
		clearTimeout(this.delayHide);
	}
};

ContextMenu.prototype.hide = function(id) {
	var functions = _eventListener.getOnClickFunctions();
	var activeFunctions = new Array();
	try {					
		this.destroy(id);
		this.menu = null;
		for (var i = 0, j = 0; i < functions.length; i++) {
			functionName = functions[i];
			functionParameters = functions[i+1];
			i++;
			if (!("_wsgDynContextMenuContainer.get('" + this.instanceName + "')" + ".hide") == functionName && id == functionParameters) {
				activeFunctions[j] = functionName;
				activeFunctions[j+1] = functionParameters;
				j++;
			}			
		}
		_eventListener.setOnClickFunctions(activeFunctions);
	} catch (e) {}				
};

ContextMenu.prototype.destroy = function (id) {
	try {			
		document.body.removeChild(document.getElementById(id));
	} catch (e) {}	
};

ContextMenu.prototype.showLauncher= function (id, location) {
	obj = document.getElementById(id);
	if (obj != undefined) {
		obj.src = location;
	}
};

ContextMenu.prototype.hideLauncher= function (id, location) {
	obj = document.getElementById(id);
	if (obj != undefined) {
		obj.src = location + 'blank.gif';
	}
};

ContextMenu.prototype.showLoadingLauncher= function (id, location) {
	obj = document.getElementById(id);
	if (obj != undefined) {
		obj.src = location + 'progress-anim.gif';
	}
};

WSGBlockerObject.prototype = new Object();
WSGBlockerObject.prototype.constructor = WSGBlockerObject;
WSGBlockerObject.superclass = null;

function WSGBlockerObject() {	
	this.id = "_wsgBlockerObjID_" + _wsgUtils.generateUUID();
	this.depth = 50;
	this.shown = false;
};

WSGBlockerObject.prototype.show = function () {
	if (this.shown) return false;
	var newdiv = document.createElement('div');
	newdiv.setAttribute('id', this.id);
	newdiv.style.position = "absolute";
	newdiv.style.zIndex = this.depth;
	newdiv.style.left = "0px";
	newdiv.style.top = "0px";
	newdiv.style.backgroundColor = '#333333';
	var bd = new BrowserDimensions();
	var maxX = bd.getHTMLElementWidth();
	var maxY = bd.getHTMLElementHeight();
	newdiv.style.width=maxX + 'px';
	newdiv.style.height=maxY + 'px';
	newdiv.x = 0; 
	newdiv.y = 0;			
	document.body.appendChild(newdiv);	
	this.showFadeIn();
	this.shown = true;
	_wsgBlockers[_wsgBlockers.length] = this.depth;
//	new WSGDOMObject(newdiv).setAlpha(20);
//	new WSGDOMObject(newdiv).setNotAllowedCursor();
};

WSGBlockerObject.prototype.changeDepth = function (depth) {
	var obj = document.getElementById(this.id);
	obj.style.zIndex = depth;
	_wsgBlockers[_wsgBlockers.length] = depth;
};

WSGBlockerObject.prototype.hide = function () {	
	try {	
		if (_wsgBlockers.length > 0) {
			_wsgBlockers.splice(_wsgBlockers.length - 1, 1);
		}
		//alert(_wsgBlockers.length);
		if (_wsgBlockers.length > 0) {
			var topShownBlockerDepth = _wsgBlockers[_wsgBlockers.length - 1];
			var obj = document.getElementById(this.id);
			obj.style.zIndex = topShownBlockerDepth;	
			//alert(topShownBlockerDepth);
		} else {
			document.body.removeChild(document.getElementById(this.id));
			this.shown = false;
		}
		
		clearTimeout(_windowBlockerTimeOut);				
	} catch (e) {}	
};

WSGBlockerObject.prototype.showFadeIn = function() {
	var element = document.getElementById(this.id);
	if (element == null) return;	 
	new WSGDOMObject(element).setAlpha(0);
	_windowBlockerTimeOut = setTimeout("_wsgBlockerObject.animateFadeIn('" + this.id + "')", 10);	  
};

WSGBlockerObject.prototype.animateFadeIn = function (id) {
	var element = document.getElementById(id);
	if (element == undefined || element == null) {
		clearTimeout(_windowBlockerTimeOut);		
		return;
	}
	
	if (element.style.opacity >= 0.2) {
	    element.style.opacity = 0.2;
	    element.style.filter = 'alpha(opacity = 20)';	    
	    clearTimeout(_windowBlockerTimeOut);
	    new WSGDOMObject(element).setNotAllowedCursor();
	    return;
	}
	
	var currentOpVal = parseFloat(element.style.opacity);
	var newOpVal = currentOpVal + 0.04;		
	newOpVal = Math.round(newOpVal * 100) / 100;	 
	element.style.opacity = newOpVal;
	element.style.filter = 'alpha(opacity = ' + (newOpVal*100) + ')';
	_windowBlockerTimeOut = setTimeout("_wsgBlockerObject.animateFadeIn('" + id + "')", 33);
};

WSGBlockerObject.prototype.resize = function () {	
	if (!this.shown) return;
	var obj = document.getElementById(this.id);
	var bd = new BrowserDimensions();
	var maxX = bd.getHTMLElementWidth();
	var maxY = bd.getHTMLElementHeight();
	obj.style.width=maxX + 'px';
	obj.style.height=maxY + 'px';
};

WSGTrashObject.prototype = new Object();
WSGTrashObject.prototype.constructor = WSGTrashObject;
WSGTrashObject.superclass = null;
	
function WSGTrashObject() {
	this.id = _wsgTrashObjectId;	
};

WSGTrashObject.prototype.getX = function () {
	return _wsgUtils.getX(document.getElementById(this.id));
};

WSGTrashObject.prototype.getY = function () {
	return _wsgUtils.getY(document.getElementById(this.id));
};


var _wsgUtils = new WSGUtils();
var _eventListener = new EventListener();
var _wsgDynContextMenuContainer = new HashMap();
var _wsgBlockerObject = new WSGBlockerObject();

window.onload = function() { 	
	document.onclick = function() { 
		var functions = _eventListener.getOnClickFunctions();
		for (i = 0; i < functions.length; i++){			
			eval(functions[i] + "('" + functions[i+1] + "')");
			i++;		
		}		
	}; 
};
window.onresize = function (){	
	_wsgBlockerObject.resize();	
};
