﻿// JScript-Datei
var fader = "";
var opacity = 0;
var act = 0;
var act2 = 0;

function fadeIn(objId) {
	if (active2=="" ) {
    opacity = opacity + 0.4;
	document.getElementById(objId).style.filter="alpha(opacity=" + Math.sin(opacity)*100 + ")";
    document.getElementById(objId).style.MozOpacity = Math.sin(opacity);
	document.getElementById('langUl').style.display="block";
	
    if(opacity >= Math.PI/2) {
        window.clearInterval(fader);
        fader = "";
		opacity = 0;
		document.getElementById('navmenu-h').style.zindex="0";
		document.getElementById('langUl').style.zindex="999";

    }
    }
}

function fadeOut(objId) {
	window.clearInterval();
    
    if (active2=="" || open != 0) {
    opacity = opacity - 0.4;
	document.getElementById(objId).style.filter="alpha(opacity=" + Math.sin(opacity)*100 + ")";
    document.getElementById(objId).style.MozOpacity = Math.sin(opacity);
	document.getElementById(objId).style.zindex=0;
	
	//document.getElementById(objId).style.filter="alpha(opacity=" + opacity + ")";
    //document.getElementById(objId).style.MozOpacity = opacity/100;
    if(opacity <= 0) {
		opacity = 0;
        window.clearInterval(fader);
        fader = "";
        //active2 = "";
		//alert("close fader");
		document.getElementById(objId).style.display = "none";
		document.getElementById(objId).style.filter="alpha(opacity=0)";
		document.getElementById(objId).style.MozOpacity = 0;
		open = 1;
    }
    }
}



function selectField(obj) 
{
    if (obj.style.backgroundImage=="url(http://www.montafon.at/Design/images/online_0.gif)" || obj.style.backgroundImage=="") 
    {
        obj.style.backgroundImage="url(http://www.montafon.at/Design/images/online_1.gif)";
        document.getElementById("SrchBookOnly").value = "true";
    } else {
        obj.style.backgroundImage="url(http://www.montafon.at/Design/images/online_0.gif)";
        document.getElementById("SrchBookOnly").value = "false";
    }
}

function showDropDown(obj) 
{
	
    if (active != "") {
	return(false);
    }
    objName = obj.id;
    part = objName.split("-");
    act = part[0] + "ValueBox";
    //alert("style=" + document.getElementById(act).style.display);
    if (document.getElementById(act).style.display == "block") {
		opacity = Math.PI/2;
		if ( fader == "") {
		    fader = window.setInterval("fadeOut(act)",1);
		}
    } else {
        initForm();
		opacity = 0;
        document.getElementById(act).style.display = "block";
        if ( fader == "") {
		    fader = window.setInterval("fadeIn(act)",1);
		}
    }
}
function showDropDown2(objName, active, active2) 
{
    if (active2=="" || open != 0) {
    part = objName.split("-");
    act2 = part[0] + "ValueBox";
    if (document.getElementById(act2).style.display == "block") {
		opacity = Math.PI/2;
	    // clear interval!!
	    // window.clearInterval();
		fader = window.setInterval("fadeOut(act2)",3);
    } else {
        initForm();
		opacity = 0;
        document.getElementById(act2).style.display = "block";
		fader = window.setInterval("fadeIn(act2)",1);
    }
    }
}
function select(obj) 
{
    hfield = obj.title;
    ddwin = obj.title + "ValueBox";
    ddvalue = obj.title + "Value";
    oid = obj.id;
    var lbl = ""
    if (oid.search(/HO/) != -1) {
        lbl = document.getElementById("Lbl_HO").value;
        
    } 
    if (oid.search(/AP/) != -1) {
        lbl = document.getElementById("Lbl_AP").value;
    }
    if (lbl != "") {
        document.getElementById("SrchRooms-label1").innerHTML = lbl;
    }
	opacity = Math.PI/2;
	fader = window.setInterval("fadeOut(ddwin)",3);
    document.getElementById(ddvalue).innerHTML = obj.innerHTML;
    document.getElementById(hfield).value = obj.innerHTML;
    if (hfield == "SrchStars") {
        parts = obj.id.split("|");
        document.getElementById("SrchStars").value = parts[0];
        document.getElementById("FC1").value = parts[1];
    }
    if (hfield == "SrchOrt") {
        parts = obj.id.split("|");
        document.getElementById("SrchOrt").value = parts[0];
        document.getElementById("RG").value = parts[1];
    }
}
function select2(item) 
{
   
    ddwin = item + "ValueBox";
	opacity = Math.PI/2;
	fader = window.setInterval("fadeOut(ddwin)",3); 
}
function initForm() 
{
    document.getElementById("SrchOrtValueBox").style.display = "none";
    document.getElementById("SrchStarsValueBox").style.display = "none";
    document.getElementById("SrchFromDayValueBox").style.display = "none";
    document.getElementById("SrchFromMonthValueBox").style.display = "none";
    document.getElementById("SrchFromYearValueBox").style.display = "none";
    document.getElementById("SrchDaysValueBox").style.display = "none";
}

function setCurrentDay() 
{
	//
	// Set Quickfinder date to current day
	//
	var today = new Date();
	var today_day   = today.getDate();
	var today_month = today.getMonth() +1;
	var today_year  = today.getFullYear();

    document.getElementById("SrchFromDayValue").innerHTML = today_day;
	document.getElementById("SrchFromMonthValue").innerHTML = today_month;
	document.getElementById("SrchFromYearValue").innerHTML = today_year;
}

function submitFORM()
{
       	OC 	= document.frmQuickFind.OC.value;
       	ID 	= document.frmQuickFind.SrchOrt.value;
        RG 	= document.frmQuickFind.RG.value;
        FN 	= document.frmQuickFind.FN.value;
        CF 	= "SPHERECAST";
        LG 	= document.frmQuickFind.LG.value;
        FC 	= document.frmQuickFind.FC1.value;
        stars 	= document.frmQuickFind.SrchStars.value;
        sfd 	= document.frmQuickFind.SrchFromDay.value;
        sfm 	= document.frmQuickFind.SrchFromMonth.value;
        sfy 	= document.frmQuickFind.SrchFromYear.value;
        sd 	= document.frmQuickFind.SrchDays.value;
       	sr 	= document.frmQuickFind.SrchRooms.value;
        sp 	= document.frmQuickFind.SrchPax.value;
        sbo 	= document.frmQuickFind.SrchBookOnly.value;
		//stat = writeStat(stars, "Quicksearch");
        //alert(stars + " Typ:" + FC);
		
		if (LG == 1) {
			langstr = "de";
		} else {
			langstr = "en";
		}
		
		if (FC == "HO") {
			qfdAccommodationType=1;
		} else {
			qfdAccommodationType=2;
		}
		
		//if (ID == "") {
        //	ID = "6c23d36d-be29-414f-b550-b79518686c5d"; // Montafon Alle Orte

        //}

		if (stars == "") {
			Effect.Pulsate('SrchStars-dropdown', { pulses: 5, duration: 1.5, from: 0.3 });
			new Effect.Highlight('SrchStars-label', { startcolor: '#ff0000', endcolor: '#000000' });
			return(false);
		}

		switch(stars) {
			case "****,***,**,*,HTL":
				qfdCategories = "ab4f2086-f06d-4dac-8b99-09eda5577c67";
				break;
			case "GH":
				qfdCategories = "361bf303-3009-4bc6-8b7e-06c7de10edfc";
				break;
			case "FEWO,FEWO3,FEWO4":
				qfdCategories = "ec3c8e0c-961c-4cfd-900e-1f2875acce63";
				break;
			case "PE***,PE":
				qfdCategories = "f4d5b37a-e9b7-4508-b16a-55d57c64309a";
				break;
			case "PZ":
				qfdCategories = "74fb9693-12ce-458a-b2d3-3ca8c6b91569";
				break;
			case "FH":
				qfdCategories = "bdf7e267-43f2-4a63-9c35-8aeaf7c18bb8"; //Ferienhaus
				break;
			case "CHALE":
				qfdCategories = "bdf7e267-43f2-4a63-9c35-8aeaf7c18bb8,e99317cd-274b-48c8-8c4d-f04d87526951"; //Ferienhaus, Schutzhütte, Hütte
				break;
			default:
				qfdCategories = "ab4f2086-f06d-4dac-8b99-09eda5577c67"; //Hotel
				break;
		}

		switch(ID) {
			case "1000222":
				 baseurl = "http://feratel-bartholo.concentrator.net/";
				 OC = "BARTHOLO";
				 ID2 = "dc7a6b11-00b6-430f-8d98-3ff0c4925646";
				 RG2="TO";
				break;
			case "1000223":
				baseurl = "http://feratel-gargellen.concentrator.net/";
				OC = "GARGELLEN";
				ID2 = "6aaa9893-0154-4c8c-ac6e-f53cb75322a5";
				RG2="TO";
				break;
			case "1000224":
				baseurl = "http://feratel-gaschurn.concentrator.net/";
				OC = "GASCHURN";
				ID2 = "fe50fe90-12e1-49e8-be65-d22249b211b7";
				RG2="TO";
				break;
			case "1000225":
				baseurl = "http://feratel-schruns.concentrator.net/";
				OC = "SCHRUNS";
				ID2 = "8922E450-AADD-441A-9184-B6243AB2DEA2";
				RG2="RG";
				break;
			case "1000226":
				baseurl = "http://feratel-silbertal.concentrator.net/";
				OC = "SILBERTAL";
				ID2 = "0569bcc0-50fa-413a-b572-573d75210316";
				RG2="TO";
				break;
			case "1000227":
				baseurl = "http://feratel-stantonm.concentrator.net/";
				OC = "STANTONM";
				ID2 = "300e500e-4766-4b07-bc84-c93c6a9a8ad7";
				RG2="TO";
				break;	
			case "1000228":
				baseurl = "http://feratel-stgallen.concentrator.net/";
				OC = "STGALLEN";
				ID2 = "d318681d-bee6-432c-930e-f9262dc59594";
				RG2="TO";
				break;		
			case "1000230":
				baseurl = "http://feratel-vandans.concentrator.net/";
				OC = "VANDANS";
				ID2 = "aedef373-32d4-4924-9a9a-b74480416086";
				RG2="TO";
				break;	
			default:
				baseurl = "http://feratel-sc-mont.concentrator.net/";
				OC = "SC-MONT";
				ID2 = "6c23d36d-be29-414f-b550-b79518686c5d";
				RG2="RG";
				break;
		}

		OC = "MONTAFON";
		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, "");
		
		//alert(qfdArrivalDate);
		
		switch(sbo) {
			case "true":
				 sbo = "1";
				break;
			default:
				sbo = "0";
				break;
		}
        
        url2 = "http://web.deskline.net/montafonqfind/" + langstr + "/qfind_accommodation?RG=" + RG2 + "&ID=" + ID2 + "&qfdArrivalDate=" + qfdArrivalDate ;
		url2 = url2 + "&qfdAccommodationType=" + qfdAccommodationType + "&qfdCategories=" + qfdCategories;
		url2 = url2 + "&qfdNights=" + sd + "&qfdAdults=" + sp + "&qfdOnlyBookable=" + sbo + "&qfdNumberOfUnits=" + sr;
		
		//alert(url2);
		
        url = baseurl + "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;
	
		//exit;
		myLightWindow.activateWindow({
            href: url2,
            title: 'Suchen & Buchen',
            author: 'Spherecast',
            opacity:70,
            caption: '',
            width:650,
            height:500,
            top:300
        });
}

function PrintContent() {
    window.print();

}

function writeStat(obj, type)
{
	//alert(obj.title);
	//url = "/application/stat.pl?obj=" + obj + "&type=" + type;
	//new Ajax.Request(url, 
	//{ 
//		method:'get', 
//		onSuccess: function(transport){ 
//		var response = transport.responseText || "NOT OK"; 
//		//alert("Success! \n\n" + response); 
//	}, 
//	onFailure: function(){  } 
//	});	
}
function chkFormular2(Language)
{
	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)
				{
					
					if (Language == "en") {
						switch (FieldName)
						{
							case "Anrede":
								FieldName = "Form of address";
								break;
							case "titel":
								FieldName = "Title";
								break;
							case "vorname":
								FieldName = "Name";
								break;
							case "nachname":
								FieldName = "Surname";
								break;
							case "firma":
								FieldName = "Company";
								break;
							case "strasse":
								FieldName = "Address";
								break;
							case "plz":
								FieldName = "ZIP";
								break;
							case "ort":
								FieldName = "City";
								break;
							case "Land":
								FieldName = "Country";
								break;
							case "email":
								FieldName = "email";
								break;
						}
					}
					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;
				}
			}
		}
	}
}