/************************************************
 * author: 	Mario Luginbühl
 * version:	1.0
 * date:	2007-04-20
 * purpose:	global javascript functions
 * todo's:	-
***********************************************/


<!-- passwordfunction -->
//the function starts when the whole site is loaded
window.onload = init2;

function init2() {
	if (Password = document.getElementById('password')) {
	 	Password.style.backgroundImage = "url(pics/tech/password_bg.gif)";
	 	Password.onfocus = emptyValue;
		Password.onblur = refillValue;
	}
	if (User = document.getElementById('user')) {
	 	User.style.backgroundImage = "url(pics/tech/user_bg.gif)";
	 	User.onfocus = emptyValueUser;
		User.onblur = refillValueUser;
	}
}

function emptyValue() {
	if (Password) {
        Password.style.backgroundColor = "#33FF33";
		Password.style.backgroundImage = "none";
	}
}

function refillValue() {
	if (Password.value == "") {
		 Password.style.backgroundColor = "#CCCCCC";
   		 Password.style.backgroundImage = "url(pics/tech/password_bg.gif)";
	}
}
function emptyValueUser() {
	if (User) {
        User.style.backgroundColor = "#33FF33";
		User.style.backgroundImage = "none";
	}
}

function refillValueUser() {
	if (User.value == "") {
		 User.style.backgroundColor = "#CCCCCC";
   		 User.style.backgroundImage = "url(pics/tech/user_bg.gif)";
	}
}

<!-- radio buttons return -->
function getCheckedValue(radioObj) 
{
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
	{
		if(radioObj.checked)
		{
			return radioObj.value;
		}
		else
		{
			return "";
		}
	}
	for(var i=0; i<radioLength; i++)
	{
		if(radioObj[i].checked) 
		{
			return radioObj[i].value;
		}
	}
	return "";
}

function setCheckedValue(radioObj, newValue) 
{
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined)
	{
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i=0; i<radioLength; i++)
	{
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) 
		{
			radioObj[i].checked = true;
			return radioObj[i].value;
		}
	}
}

function urlOpen(url)
{
	window.open(url,'urlOpen');
}

function setPortrait(pid)
{
	for(var i=0; i < document.all.tags('DIV').length; ++i)
	{
		if (document.all.tags('DIV')[i].id == "portrait_right_bottom")
		{
			if (document.all.tags('DIV')[i].name == pid) // set the new layer visible
			{
				var element = document.all.tags('DIV')[i];
				element.filters.blendTrans.Apply();
				element.style.visibility = 'visible';
				element.filters.blendTrans.Play();
			}
			else // all the others should be hidden
			{
				var element = document.all.tags('DIV')[i];
				element.filters.blendTrans.Apply();
				element.style.visibility = 'hidden';
				element.filters.blendTrans.Play();
			}
		}
	}
}


function showDiv()
{
	for(var i=0; i < document.all.tags('DIV').length; ++i)
	{
		if (document.all.tags('DIV')[i].id == "transparent")
		{
			var element = document.all.tags('DIV')[i];
			//element.filters.blendTrans.Apply();
			element.style.visibility = 'visible';
			//element.filters.blendTrans.Play();
		}
		if (document.all.tags('DIV')[i].id == "loading")
		{
			var element = document.all.tags('DIV')[i];
			//element.filters.blendTrans.Apply();
			element.style.visibility = 'visible';
			//element.filters.blendTrans.Play();
		}
	}
	//alert("Gut");
	//return true;
}

function checkIt()
{
   if(!document.check.verifyed.checked)
	{
	 alert("Bitte löschen bestätigen!");
	 return false;
	}
}

<!--
// Copyright information must stay intact
// FormCheck v1.10
// Copyright NavSurf.com 2002, all rights reserved
// Creative Solutions for JavaScript navigation menus, scrollers and web widgets
// Affordable Services in JavaScript consulting, customization and trouble-shooting
// Visit NavSurf.com at http://navsurf.com

function formCheck(formobj){
	// name of mandatory fields

	var fieldRequired = Array("huette_nname", "huette_strasse", "huette_plz", "huette_ort", "huette_tel", "huette_mail", "huette_datevon", "huette_datebis", "huette_anzpers", "txtCode");
	
	var fieldDescription = Array("Name", "Strasse", "PLZ", "Ort", "Telefon", "E-Mail", "Datum Anreise", "Datum Abreise", "Personen", "Code");
	// dialog message
	var alertMsg = "Bitte follgende Felder ausfüllen:\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == "" || obj.options[obj.selectedIndex].value == "leer" /*input Mario*/){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1 ){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null || obj.value == "Kalender ->" /*input Mario*/){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}
// -->

// Mailfunction

// rot13-Algorithmus (für Entschlüsselung in JavaScript)
var map = new Array();
var s = "abcdefghijklmnopqrstuvwxyz";
  
for (var i = 0; i < s.length; i++)
	map[s.charAt(i)] = s.charAt((i + 13) % 26);

for (i = 0; i < s.length; i++)
	map[s.charAt(i).toUpperCase()] = s.charAt((i + 13) % 26).toUpperCase();

function rot13 (str)
{
	var rwert = 'mailto:';
	for (i = 0; i < str.length; i++)
	{
		var b = str.charAt(i);
		if (b == '+')
			rwert += '@';
		else
			rwert += ('A' <= b && b <= 'Z' || 'a' <= b && b <= 'z' ? map[b] : b);
	}
	return rwert;
}
