//from HTML
var countryList = ['Affi','Arco','Bardolino','Brentino Belluno','Brenzone','Bussolengo','Caprino Veronese','Castelnuovo del Garda','Cavaion Veronese','Costermano','Desenzano del Garda','Drena','Dro','Ferrara di Montebaldo','Garda','Gardone Riviera','Gargnano','Lazise','Limone sul Garda','Lonato del Garda','Magasa','Malcesine','Manerba del Garda','Moniga del Garda','Padenghe sul Garda','Pastrengo','Peschiera del Garda','Polpenazze del Garda','Pozzolengo','Puegnago','Riva del Garda','Rivoli Veronese','Salò','San Felice del Benaco','San Zeno di Montagna','Sirmione','Soiano del Lago','Tenno','Tignale','Torbole sul Garda - Nago','Torri del Benaco','Toscolano - Maderno','Tremosine','Valeggio sul Mincio','Valvestino'];
var countryID = ['300','268','301','302','303','304','305','306','307','308','287','516','367','309','310','281','280','311','278','290','279','312','271','272','288','765','313','274','291','275','267','314','286','276','315','299','277','520','283','517','317','284','282','318','322'];
var firstLoadPG = true




function getSelectionId(text, li) {
    checkLocalita(text.value);
}

function checkLocalita(Localita) {
	var controllo;
	controllo = countryList.select(function(Loc) {return Loc.toLowerCase() == Localita.toLowerCase()});

	if (controllo != ''){
		$('IDLocalita').value = countryID[countryList.indexOf(controllo.toString())];
		$('Localita').value = controllo;
	}else{
		$('IDLocalita').value = 0;
	}
	
	if ($('fullList')){
		document.getElementById('fullList').style.display='none';
	}

}

function resetDefValue(){
	$('Localita').value = $('defaultLocValue').value;
}

function rePosFullList(event){
	var myClickY = getDivY($('listaLink'))
	var myClickX = getDivX($('listaLink'))
	if(!myListDIV){
		myListDIV = new MyFullListDIV;
		myListDIV.init((myClickX-250),(myClickY-65),'ORTSCHAFTEN')
	}
	myListDIV.showFullList();
}


//form
function fSubmitRic()
	{
		var objForm
		var StrParTypeStr
		var Url
		
		objForm = document.mRic
		StrParTypeStr = objForm.ParTypeStr[objForm.ParTypeStr.selectedIndex].value
		
		if(StrParTypeStr == 0)
		{
			alert('Unterkunftstyp wählen');
			objForm.ParTypeStr.focus();
		}
		else
		{		
			Url = "http://www.visitgarda.com/cms-01.00/articolo.asp?IDLocalita=" + objForm.IDLocalita.value + "&Data=" + objForm.Data.value + "&nNotti=" + objForm.nNotti[objForm.nNotti.selectedIndex].value + "&nPersone=" + objForm.nPersone[objForm.nPersone.selectedIndex].value + "&TypeRic=" + objForm.TypeRic.value + "&l=DE&" + StrParTypeStr;
			document.location = Url;
		}
	}



/////////////////////////////////////






Event.observe(window, 'load',insertDivCalendar );
var myListDIV;

// Insert Div calendar //////////////////////////////////
function insertDivCalendar(){
	var myDivCalendario = '<div id="DIV_PopData" style="z-index:100;position:absolute;visibility:hidden;background-color:white;layer-background-color:white;"></div>';
	new Insertion.Bottom(document.body,myDivCalendario);
}
/////////////////////////////////////////////////////////

function getDivY(oElement)
{
	var iReturnValue = 0;
	while( oElement != null ) {
		iReturnValue += oElement.offsetTop;
		oElement = oElement.offsetParent;
	}
	return iReturnValue;
}


function getDivX(oElement)
{
	var iReturnValue = 0;
	while( oElement != null ) {
		iReturnValue += oElement.offsetLeft;
		oElement = oElement.offsetParent;
	}
	return iReturnValue;
}

function giveMeTheDiv(myCoordX,myCoordY,titleBox){
	
	var myFullListCountry = '' ;
	
	myFullListCountry = myFullListCountry + '<div class="elencoLoc" id="fullList" style="display:none;position:absolute;top:'+myCoordY+'px;left:'+myCoordX+'px;">';
	myFullListCountry = myFullListCountry + '<div class="close"><a onClick="javascript:myListDIV.hideFullList();" style="cursor:pointer;">close <span>X</span></a></div>';
	myFullListCountry = myFullListCountry + '<div style="border:1px solid #243467;padding:0 0 10px 0;background-color:#FFFFFF">';
	myFullListCountry = myFullListCountry + '<div>';
	myFullListCountry = myFullListCountry + '<div class="boxtitle-BLU" >'+titleBox+'</div>';
	myFullListCountry = myFullListCountry + '<div class="clear"></div>';
	myFullListCountry = myFullListCountry + '' + $('searchService').innerHTML;
	myFullListCountry = myFullListCountry + '<div class="clear"></div>';
	myFullListCountry = myFullListCountry + '</div>';
	myFullListCountry = myFullListCountry + '</div>';
	myFullListCountry = myFullListCountry + '</div>';

	return myFullListCountry;
}



var MyFullListDIV = Class.create({
    divPtr: '',
    
    init: function (theX,theY,titleBox) {
		new Insertion.Bottom(document.body,giveMeTheDiv(theX,theY,titleBox));
		this.divPtr = $(document.body).lastChild;

    },
 
    showFullList: function () {
        if (this.divPtr == null) return; 
        $(this.divPtr).show();
    },
 
    hideFullList: function () {
        if (this.divPtr == null) return;
        $(this.divPtr).hide();
    },
 
    removeFullList: function () {
        if (this.divPtr == null) return; 
		document.body.removeChild($(this.divPtr));
		this.divPtr = null;
    }
 
});
