window.defaultStatus = "web development by dg2";
var doAlerts=false;

function hand(theId) {
	if (document.all) {
		document.all(theId).style.cursor ='hand';
	}
	else {
		document.getElementById(theId).style.cursor ='pointer';
	}
}




function showSingle(width, height, address, title) {
	options = "width=" + width + ",height=" + height + ",location=no,menubar=no,status=yes,resizable=no,scrollbars=yes,toolbar=no";
	//popup = window.open(address, title, options);
	window.open(address, title, "width=" + width + ",height=" + height + ",resizable=no,scrollbars=yes,left=100,top=200");
	//alert();
}

function changeTextColor(theId,color) {
	document.getElementById(theId).style.color = color;
}
function calculate() {
	document.getElementById("calcResult").style.display = 'none';
	errors = 0;
	error1 = "";
	error2 = "";
	check = true;
	selectedStart = document.getElementById('location').value;
	place = selectedStart.split("|");
	adults = document.getElementById('adlts').value;
	kids = document.getElementById('kds').value;
	if (place[0] < 1) {
		error1 = unescape("Bitte w%E4hlen Sie einen Startplatz aus.\r\n");
		errors++;
	}
	if ((adults == 0) && (kids == 0)) {
		error2 = unescape("Bitte tragen Sie die Anzahl der Teilnehmer ein.");
		errors++;
	}
	if (errors > 0) {
		alert(error1 + error2);
	}
	if ((adults == 0) && (kids > 0) && (errors == 0)) {
		check = confirm(unescape("Bitte bedenken Sie, da%DF Kinder unter 16 Jahren nur in Begleitung eines Erwachsenen an einer Ballonfahrt teilnehmen d%FCrfen."));
	}
	if ((errors == 0) && (check != false)) {
		kidsPrice = Number(place[0]) - 25;
		adultPrice = Number(place[0]);
		if (document.getElementById('weekend').checked == true) {
			kidsPrice = kidsPrice + 10;
			adultPrice = adultPrice + 10;
			document.getElementById("notes").firstChild.nodeValue = 'Wochenendfahrt (Freitag bis Sonntag): Ja';
			document.getElementById('temp_notes').value = 'Wochenendfahrt (Freitag bis Sonntag): Ja';
		}
		else {
			document.getElementById("notes").firstChild.nodeValue = '';
			document.getElementById('temp_notes').value = '';
		}
		if (adults > 1) {
			adultLabel = adults + ' Erwachsene';
		}
		else if (adults == 1) {
			adultLabel = adults + ' Erwachsener';
		}
		if (kids > 1) {
			kidsLabel = kids + ' Kinder zwischen 12 und 17 Jahren';
		}
		else if (kids == 1) {
			kidsLabel = kids + ' Kind zwischen 12 und 17 Jahren';
		}
		sumRedux = 0;
		totalAdults = adultPrice * adults;
		totalKids = kidsPrice * kids;
		total = totalAdults + totalKids;
		var now = new Date();
		var year = now.getFullYear();
		var month = now.getMonth();
		if ((year <= 2007) && (month < 3)) {
			sumRedux = total * .05;
			total_org = total;
			total_orgNice = total_org.toFixed(2);
			total = total - sumRedux;
		}
		adultPriceString = adultPrice.toFixed(2) + ' \u20AC';
		totalAdultsString = totalAdults.toFixed(2) + ' \u20AC';
		kidsPriceString = kidsPrice.toFixed(2) + ' \u20AC';
		totalKidsString = totalKids.toFixed(2) + ' \u20AC';
		sumReduxString = '-' + sumRedux.toFixed(2) + ' \u20AC';
		if (kids > 0) {
			/*
			document.getElementById("no_kids").firstChild.nodeValue = kidsLabel;
			document.getElementById("price_kids").firstChild.nodeValue = '\u20AC ' + kidsPrice;
			document.getElementById("sum_kids").firstChild.nodeValue = '\u20AC ' + totalKids;
			*/
			document.getElementById("price_kids").firstChild.nodeValue = kidsPriceString;
			document.getElementById("sum_kids").firstChild.nodeValue = totalKidsString;
			if (document.all) {
				document.getElementById("kidsRow").style.display = 'inline';
			}
			else {
				document.getElementById("kidsRow").style.display = 'table-row';
			}
			document.getElementById('kids_label').value = kidsLabel;
			/*
			document.getElementById('kids_price').value = '\u20AC ' + kidsPrice;
			document.getElementById('kids_sum').value = '\u20AC ' + totalKids;
			*/
			document.getElementById('kids_price').value = kidsPriceString;
			document.getElementById('kids_sum').value = totalKidsString;
		}
		else {
			document.getElementById('kids_label').value = '';
			document.getElementById("no_kids").firstChild.nodeValue = "Keine Kinder zwischen 12 und 17 Jahren";
			document.getElementById("price_kids").firstChild.nodeValue = '--';
			document.getElementById("sum_kids").firstChild.nodeValue = '--';
			document.getElementById("kidsRow").style.display = 'none';
		}
		if (adults > 0) {
			document.getElementById("no_adults").firstChild.nodeValue = adultLabel;
			/*
			document.getElementById("price_adults").firstChild.nodeValue = '\u20AC ' + adultPrice;
			document.getElementById("sum_adults").firstChild.nodeValue = '\u20AC ' + totalAdults;
			*/
			document.getElementById("price_adults").firstChild.nodeValue = adultPriceString;
			document.getElementById("sum_adults").firstChild.nodeValue = totalAdultsString;
			if (document.all) {
				document.getElementById("adultsRow").style.display = 'inline';
			}
			else {
				document.getElementById("adultsRow").style.display = 'table-row';
			}
			document.getElementById('adults_label').value = adultLabel;
			/*
			document.getElementById('adults_price').value = '\u20AC ' + adultPrice;
			document.getElementById('adults_sum').value = '\u20AC ' + totalAdults;
			*/
			document.getElementById('adults_price').value = adultPriceString;
			document.getElementById('adults_sum').value = totalAdultsString;
		}
		else {
			document.getElementById('adults_label').value = '';
			document.getElementById("no_adults").firstChild.nodeValue = "Keine Erwachsenen";
			document.getElementById("price_adults").firstChild.nodeValue = '--';
			document.getElementById("sum_adults").firstChild.nodeValue = '--';
			document.getElementById("adultsRow").style.display = 'none';
		}
		if ((document.getElementById('gift')) && (document.getElementById('gift').checked == true)) {
			document.getElementById("gift_label").firstChild.nodeValue = "1 Geschenkgutschein";
			document.getElementById("sum_gift").firstChild.nodeValue = "4.70 \u20AC";
			document.getElementById("gift_amount").firstChild.nodeValue = "4.70 \u20AC";
			document.getElementById('temp_gift').value = "4.70 \u20AC";
			if (document.all) {
				document.getElementById("giftRow").style.display = 'inline';
			}
			else {
				document.getElementById("giftRow").style.display = 'table-row';
			}
			total = total + 4.70;
		}
		else {
			document.getElementById("giftRow").style.display = 'none';
			document.getElementById('temp_gift').value = "";
		}
		totalString = total.toFixed(2) + ' \u20AC';
		if (sumRedux > 0) {
			/*
			document.getElementById("sum_redux").firstChild.nodeValue = '\u20AC -' + sumRedux;
			*/
			document.getElementById('gift').value = 1;
			document.getElementById("redux").firstChild.nodeValue = '5% Rabatt auf Ballonfahrten bei Buchung bis zum 31.03.2007';
			document.getElementById("sum_redux").firstChild.nodeValue = sumReduxString;
			/*document.getElementById("amount_redux").firstChild.nodeValue = '\u20AC ' + total + ' * 5%';*/
			if (document.all) {
				document.getElementById("specialRow").style.display = 'inline';
			}
			else {
				document.getElementById("specialRow").style.display = 'table-row';
			}
			
			document.getElementById('temp_redux').value = '5% Rabatt auf Ballonfahrten bei Buchung bis zum 31.03.2007';
			document.getElementById('temp_sum_redux').value = sumReduxString;
		}
		else {
			document.getElementById("specialRow").style.display = 'none';
		}
		/*
		document.getElementById("amount").firstChild.nodeValue = '\u20AC ' + total;
		document.getElementById('total_sum').value = '\u20AC ' + total;
		*/
		
		document.getElementById("amount").firstChild.nodeValue = totalString;
		document.getElementById('total_sum').value = totalString;
		document.getElementById("startlocation").firstChild.nodeValue = 'Startplatz: ' + place[2];
		document.getElementById('temp_location').value = 'Startplatz: ' + place[2];
		document.getElementById("calcResult").style.display = 'block';
		document.getElementById("calculatorButton").firstChild.nodeValue = 'Preis berechnen';
		document.getElementById("sendButton").style.visibility = 'visible';
	}
}
function hideResults() {
	document.getElementById("sendButton").style.visibility = 'hidden';
	if (document.getElementById("calcResult").style.display == 'block') {
		document.getElementById("calculatorButton").firstChild.nodeValue = 'Preis aktualisieren';
	}
}
function checkSubject() {
	//tempVar = document.getElementById('messageType').value;
	if (document.getElementById('resType2').checked == true) {
		tempVar = '2';
	}
	else {
		tempVar = '1';
	}
	if (tempVar == '1') {
		document.getElementById('resType').value = 'Unverbindliche Buchungsanfrage';
		document.getElementById('subject').value = 'unverbindliche Buchungsanfrage, bitte nehmen Sie Kontakt mit mir auf.';
		document.getElementById("addReq").style.display = 'none';
	}
	else if (tempVar == '2') {
		document.getElementById('resType').value = 'Verbindliche Buchung';
		document.getElementById('subject').value = 'verbindliche Buchung, bitte schicken Sie mir die Rechnung.';
		document.getElementById("addReq").style.display = 'block';
	}
	document.getElementById('resTypeVal').value = tempVar;
}
function submitForm(theForm, action, cancelUrl) {
	if (cancelUrl != '') {
		location.href = cancelUrl;
	}
	else {
		if ((theForm == 'buchung') && (document.getElementById('accept').checked == false)) {
			alert (unescape("Bitte akzeptieren Sie die Allgemeinen Gesch%E4ftsbedingungen von Balloon-Adventure"));
		}
		else if (((theForm == 'buchung')) && (document.getElementById('resType1').checked == false) && (document.getElementById('resType2').checked == false)) {
			alert (unescape("Bitte w%E4hlen sie eine Betreffzeile"));
		}
		else {
			document.getElementById('action').value = action;
			document.getElementById(theForm).submit();
		}
	}
}
function openPopup (width, height, image, title) {
	options = "width=" + (width + 20) + ",height=" + (height + 30) + ",location=no,menubar=no,status=no,resizable=yes,scrollbars=auto,toolbar=no";
	image = "images/" + image;
	window.open (image, title, options)
}

function changeButton(theId, state) {
	if (state == 'over') {
		document.getElementById(theId).style.color = '#666666';
		if (theId == 'loginButton') {
			document.getElementById(theId).style.border = '1px solid #666666';
		}
	}
	else {
		document.getElementById(theId).style.color = '#999999';
		if (theId == 'loginButton') {
			document.getElementById(theId).style.border = '1px solid #999999';
		}
		
	}
}

function checkClientNo(theId) {
	clientCount = theId.substring(11,12);
	if (document.getElementById(theId).checked == true) {
		for (var i = 2; i <= clientCount; i++) {
			showhide = "container_" + i;
			checkboxId = "teilnehmer_" + i;
			document.getElementById(showhide).style.display = 'inline';
		}
	}
	else {
		for (var i = 5; i >= clientCount; i--) {
			showhide = "container_" + i;
			checkboxId = "teilnehmer_" + i;
			document.getElementById(showhide).style.display = 'none';
			document.getElementById(checkboxId).checked = false;
		}
	
	}
}

function getPassword() {
	window.location.href = "index.php?id=40&no_cache=1&tx_newloginbox_pi1[forgot]=1";
}

/*function changeSheets(state){
alert (state);
	if(document.styleSheets){
	var c = document.styleSheets.length;
		if (doAlerts) alert(state + ' legend? - stylesheets: ' + c);
		if (state == 'show') {
			document.styleSheets[4].disabled=true;
			document.styleSheets[5].disabled=false;
		}
		else {
			document.styleSheets[4].disabled=false;
		}
		
	}
}*/

// 'getElementsWithClass' function
function getElementsWithClass(containingEl, tagName, className){
    
    var returnedCollection = new Array(0);

    var collection  = (containingEl.all && tagName == "*") ? 
     containingEl.all : containingEl.getElementsByTagName(tagName);
     
    for(var i = 0; i < collection.length; i++)
        if(collection[i].className == className)
            returnedCollection[returnedCollection.length] = collection[i];

    return returnedCollection;
}

// example 1: set display of 'elements with class' to a given style
 function setBgColor(tagName, className, theStyle) {
 
 	var theElements = getElementsWithClass(document, tagName, className);
 	
 	//alert (theElements.length)
 	
 	for(i = 0;i<theElements.length;i++) {
		
		theElements[i].style.backgroundColor = theStyle;
	}
}

function changeSheets(state){
	if(state == 'show') {
		document.body.style.backgroundColor = '#DDDDDD';
		document.getElementById('level_1_List').style.backgroundColor = '#99FF88';
		if (document.getElementById('level_2_List')) {
			document.getElementById('level_2_List').style.backgroundColor = '#AAFF88';
		}
		document.getElementById('centerContent').style.backgroundColor = '#FFFF66';
		document.getElementById('footer').style.backgroundColor = '#BBFFFF';
		document.getElementById('noLegend').style.display = 'none';
		document.getElementById('legend').style.display = 'block';
		setBgColor('div', 'floatLeft metaNav1', '#55FF99');
		setBgColor('div', 'floatRight metaNav2', '#99FFAA');
		setBgColor('div', 'teaserBoxSingle', '#BBFFFF');
		setBgColor('div', 'teaserBox', '#FFBBBB');
		document.getElementById('allContainer').style.top = '145px';
		document.getElementById('logoArea').style.top = '163px';
		document.getElementById('logoArea').style.backgroundColor = '#FFFFFF';
		document.getElementById('topVisualHolder').style.backgroundColor = '#FFFFFF';
		document.getElementById('topVisual').style.display = 'none';
		document.getElementById('legendContainer').style.backgroundColor = '#DDDDDD';
	}
	else {
		document.body.style.backgroundColor = '#0088E0';
		document.getElementById('level_1_List').style.backgroundColor = '#0088E0';
		if (document.getElementById('level_2_List')) {
			document.getElementById('level_2_List').style.backgroundColor = 'transparent';
		}
		document.getElementById('centerContent').style.backgroundColor = '#0079C2';
		document.getElementById('footer').style.backgroundColor = '#0088E0';
		document.getElementById('legend').style.display = 'none';
		document.getElementById('noLegend').style.display = 'block';
		setBgColor('div', 'floatLeft metaNav1', '#29AAEA');
		setBgColor('div', 'floatRight metaNav2', '#29AAEA');
		setBgColor('div', 'teaserBoxSingle', '#FFFFFF');
		setBgColor('div', 'teaserBox', '#FFFFFF');
		document.getElementById('allContainer').style.top = '40px';
		document.getElementById('logoArea').style.top = '60px';
		document.getElementById('logoArea').style.backgroundColor = 'transparent';
		document.getElementById('topVisualHolder').style.backgroundColor = '#0079C2';
		document.getElementById('topVisual').style.display = 'block';
		document.getElementById('legendContainer').style.backgroundColor = '#FFFFFF';
	}
}

function changeTemplateImg() {
	templateImageName = new Array("Amsterdam", "Paris", "London");
	changeTo = document.getElementById('template').value;
	path = "fileadmin/templates/template_images/template_" + templateImageName[changeTo] + ".jpg";
	document.getElementById('templateImage').src = path;
}

function applyTemplate() {
	pageLocation = window.location.href;
	pageLocationClean = pageLocation.replace(/&type=0/, "");
	pageLocationClean = pageLocationClean.replace(/&type=1/, "");
	pageLocationClean = pageLocationClean.replace(/&type=2/, "");
	//alert (pageLocation + " - " + pageLocationClean)
	pageLocationEnd = pageLocation.substr((pageLocation.length -1), 1);
	if (pageLocationEnd == '/') {
		stringToAppend = "index.php?type=" + document.getElementById('template').value;
	}
	else {
		stringToAppend = "&type=" + document.getElementById('template').value;
	}
	//alert (stringToAppend);
	newLoc = pageLocationClean + stringToAppend;
	location.href = newLoc;;
}