	function openWindow(url, winName, features) {
		return window.open(url, winName, features);
	}
	
	function checkUncheckAll(theElement) {
		var theForm = theElement.form, z = 0;
		for(z=0; z<theForm.length;z++){
			if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
				theForm[z].checked = theElement.checked;
			}
		}
	}
	
	function checkUncheckAll(theElement, action) {
		var theForm = theElement.form, z = 0;
		for (z = 0; z < theForm.length; z++ ){
			if (theForm[z].type == 'checkbox' && theForm[z].name != 'checkall') {
				switch (action) {
					case 'all':
						theForm[z].checked = true;
						break;
					
					case 'none':
						theForm[z].checked = false;
						break;
					
					default:
						theForm[z].checked = theElement.checked;
				}
			}
		}
	}
	
	function confirmSubmission (confDesc, confLink) {
		if (confirm(confDesc)) go(confLink);
	}
	
	function go(location) {
		window.location = location;
	}
	
	function looseFocus(element) {
		element.blur();
	}
	
	function showElement(idObject, txt, xyPosition, xyOffset) {
		document.getElementById(idObject).style.left = (xyPosition[0] + xyOffset[0]) + "px";
		document.getElementById(idObject).style.top = (xyPosition[1] + xyOffset[1]) + "px";
		document.getElementById(idObject).style.display = "block";
		document.getElementById(idObject + "Content").innerHTML = txt;
	}
	
	function hideElement(idObject) {
		document.getElementById(idObject).style.display = "none";
	}
	
	function getWindowSize() {
		var winW = winH = 0;
		var docX = document.documentElement ? document.documentElement : document.body ? document.body : 0;
		if (typeof(window.innerWidth) == "number" && typeof(window.innerHeight) == "number") {
			winW = window.innerWidth; winH = window.innerHeight;
		} else if (docX && docX.clientWidth && docX.clientHeight) {
			winW = docX.clientWidth; winH = docX.clientHeight;
		}
		return [winW, winH];
	}

	function getWindowScroll() {
		var scrX = 0, scrY = 0;
		if (typeof(window.pageYOffset) == 'number') { // ns+
			scrY = window.pageYOffset; scrX = window.pageXOffset;
		} else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) { // DOM
			scrY = document.body.scrollTop; scrX = document.body.scrollLeft;
		} else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) { // ie
			scrY = document.documentElement.scrollTop; scrX = document.documentElement.scrollLeft;
		}
		return [scrX, scrY];
	}

	function _objectPos(obj) {
		var curleft = curtop = 0;
		if (obj.offsetParent) {
			curleft = obj.offsetLeft; curtop = obj.offsetTop;
			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft; curtop += obj.offsetTop;
			}
		}
		return [curtop, curleft];
	}

	/** SOSTITUIRE - vedi sopra (ATTENZIONE a return) */
	function findObjectPos(obj) {
		var curleft = curtop = 0;
		if (obj.offsetParent) {
			curleft = obj.offsetLeft; curtop = obj.offsetTop;
			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft; curtop += obj.offsetTop;
			}
		}
		return [curleft, curtop];
	}

	function _keyCode(e) {
		if (!e) var e = window.event;
		return e.keyCode;
	}

	function _flash(user) {
		if (confirm("Vuoi prendere un colpo di fulmine per " + user + " ?")) {
			window.location = "index.php?mod=detail&user=" + user + "&task=sendFlash";
		}
	}
	
	function _friend(user) {
		if (confirm("Inviare la richiesta di amicizia all'utente " + user + " ?")) {
			window.location = "index.php?mod=friends&tab=requests&task=request&user=" + user;
		}
	}
	
	function _blacklist(user) {
		if (confirm("Aggiungere l'utente " + user + " alla tua lista nera ?")) {
			window.location = "index.php?mod=blacklist&task=insert&user=" + user;
		}
	}

	function _trim(str) {
		str = str.replace(/^\s+/, "");
		for (var i = str.length - 1; i > 0; i--) {
			if (/\S/.test(str.charAt(i))) {
				str = str.substring(0, i + 1);
				break;
			}
		}
		return str;
	}

	function _openChat() {
		chWinHandle = openWindow("index.php?mod=chat", "YoumeetCHAT", "top=10, left=10, width=575, height=592");
	}

	/** Funzioni Ajax */
	function _getAjax() {
		var xmlHttp;
		try { // Firefox, Opera 8.0+, Safari
			xmlHttp = new XMLHttpRequest();
		} catch (e) { // IE
			try {
				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) { // This browser does not support AJAX
					xmlHttp = false;
				}
			}
		}
		return xmlHttp;
	}

	var ajaxIn = _getAjax();
	var ajaxOut = _getAjax();
	var chWinHandle = null;