

/**

AUTORE: GERARDO LOMBARDO
DATA:	16/01/2009

*/

var urlSito = "http://www.casadimeglio.it/";
var nSlideGalleryHome = 19;


function cleanField(idField) {
		document.getElementById(idField).value = "";
}

function displayMail(Server, Login, Display, Stile) {

	if ((Display.length == 0) || (Display.indexOf('@')+1)) {
		document.write("<a title='mail' class='"+Stile+"' href=" + "'mai" + "lto:" + Login + "@" + Server + "'>" + Login + "@" + Server + "</a>");
	} else {
		document.write("<a title='mail' class='"+Stile+"' href=" + "'mai" + "lto:" + Login + "@" + Server + "'>" + Display + "</a>");
	}
}

function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}

}

function selezioneIntro(sel,del) {

	var logoSel = document.getElementById('logo'+sel);
	var scrittaSel = document.getElementById('testoIntro'+sel);
	var contenitoreSel = document.getElementById('contenitoreIntro'+sel);

	var logoDel = document.getElementById('logo'+del);
	var scrittaDel = document.getElementById('testoIntro'+del);
	var contenitoreDel = document.getElementById('contenitoreIntro'+del);

	var logoBase = document.getElementById('logo');


	$(":animated").stop();
	logoBase.style.display='none';
	logoDel.style.display='none';
	logoSel.style.display='inline';

	/** AMBIENTE CLIMATIZZATO */
	var testoIntro1 = document.getElementById('testoIntro1');
	var testoIntro1b = document.getElementById('testoIntro1b');
	if ( sel==1 ) {
		testoIntro1.style.display="none";
		testoIntro1b.style.display="inline";
	} else {
		testoIntro1.style.display="inline";
		testoIntro1b.style.display="none";
	}
	/** ---- */

	$(contenitoreSel).animate({ width: "382px", opacity: 1.0}, 800 );
	$(contenitoreDel).animate({ width: "182px", opacity: 0.4}, 800 );

}

function ripristinaIntro() {

	var logo = document.getElementById('logo');
	var logo1 = document.getElementById('logo1');
	var logo2 = document.getElementById('logo2');

	$(":animated").stop();

	$('#contenitoreIntro1').animate({ width: "282px", opacity: 1.0}, 800 );
	$('#contenitoreIntro2').animate({ width: "282px", opacity: 1.0}, 800 );

	logo.style.display='inline';
	logo1.style.display='none';
	logo2.style.display='none';

	/** AMBIENTE CLIMATIZZATO */
	var testoIntro1 = document.getElementById('testoIntro1');
	var testoIntro1b = document.getElementById('testoIntro1b');

	testoIntro1b.style.display="none";
	testoIntro1.style.display="inline";
	/** ---- */

}

function LTrim(str) {

 for (var i=0; ((str.charAt(i)<=" ")&&(str.charAt(i)!="")); i++);

 return str.substring(i,str.length);

}

function RTrim(str) {

 for (var i=str.length-1; ((str.charAt(i)<=" ")&&(str.charAt(i)!="")); i--);

 return str.substring(0,i+1);

}

function Trim(str) {

 return LTrim(RTrim(str));

}

function loadGmap(struttura) {
      if (GBrowserIsCompatible()) {

	var N = "40.7458";
	var E = "13.9134";
	var titolo = "Hotel Casa Di Meglio";
	if ( struttura=="beb" ) {
		N = "40.7445";
		E = "13.9117";
		titolo = "B&amp;B Casa Di Meglio";
	}
        var map = new GMap2(document.getElementById('gMap'));
	map.enableContinuousZoom();
	map.enableDoubleClickZoom();

	map.enableScrollWheelZoom();
	map.addControl(new GSmallMapControl());
	map.addControl(new GOverviewMapControl());
	map.addControl(new GMapTypeControl());
	map.openInfoWindowHtml(new GLatLng(N, E),"<div align='left'><span class='testoStandard'><b>"+titolo+"</b><br />Corso Vittorio Emanuele, 46<br />80074 Casamicciola Terme (NA)</span></div>");
	
	new GKeyboardHandler(map);
        map.setCenter(new GLatLng(N, E), 13);

	var marker = new GMarker(new GLatLng(N, E));
	GEvent.addListener(marker, "click", function() {
		  marker.openInfoWindowHtml("<div align='left'><span class='testoStandard'><b>"+titolo+"</b><br />Corso Vittorio Emanuele, 46<br />80074 Casamicciola Terme (NA)</span></div>");
	});

	map.addOverlay(marker);
      }
}

function galleryHome(slide) {


	if ( slide > nSlideGalleryHome ) slide=1;
	var prossimaSlide = slide+1;
	if ( prossimaSlide>nSlideGalleryHome) prossimaSlide =1;

	$("#slide"+prossimaSlide).css({left: "588px", display: "inline"});
	$("#slide"+prossimaSlide).animate({opacity: 1.0},10000).animate({left: "0px"},10000);

	$("#slide"+slide).animate({opacity: 1.0},10000).animate({left: "-588px"},10000,function(e) {

			$(this).css({display: 'none'});
			galleryHome(slide+1);

	});


}

