﻿// 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 = "on";
	}
        //alert(sbo);
        
	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");
		var html = "<A id='QSLB_Submit' title='Unterkunft suchen'  href='" + url + "' 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 = "http://feratel.concentrator.net/tosc.asp?TOSCNEW=TRUE&RG=OG&" + OC + "&ID=" + ID + "&FN=POOL&FC=HO&CF=SCZILLER&PLANNER=TRUE";
	url = "http://feratel-zillertal.concentrator.net/tosc.asp?TOSCNEW=TRUE&OC=ZILLMITTE&RG=OG&ID=1000016&FN=POOL&CF=SCZILLER&FC=" + FC;

	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";
}