﻿// JScript-Datei
var status1 = "";
function toggleMain(obj)
{
    lfo         = obj.firstChild;
    lfo_class   = lfo.style.background;
    test        = lfo_class.indexOf("_hi");
    //alert(lfo_class);
    if (test == -1) {
        lfo.style.background = "url(http://www.montafon.at/Design/images/mainNav_hileft_gold.gif)";
        lfo.style.backgroundrepeat = "no-repeat";
        rfo = lfo.nextSibling;
        rfo = rfo.nextSibling;
        rfo.style.background = "url(http://www.montafon.at/Design/images/mainNav_hiright_gold.gif)";
        rfo.style.backgroundrepeat = "no-repeat";
    } else {
        lfo.style.background = "url(http://www.montafon.at/Design/images/mainNav_loleft_gold.gif)";
        lfo.style.backgroundrepeat = "no-repeat";
        rfo = lfo.nextSibling;
        rfo = rfo.nextSibling;
        rfo.style.background = "url(http://www.montafon.at/Design/images/mainNav_loright_gold.gif)";
        rfo.style.backgroundrepeat = "no-repeat";
    }
}


function setBackground(pid) {
	if (document.getElementById("channel_Image")) {
		bgimage = "url(http://www.montafon.at/userfiles/channelimages/channel" + document.getElementById("channel_Image").value + ".jpg)";
		document.getElementById("sitewrapper").style.backgroundImage = bgimage;
		return(true);
	}
    if (pid != 294) {
        //alert(pid);
        idx = GetIndexByID(pid);
        if (Items[idx]) {
			ImageIndex = Items[idx].xPos;
			bgimage = "url(http://www.montafon.at/userfiles/channelimages/channel" + ImageIndex + ".jpg)";
			document.getElementById("sitewrapper").style.backgroundImage = bgimage;
		}
    }
}

function GetIndexByID(ID)
{
	for (n = 0; n <= sumItems - 1; n++)
	{
		link = Items[n].ItemLink;
		var linkPID = link.split("=");
		pageID = linkPID[2];
		if (pageID == parseInt(ID)) {
			return n;
		}
	}
	return -1;
}

function load_wetter() {
	//alert('loading images...');
	document.getElementById('wettervorschau').innerHTML = "";
	url = "http://www.montafon.at/application/wetter_import.pl";
	new Ajax.Updater('wettervorschau', url, { method: 'get' });
}
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;
				}
			}
		}
	}
}




function submitNLForm2(lang) {
	//alert("check");
	
	var ajaxform=$('captcha').request({ onSuccess: function(response) { 
		resp = response.responseText;
		
		if (resp == "OK") {
			
			email = document.getElementById('email-addr').value;
			status1 = "checked";
			//document.NLForm.submit();
			email = email.replace(/@/g, "~");

			url = "http://www.montafon.at/captcha/preregister.pl?email=" + email + "&lang=" + lang;
			
			new Ajax.Request(url, {
				method: 'get',
				onSuccess: function(transport) {
					
				switch (lang) {
					case "198":
						response_Text="<p style='padding-left:10px; padding-top:10px; color:#000;'><b>Vielen Dank!</b><br><br>Sie bekommen in Kürze eine EMail mit dem Bestätigungslink zugesendet.</p>";
						break;
					case "199":
						response_Text="<p style='padding-left:10px; padding-top:10px; color:#000;'><b>Thank You!</b><br><br>You will receive an EMail with your activation code shortly.</p>";
						break;
					case "200":
						response_Text="<p style='padding-left:10px; padding-top:10px; color:#000;'><b>Thank You!</b><br><br>You will receive an EMail with your activation code shortly.</p>";
						break;
					case "201":
						response_Text="<p style='padding-left:10px; padding-top:10px; color:#000;'><b>Thank You!</b><br><br>You will receive an EMail with your activation code shortly.</p>";
						break;
					case "201":
						response_Text="<p style='padding-left:10px; padding-top:10px; color:#000;'><b>Thank You!</b><br><br>You will receive an EMail with your activation code shortly.</p>";
						break;
					default:
						response_Text="<p style='padding-left:10px; padding-top:10px; color:#000;'><b>Thank You!</b><br><br>You will receive an EMail with your activation code shortly.</p>";
						break;
				}
		
					
					
					document.getElementById('captchaform').innerHTML = response_Text;
					
				}
			});

		} else {
			document.getElementById('codefield').value = "falscher Code";
			status1 = "failed";
		}
	
	
	} });
}
// NavLib ru

function loadMainNav(lang) {
	url = "/navlibrary.asp?navtype=MainNav&lang=" + lang;
	new Ajax.Updater('mainNav', url, { method: 'get' });

}
function loadMetaNav(lang) {
	url = "/navlibrary.asp?navtype=MetaNav&lang=" + lang;
	new Ajax.Updater('divMetaNav', url, { method: 'get' });

}
function chkResForm(lang) {
	//alert("check resform...");
	errormsg = "";
	error = 0;
	if (document.resformular.res_email.value == "") {
		if (lang=="de") {
			errormsg = "Bitte geben Sie Ihre EMail ADRESSE ein!";
			error = 1;
		} else {
			errormsg = "Insert your email address, please!";
			error = 1;
		}
		field = "res_email";
	}

	if (document.resformular.res_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 = "res_tel";
	}
	
	if (errormsg != "") {
		alert(errormsg);
		document.getElementById(field).focus();
		return false;
	} else {
		document.resformular.submit();
	}
	return true;
}
