function getObj(obj) {
	
	if (document.all && !document.getElementById) {
		//alert("Internet Explorer 4");
		// Internet Explorer 4
		return document.all(obj);
	}
	if (document.all && document.getElementById) {
		//alert("Internet Explorer 5");
		// Internet Explorer 5
		return document.getElementById(obj);
	}
	if (document.layers) {
		//alert("Netscape 4");
		// Netscape 4
		return document.layers(obj);
	}
	if (!document.all && document.getElementById) {
		//alert("Netscape 6");
		// Netscape 6
		return document.getElementById(obj);
	}
	

}

function openURL(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function openPrivacy() {
	return openURL('privacy.php','','top=0,left=0,width=750,height=550,scrollbars=yes,resizable=no');	
}

function sendMail(mail) {
	alert(mail);
}

function openDirectionsPopUp(id,id_hotel) {
	return openURL('indicazioni.php?id='+id+'&idhotel='+id_hotel,'','top=0,left=0,width=595,height=595,scrollbars=yes,resizable=no');	
}


// Funzioni per la centratura delle pagine nel browser
function centerLayerOnScreen(lyName) {
	var obj = document.getElementById(lyName);
	var layerWidth;
	var screenWidth;
	var x;	
	if ( obj != null ) {
		if ( isExplorer() || isOpera() )
			screenWidth = parseInt(document.body.clientWidth);
		else
			screenWidth = parseInt(window.innerWidth);
		layerWidth = parseInt(obj.style.width);
		if ( layerWidth < screenWidth ) {
			x = eval("( " + screenWidth + " - " + layerWidth + " ) / parseInt(2) ")+10;
		} else {
			x = 0;
		}
		obj.style.left =x + "px";
		obj.style.visibility = "visible";
		return true;
	}
	return false;
}

// Funzioni sul browser utilizzato
function isExplorer() {
	if ( ( navigator != null ) && ( navigator.appName != null ) )
		if ( navigator.appName.indexOf("Explorer") != -1 ) 
			return true;
	return false;	
}

function isNetscape() {
	if ( ( navigator != null ) && ( navigator.appName != null ) )
		if ( navigator.appName.indexOf("Netscape") != -1 ) 
			return true;
	return false;	
}

function isOpera() {
	if ( ( navigator != null ) && ( navigator.appName != null ) )
		if ( navigator.appName.indexOf("Opera") != -1 ) 
			return true;
	return false;	
}

function redirect(url,target) {
	if(target == null || target=="")
		window.location = url;
	else
		eval(target).window.location = url;
}

function display(f) {
	if(getObj(f).style.display == "none" || getObj(f).style.display == "")
		getObj(f).style.display = "block";
	else
		getObj(f).style.display = "none";
}



function doAskDelete(txt,url) {
	if(confirm(txt))
		redirect(url,'');
}

function isEmail(str) {
   return (	str.length > 0 &&
		   	str.indexOf(".") > 2 && 
			str.lastIndexOf(".") > str.indexOf("@") && 
			str.indexOf("@") > 0);
}
