﻿// Function Library
// (c) 2008 by Spherecast IT GMbH
// Author: Michael Quas
// Version: 1.0

function chkCBForm(lang) {
	//alert('chk');
	errormsg = "";
	error = 0;
	if (document.callback.vorname.value == "") {
		if (lang=="de") {
			errormsg = "Bitte geben Sie Ihren Vornamen ein!";
			error = 1;
			//alert('no name');
		} else {
			errormsg = "Insert your name, please!";
			error = 1;
		}
		field = "vorname";
	}
	// this.form.Pizza.options[this.form.Pizza.selectedIndex].value
	//alert("::" + document.callback.anrede.selectedIndex);
	
	if (document.callback.nachname.value == "" && error == 0) {
		if (lang=="de") {
			errormsg = "Bitte geben Sie Ihren Nachnamen ein!";
			error = 1;
		} else {
			errormsg = "Insert your last name, please!";
			error = 1;
		}
		field = "nachname";
	}
	if (document.callback.rrdatum.value == "" && error == 0) {
		if (lang=="de") {
			errormsg = "Bitte geben Sie das Rückrufdatum ein!";
			error = 1;
		} else {
			errormsg = "Insert the callback date, please!";
			error = 1;
		}
		field = "rrdatum";
	}
	if (document.callback.tel.value == "" && error == 0) {
		if (lang=="de") {
			errormsg = "Bitte geben Sie Ihre Telefonnummer ein!";
			error = 1;
		} else {
			errormsg = "Insert your phone number, please!";
			error = 1;
		}
		field = "tel";
	}

	if (errormsg != "") {
		alert(errormsg);
		document.getElementById(field).focus();
		return false;
	} else {
		document.callback.submit();
	}
	return true;
}

function showBestellForm()
{
	document.getElementById("pauschale-bestellform").style.display = "block";
	for (n=0;n<=100;n++) {
		document.getElementById("pauschale-bestellform").style.opacity=n; 
		//document.getElementById("pauschale-bestellform").style.-moz-opacity=n/100;
	}
}

function showBox(id)
{
    document.getElementById("multibox_1").style.display="none";
    document.getElementById("multibox_2").style.display="none";
    document.getElementById("multibox_3").style.display="none";
    elm = "multibox_" + id;
    document.getElementById(elm).style.display="block";
}

// Feratel Quickfinder Scripts 

function validateForm(form) {
	var d = parseInt( form.SrchFromDay.value )
	var m = parseInt( form.SrchFromMonth.value )
	var j = parseInt( form.SrchFromYear.value )

	if ( !checkDate(d,m,j) ) {
		alert("Datum inkorrekt!") ;
		form.SrchFromDay.focus();
		return false;
	}
}

function checkDate( d, m, j ) {
	var dt = new Date( j, m-1, d )
	if ( dt.getDate() != d || dt.getMonth()+1 != m ) return false;
	return true;
}

function setCurrentDay() {
	//
	// Set Quickfinder date to current day
	//
	var today = new Date();
	var today_day   = today.getDate();
	var today_month = today.getMonth();
	var today_year  = today.getFullYear();

	window.document.frmQuickFind.SrchFromDay.options[today_day-1].selected = true;
	window.document.frmQuickFind.SrchFromMonth.options[today_month].selected = true;
	window.document.frmQuickFind.SrchFromYear.options[0].value = today_year;
	window.document.frmQuickFind.SrchFromYear.options[0].text = today_year;
}

function submitFORM()
{
		
       	OC = document.frmQuickFind.OC.value;
       	//ID = document.frmQuickFind.ID.value;

	ID = document.frmQuickFind.SrchOrt.options[document.frmQuickFind.SrchOrt.selectedIndex].value;

        RG = document.frmQuickFind.RG.value;
        FN = document.frmQuickFind.FN.value;
        CF = "SCZILLER";
        LG = document.frmQuickFind.LG.value;
        if (document.getElementById("FC1").checked) {
        	FC = document.getElementById("FC1").value;
        } else {
        	FC = document.getElementById("FC2").value;
        }

	if (ID == "1000016") {
		RG="OG";
	} else {
		RG="DN";
	}
        //alert(ID);
        sfd = document.frmQuickFind.SrchFromDay.value;
        sfm = document.frmQuickFind.SrchFromMonth.value;
        sfy = document.frmQuickFind.SrchFromYear.value;
        sd = document.frmQuickFind.SrchDays.value;
       	sr = document.frmQuickFind.SrchRooms.options[document.frmQuickFind.SrchRooms.selectedIndex].text;
        sp = document.frmQuickFind.SrchPax.options[document.frmQuickFind.SrchPax.selectedIndex].text;
        sbo = document.frmQuickFind.SrchBookOnly.checked;
	stars = document.frmQuickFind.SrchStars.value;
	if (sbo == true) {
		sbo = "1";
	}
        //alert(sbo);
    //http://web.deskline.net/erstezill/de/search_accommodation 
	
	switch(ID) {
		case "1000016": //Erste Ferienregion
			 baseurl = "http://web.deskline.net/erstezill/";
			 ID2 = "E8446CC9-8388-4100-8646-544FF03004EA,C2704870-1265-45EE-8AA0-52FD46E4F4FD,8A10D5CE-2622-4BDC-B0E9-0E9E53A0A77A,B429F008-78F2-414E-9A33-99B546806874,B46D769D-CF10-4839-A80A-FD0005258500,87236097-B3C4-4A2E-BE8D-206A52D8AF56,82CA28FA-588F-428D-A89F-2482AC1C1480,580440CF-79D0-48E1-83EA-9AB57430BC94,BEC70929-F8F5-4670-96F9-9153F0415CEE,88BBB853-8498-4828-98CB-ADFEEFCEC7B0,5AF211B9-A99F-4960-AF8B-DF256A18B35D,B8472F0F-8639-4D64-8FE5-7958A3B68716";
			 RG2="TO";
			break;
		case "1000023": //Aschau
			 baseurl = "http://web.deskline.net/erstezill/";
			 ID2 = "E8446CC9-8388-4100-8646-544FF03004EA";
			 RG2="TO";
			break;
		case "1000915": //Bruck 
			 baseurl = "http://web.deskline.net/erstezill/";
			 ID2 = "C2704870-1265-45EE-8AA0-52FD46E4F4FD";
			 RG2="TO";
			break;
		case "1000324": //Fügen
			 baseurl = "http://web.deskline.net/erstezill/";
			 ID2 = "8A10D5CE-2622-4BDC-B0E9-0E9E53A0A77A";
			 RG2="TO";
			break;
		case "1000327": //Fügenberg
			 baseurl = "http://web.deskline.net/erstezill/";
			 ID2 = "B429F008-78F2-414E-9A33-99B546806874";
			 RG2="TO";
			break;
		case "1000326": //Hart 
			 baseurl = "http://web.deskline.net/erstezill/";
			 ID2 = "B46D769D-CF10-4839-A80A-FD0005258500";
			 RG2="TO";
			break;
		case "1000024": //Kaltenbach
			 baseurl = "http://web.deskline.net/erstezill/";
			 ID2 = "87236097-B3C4-4A2E-BE8D-206A52D8AF56";
			 RG2="TO";
			break;
		case "1000021": // Ried
			 baseurl = "http://web.deskline.net/erstezill/";
			 ID2 = "82CA28FA-588F-428D-A89F-2482AC1C1480";
			 RG2="TO";
			break;
		case "1000157": // Schlitters
			 baseurl = "http://web.deskline.net/erstezill/";
			 ID2 = "580440CF-79D0-48E1-83EA-9AB57430BC94";
			 RG2="TO";
			break;
		case "1000236": // Strass
			 baseurl = "http://web.deskline.net/erstezill/";
			 ID2 = "BEC70929-F8F5-4670-96F9-9153F0415CEE";
			 RG2="TO";
			break;
		case "1000022": // Stumm
			 baseurl = "http://web.deskline.net/erstezill/";
			 ID2 = "88BBB853-8498-4828-98CB-ADFEEFCEC7B0";
			 RG2="TO";
			break;
		case "1000916": // Stummerberg
			 baseurl = "http://web.deskline.net/erstezill/";
			 ID2 = "5AF211B9-A99F-4960-AF8B-DF256A18B35D";
			 RG2="TO";
			break;
		case "1000325": // Uderns
			 baseurl = "http://web.deskline.net/erstezill/";
			 ID2 = "B8472F0F-8639-4D64-8FE5-7958A3B68716";
			 RG2="TO";
			break;
		default:
			ID2 = "E8446CC9-8388-4100-8646-544FF03004EA,C2704870-1265-45EE-8AA0-52FD46E4F4FD,8A10D5CE-2622-4BDC-B0E9-0E9E53A0A77A,B429F008-78F2-414E-9A33-99B546806874,B46D769D-CF10-4839-A80A-FD0005258500,87236097-B3C4-4A2E-BE8D-206A52D8AF56,82CA28FA-588F-428D-A89F-2482AC1C1480,580440CF-79D0-48E1-83EA-9AB57430BC94,BEC70929-F8F5-4670-96F9-9153F0415CEE,88BBB853-8498-4828-98CB-ADFEEFCEC7B0,5AF211B9-A99F-4960-AF8B-DF256A18B35D,B8472F0F-8639-4D64-8FE5-7958A3B68716";
			RG2="TO";
			break;
	}
	switch(stars) {
		case "CHALE,PZ,FP,PE,FEWO,GH,HTL,***,****":
			qfdCategories = "bdf7e267-43f2-4a63-9c35-8aeaf7c18bb8,74fb9693-12ce-458a-b2d3-3ca8c6b91569,3115ee0f-d6a0-4b3f-987a-f4eb421c2422,970bfe53-8e58-4f2e-8706-cfc2df8387c5,d3062708-5b43-4f42-aa18-95b3ad32c3c9,ab4f2086-f06d-4dac-8b99-09eda5577c67,361bf303-3009-4bc6-8b7e-06c7de10edfc,ec3c8e0c-961c-4cfd-900e-1f2875acce63,f4d5b37a-e9b7-4508-b16a-55d57c64309a"; // alle Kategorien
			break;
		case "****":
			qfdCategories = "3115ee0f-d6a0-4b3f-987a-f4eb421c2422"; // **** Hotel
			break;
		case "***":
			qfdCategories = "d3062708-5b43-4f42-aa18-95b3ad32c3c9"; // *** Hotel
			break;
		case "Hotel":
			qfdCategories = "ab4f2086-f06d-4dac-8b99-09eda5577c67"; // *** Hotel
			break;
		case "GH":
			qfdCategories = "361bf303-3009-4bc6-8b7e-06c7de10edfc"; // Gasthof
			break;
		case "FEWO":
			qfdCategories = "ec3c8e0c-961c-4cfd-900e-1f2875acce63"; // Ferienwohnung / Appartement
			break;
		case "PE":
			qfdCategories = "f4d5b37a-e9b7-4508-b16a-55d57c64309a"; // Pension
			break;
		case "FP":
			qfdCategories = "970bfe53-8e58-4f2e-8706-cfc2df8387c5"; // Frühstückspension
			break;
		case "PZ":
			qfdCategories = "74fb9693-12ce-458a-b2d3-3ca8c6b91569"; //Privatzimmer
			break;
		case "CHALE":
			qfdCategories = "bdf7e267-43f2-4a63-9c35-8aeaf7c18bb8"; //Ferienhaus
			break;
		default:
			qfdCategories = "bdf7e267-43f2-4a63-9c35-8aeaf7c18bb8,74fb9693-12ce-458a-b2d3-3ca8c6b91569,3115ee0f-d6a0-4b3f-987a-f4eb421c2422,970bfe53-8e58-4f2e-8706-cfc2df8387c5,d3062708-5b43-4f42-aa18-95b3ad32c3c9,ab4f2086-f06d-4dac-8b99-09eda5577c67,361bf303-3009-4bc6-8b7e-06c7de10edfc,ec3c8e0c-961c-4cfd-900e-1f2875acce63,f4d5b37a-e9b7-4508-b16a-55d57c64309a"; // alle Kategorien
			break;
	}
	var today = new Date();
	var today_day   = today.getDate();
	var today_month = today.getMonth() + 1;
	var today_year  = today.getFullYear();
	if (sfd=="") {
		sfd = today_day;
	}
	if (sfm=="") {
		sfm = today_month;
	}
	if (sfy=="") {
		sfy = today_year;
	}
	
	if(sfd < 10){
	sfd = '0'+sfd;
	} 
	if(sfm < 10){
	sfm = '0'+sfm; 
	}
	qfdArrivalDate = sfy+''+sfm+''+sfd;
	qfdArrivalDate = qfdArrivalDate.replace(/ /g, "");
	sd = sd.replace(/ /g, "");
	switch(LG) {
		case "1":
			langstr = "de";
			url2 = "http://web.deskline.net/erstezill/de/qfind_accommodation";
			break;
		case "2":
			langstr = "en";
			url2 = "http://web.deskline.net/erstezill/en/qfind_accommodation";
			break;
		default:
			langstr = "de";
			url2 = "http://web.deskline.net/erstezill/de/qfind_accommodation";
			break;
	}
	
	url2 = url2 + "?RG=" + RG2 + "&ID=" + ID2 + "&qfdArrivalDate=" + qfdArrivalDate ;
	url2 = url2 + "&qfdCategories=" + qfdCategories;
	url2 = url2 + "&qfdNights=" + sd + "&qfdAdults=" + sp + "&qfdOnlyBookable=" + sbo + "&qfdNumberOfUnits=" + sr;
	//alert(url2);
	url = "http://feratel.concentrator.net/tosc.asp?TOSCNEW=TRUE&OC=" + OC + "&ID=" + ID + "&RG=" + RG + "&FN=" + FN;
        url = url + "&CF=" + CF + "&LG=" + LG + "&FC=" + FC + "&SrchFromDay=" + sfd + "&SrchFromMonth=" + sfm;
        url = url + "&SrchFromYear=" + sfy + "&SrchDays=" + sd + "&SrchRooms=" + sr + "&SrchPax=" + sp;
        url = url + "&SrchBookOnly=" + sbo + "&SrchStars=" + stars;
        //alert(url);
	var obj = document.getElementById("lbdiv");
		// für die umstellung auf deskline3 in der nächsten Zeile url auf url2 ändern!
		var html = "<A id='QSLB_Submit' title='Unterkunft suchen'  href='" + url2 + "' rev='width: 830px; height: 600px; scrolling: yes;' rel='lyteframe[Quicksearch]'>&nbsp;</A>";
		obj.innerHTML = html;
		var el   = document.getElementById("QSLB_Submit");
		myLytebox.start(el,false, true);
		html = "&gt;&nbsp; <SPAN class=button-text onclick=submitFORM();>Unterkunft suchen </SPAN>";
		obj = document.getElementById("lbdiv");
		obj.innerHTML = html;
}




function unverbAnfrage() {
						
	if (document.getElementById("FC1").checked) {
        	FC = document.getElementById("FC1").value;
        } else {
        	FC = document.getElementById("FC2").value;
        }
	//alert('start');
	//url = ""https://web.deskline.net/erstezill/de/request_pool?CLR_ALL=true";";
	url= ""https://web.deskline.net/erstezill/de/request_pool?CLR_ALL=true";
	var obj = document.getElementById("lbdiv1");
	var html = "<A id='QSLB1_Submit' class=box title='Unverbindliche Anfrage' target=_parent  href='" + url + "' rev='width: 830px; height: 600px; scrolling: yes;' rel='lyteframe[Anfrage]'>Betrieb auswählen </A>";
	obj.innerHTML = html;
	var el   = document.getElementById("QSLB1_Submit");
	//alert(el);
	myLytebox.start(el,false, true);
	html = "<SPAN class=button-text onclick=unverbAnfrage();>&gt;&nbsp;&nbsp;Unverbindliche Anfrage</SPAN>";
	obj = document.getElementById("lbdiv1");
	obj.innerHTML = html;
}

function requestPauForm() {
	formObj = document.getElementById("pauBest");
	pauschale = formObj.titel.value;
	window.scrollTo(1,1);
	alert(pauschale);

}

function chkFormular2(Language)
{
	//alert('check form');
	chkError = false;
	for (i = 0; i < document.all.length; i++)
	{
		if (document.all(i).getAttribute("mandatory"))
		{
			if (document.all(i).getAttribute("mandatory") == 1)
			{
				FieldName = document.all(i).name;
				switch (document.all(i).tagName)
				{
					case "SELECT":
								if (document.all(i).selectedIndex == -1)
									chkError = true;
								else if (document.all(i).options(document.all(i).selectedIndex).text == "")
									chkError = true;
								break;
					case "INPUT":
								if (document.all(i).value == "")
									chkError = true;
								break;
					case "TEXTAREA":
								if (document.all(i).innerText == "")
									chkError = true;
								break;
				}
				if (chkError)
				{
					switch (Language)
					{
						case "de":	
								msg = "Geben Sie bitte einen Wert für das Feld <" + FieldName + "> an!";
								break;
						case "en":	
								msg = "Please enter a value for the field <" + FieldName + ">!";
								break;
					}
					alert(msg);
					document.all(i).focus();
					return false;
				}
			}
		}
	}
}
function chkFormular3(obj,lang) {
	formFields = $('pauBestForm').select('[mandatory="1"]');
	for (n=0; n<= formFields.length -1; n++) {
		if (formFields[n].value == "") {
			FieldName = formFields[n].name;
			switch (lang)
			{
				case "de":	
						msg = "Geben Sie bitte einen Wert für das Feld <" + FieldName + "> an!";
						break;
				case "en":	
						msg = "Please enter a value for the field <" + FieldName + ">!";
						break;
			}
			alert(msg);
			formFields[n].focus();
			return false;
		}
	}
}
function loadBikeDetail(bid) {
	var url = "http://www.best-of-zillertal.at/sommer/application/sportdb_detail.pl?id=" + bid;
	//alert("loading..\n" + url);
	new Ajax.Request(url, {
		method: 'get',
		onSuccess: function(transport) {
			$('biketour').innerHTML = transport.responseText;
		}
	});
	Array.prototype.removeDuplicates = function () { for (var i = 1; i < this.length; i++) { if (this[i][0] == this[i-1][0]) { this.splice(i,1); } } }
	Array.prototype.empty = function () { for (var i = 0; i <= this.length; i++) { this.shift(); } }
	String.prototype.trim = function () { return this.replace(/^\s+|\s+$/g, ''); }
	LyteBox();
	//new Ajax.Updater('biketour', url);
}
function loadBikeDetail_en(bid) {
	var url = "http://www.best-of-zillertal.at/sommer/application/sportdb_detail_en.pl?id=" + bid;
	//alert("loading..\n" + url);
	new Ajax.Request(url, {
		method: 'get',
		onSuccess: function(transport) {
			$('biketour').innerHTML = transport.responseText;
		}
	});
	Array.prototype.removeDuplicates = function () { for (var i = 1; i < this.length; i++) { if (this[i][0] == this[i-1][0]) { this.splice(i,1); } } }
	Array.prototype.empty = function () { for (var i = 0; i <= this.length; i++) { this.shift(); } }
	String.prototype.trim = function () { return this.replace(/^\s+|\s+$/g, ''); }
	LyteBox();
	//new Ajax.Updater('biketour', url);
}
function setHigh(obj) {
	obj.style.background = "#d1d6f9";
}
function setLow(obj) {
	obj.style.background = "0";
}
