// JavaScript Document
function showStructure(latitudine, longitudine, icona,testohtml)
{
	divMappa = document.getElementById('testo_mappa');
	var point = new GLatLng(latitudine, longitudine);
	
	map = new GMap2(divMappa);
	map.setCenter(point, 15);
	map.addControl(new GSmallMapControl());									
	var mapControl = new GMapTypeControl();
	map.addControl(mapControl);									 
	
	markerOptions = { icon: icona };
	var marker = new GMarker(point, markerOptions);
	
	GEvent.addListener(marker, "click", function()
										{
											marker.openInfoWindowHtml(testohtml);
										});
	
	map.addOverlay(marker);								 
}

function showStructureAddress(indirizzo, icona, testohtml)
{
	divMappa = document.getElementById('testo_mappa');
	var geocoder = new GClientGeocoder();
	
	map = new GMap2(divMappa);
	geocoder.getLatLng(indirizzo, function(point) 
								  {
									if(!point) 
									{
										alert(indirizzo + " not found");
									} 
									else 
									{
										map.setCenter(point, 15);
										map.addControl(new GSmallMapControl());
										var mapControl = new GMapTypeControl();
										map.addControl(mapControl);
													
										markerOptions = { icon: icona };
										var marker = new GMarker(point, markerOptions);
										
										GEvent.addListener(marker, "click", function()
										{
											marker.openInfoWindowHtml(testohtml);
										});
										
										map.addOverlay(marker);
									}
								  }
						);
}

function vota_video(id_video,voto,ip){

 		var jsel = document.createElement('SCRIPT');
        jsel.type = 'text/javascript';
        jsel.src = 'http://www.you-hotel.com/scripts/ajax/vota_video.php?id_video=' + id_video + '&voto=' + voto + '&ip=' + ip;
        window.document.body.appendChild (jsel);
}

function centradiv(nome_div,space) { //Centers a div element on the page
		
		var divobj = document.getElementById(''+ nome_div +''); 
		
		if(space=='') var space = 60;
		
		var ie=document.all && !window.opera
		var dom=document.getElementById
		
		var standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body 
		
		var scroll_top=(ie)?  standardbody.scrollTop : window.pageYOffset
		var scroll_left=(ie)?  standardbody.scrollLeft : window.pageXOffset
		var docwidth=(ie)?  standardbody.clientWidth : window.innerWidth
		var docwidth2 = document.body.clientWidth;
		var docheight=(ie)?  standardbody.clientHeight: window.innerHeight
		var docheightcomplete=( standardbody.offsetHeight> standardbody.scrollHeight)?  standardbody.offsetHeight :  standardbody.scrollHeight //Full scroll height of document
		var objwidth=divobj.offsetWidth //width of div element
		var objheight=divobj.offsetHeight //height of div element
		var topposition=(docheight>objheight)? scroll_top+docheight/2-objheight/2+"px" : scroll_top+10+"px" //Vertical position of div element: Either centered, or if element height larger than viewpoint height, 10px from top of viewpoint
		
		divobj.style.display = 'block'; 
		divobj.style.width = (docwidth2 - space) + 'px'; //100px or 100%
		divobj.style.height = ((docheight - scroll_top) - space) + 'px'; //100px or 100% 
		divobj.style.top = (scroll_top + (space/2)) + 'px'; //100px or 100%  
		divobj.style.left = ( (docwidth/2) - (divobj.offsetWidth/2) ) +"px"; //100px or 100%  
		
	
	}
	
	function maximize_div(nome_div) { //Centers a div element on the page
		
		var divobj3 = document.getElementById(''+ nome_div +''); 
		var ie=document.all && !window.opera
		var dom=document.getElementById
		var standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body 
		
		var scroll_top=(ie)?  standardbody.scrollTop : window.pageYOffset
		var scroll_left=(ie)?  standardbody.scrollLeft : window.pageXOffset
		var docwidth=(ie)?  standardbody.clientWidth : window.innerWidth
		var docwidth2 = document.body.clientWidth;
		var docheight=(ie)?  standardbody.clientHeight: window.innerHeight
		var docheightcomplete=( standardbody.offsetHeight> standardbody.scrollHeight)?  standardbody.offsetHeight :  standardbody.scrollHeight //Full scroll height of document
		var objwidth=divobj3.offsetWidth //width of div element
		var objheight=divobj3.offsetHeight //height of div element
		var topposition=(docheight>objheight)? scroll_top+docheight/2-objheight/2+"px" : scroll_top+10+"px" //Vertical position of div element: Either centered, or if element height larger than viewpoint height, 10px from top of viewpoint
		
		divobj3.style.display = 'block'; 
		if(ie){
			divobj3.style.width = docwidth + 'px'; //100px or 100%
		}else{
			divobj3.style.width = '100%'; //100px or 100%	
		}
		divobj3.style.height = docheight + 'px'; //100px or 100% 
		divobj3.style.top = scroll_top + 'px'; //100px or 100%  
		divobj3.style.left = '0px'; //100px or 100%    
		
		//alert(divobj3.style.top);
 
		
	}
	
	function opacizza_site(){

		var b = document.getElementById("opacity");
		var opacity = 60;
		var opaque = (opacity / 100);
		var ie = document.all && !window.opera
		var dom = document.getElementById
		var scroll_top = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;

		if(b){
			maximize_div("opacity");
			b.style.top =  scroll_top +'px';
			b.style.display='block'; 
			b.style.opacity=opaque;                      
			b.style.MozOpacity=opaque;                   
			b.style.filter='alpha(opacity='+opacity+')';  
		}
	}
	
	function restore_opacita_site(){

		var b = document.getElementById("opacity");
		var opacity = 0;
		var opaque = (opacity / 100);
		if(b){
			b.style.display='none'; 
			b.style.opacity=opaque;                      
			b.style.MozOpacity=opaque;                   
			b.style.filter='alpha(opacity='+opacity+')'; 
			if(document.getElementById("preview_content")) document.getElementById("preview_content").innerHTML = '';
			if(document.getElementById("div_preview_content")) document.getElementById("div_preview_content").style.display='none';
			if(document.getElementById("video_youtube")) document.getElementById("video_youtube").style.display='block';
		}
	}
	
	function preview_video(codice,descrizione){	
		
		var ie = document.all && !window.opera
		var dom = document.getElementById
		var scroll_top = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		
		opacizza_site();
		var div_prev = document.getElementById("div_preview_content");
		

		maximize_div("div_preview_content");
		div_prev.style.display='block';
		div_prev.style.top =  (scroll_top + 100) +'px';
		if(document.getElementById("preview_title")) document.getElementById("preview_title").innerHTML = '<b>'+descrizione+'</b>';
		insert_youtubevideo('preview_content',codice,'410','344');
		if(document.getElementById("video_youtube")) document.getElementById("video_youtube").style.display='none';
		
	}
	
	function insert_youtubevideo(nome_div,codice,larg,alt){
		
		if(alt=='') alt = '344';
		if(larg=='') larg = '410';
		
		var code_html = '<object width="'+larg+'" height="'+alt+'" style="z-index:2000">';
		code_html += '<param name="movie" value="http://www.youtube.com/v/'+codice+'&hl=it&fs=1&rel=0&autoplay=1"></param>';
		code_html += '<param name="allowFullScreen" value="true"></param>';
		code_html += '<embed src="http://www.youtube.com/v/'+codice+'&hl=it&fs=1&rel=0&autoplay=1&fmt=6" style="z-index:2000" type="application/x-shockwave-flash" allowfullscreen="true" width="'+larg+'" height="'+alt+'"></embed>';
		if(document.getElementById(''+nome_div+'')) document.getElementById(''+nome_div+'').innerHTML = '<span>'+code_html+'</span>';
	}
	
	function hideshow(id) { //Centers a div element on the page 
		
		var obj = document.getElementById(''+ id +''); 
		
		if ( document.all ) { // se ie
				
				if(obj.style.display=='none'){
					obj.style.display="block";
				}else{
					obj.style.display="none";
				}
		
			
		}else{ // se firefox
			
				if(obj.style.display=='none'){
					obj.style.display="table-row";
				}else{
					obj.style.display="none";
				}
			
		}
	
	}




