var MODE_URL = 1;
var MODE_FORM = 2;
var timerID;


var quickHelpTimerID;

function do_confirm(target, message, mode)
{
	var answer = confirm(message);
	if (answer) {
		switch (mode) {
			case MODE_URL:
				location.href = target;
				break;
			case MODE_FORM:
				target.submit();
				break;
			default:
				alert('Interner Fehler: Kein Modus spezifiziert!');
		}
	}
}

function popup(url, width, height, sb)
{
/*	w = window.open('#', 'zoom', 'width=1, height=1, toolbar=no, scrollbars=no, menubar=no, locationbar=no');
	w.close();*/

	w = window.open(url, 'zoom', 'width=' + width +', height=' + height + ', toolbar=no, scrollbars=' + sb + ', menubar=no, locationbar=no');
	w.focus();
}


var pWin = null, htmlstr = '';

function picWin(url,width,height,title)
{
	if (pWin && !pWin.closed)
		pWin.close();

	htmlstr = '<html><head><title>'+title+'</title></head>';
	htmlstr += '<body style="margin: 0" marginwidth="0" marginheight="0" leftmargin="0" topmargin="0"';
	htmlstr += '><img border="0" src="' + url + '"></body></html>';
	var left = screen.width/2 - width/2;
	var top = screen.height/2 - height/2;
	var chrome = 'status=0,width='+width+',height='+height+',left='+left+',top='+top;
	pWin = open('javascript:opener.htmlstr','pWin',chrome);

	if (pWin && !pWin.closed) {
		pWin.focus();
	}
}


function directBook(id)
{
http://pfiff.intosite.info/travel/book/bookdestination.php?id=2&location_id=4

	if (id == 9991) window.location.href = "/travel/book/bookdestination.php?id=2&location_id=4";
	else if (id == 9992) window.location.href = "/travel/book/bookdestination.php?id=2&location_id=6";
	else if (id != "") window.location.href = "/travel/book/bookdestination.php?id="+id;
}




function chkFormular()
{


 if(document.Formular.name.value == "")  {
   alert("Bitte geben Sie Ihren Namen ein.");
   document.Formular.name.focus();
   return false;
  }
 if(document.Formular.emailadresse.value == "")  {
   alert("Bitte geben Sie Ihre eMailadresse ein.");
   document.Formular.emailadresse.focus();
   return false;
  }
 if(document.Formular.strasse.value == "")  {
   alert("Bitte geben Sie Ihre Strasse ein.");
   document.Formular.strasse.focus();
   return false;
  }
 if(document.Formular.plz.value == "")  {
   alert("Bitte geben Sie Ihre Postleitzahl ein.");
   document.Formular.plz.focus();
   return false;
  }
 if(document.Formular.ort.value == "") {
   alert("Bitte geben Sie Ihren Wohnort ein.");
   document.Formular.ort.focus();
   return false;
  }
}








function showHelp(e,q,a)
{
	var ns = navigator.appName == "Netscape";
	var ns5 = (ns && parseInt(navigator.appVersion) > 4);


	helpLayer = getLayer('quickHelp');

//	if (helpLayer.style.visibility == "visible") return;

	helpLayer.style.visibility = "visible";



	// Mozilla
	if (window.event == undefined)
	{
		helpLayer.style.left = e.pageX +"px";
        helpLayer.style.top = e.pageY +"px";
        
        helpLayer.style.width = (630-e.pageX) + "px";
        
	}
	else	// IE 
	{
		// not all versions of IE determine scrollposition in the same manner (why should they?)
		scrollTop = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		scrollLeft = (document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		
		
        helpLayer.style.left = window.event.clientX + scrollLeft +"px";
        helpLayer.style.top = window.event.clientY+scrollTop +"px";
        
        helpLayer.style.width = (630-(window.event.clientX+scrollLeft)) + "px";

	}



	if (ns5) questionLayer = document.getElementById("question");
	else questionLayer = document.all ? document.all["question"] : null;


	if (ns5) answerLayer = document.getElementById("answer");
	else answerLayer = document.all ? document.all["answer"] : null;


	questionLayer.innerHTML = q;
	answerLayer.innerHTML = a;


	clearTimeout(timerID);
}



function hideHelp()
{
	helpLayer = getLayer('quickHelp');
	helpLayer.style.visibility = "hidden";
	clearTimeout(timerID);
}




function keepHelp()
{
	helpLayer = getLayer('quickHelp');
	helpLayer.style.visibility = "visible";
	clearTimeout(timerID);
}




// rückruf
function checkCallback()
{
	if (!checkTelNumber()) return false;


	//cur_weekday = <?=$cur_date['wday']?>;
	//if (!checkTime()) return false;

	if (document.callbackform.tel.value == "" || document.callbackform.tel.value.length < 6)
	{
		alert("Bitte gib deine Telefonnummer an,\n unter der wir dich erreichen können.");
		return false;
	}
	else if (document.callbackform.name.value == "")
	{
		alert("Bitte gib deinen Namen an.");
		return false;
	}
	else if (document.callbackform.rueckruf_von.value == "" || document.callbackform.rueckruf_bis.value == "")
	{
		alert("Bitte gib an, von wann bis wann wir dich am besten erreichen können.");
		return false;
	}
	else return true;
}

// rückruf
function checkTelNumber()
{
	allowedChars = "0123456789-()/.";
	tel = tel_orig = document.callbackform.tel.value;

	checkAgain = true;
	// delete all illegal characters
	while(checkAgain)
	{
		checkAgain = false;
		for (i=0; i<tel.length; i++)
		{
			if (allowedChars.indexOf(tel.charAt(i)) == -1)
			{
				tel = tel.substring(0,i) + tel.substring(i+1,tel.length);
				checkAgain = true;
				break;
			}
		}
	}

	document.callbackform.tel.value = tel;

	if(document.callbackform.tel.value == tel_orig) return true;
	else
	{
		alert ("Ungültiges Zeichen in der Telefonnummer wurde entfernt.\nBitte überprüfe deine Eingabe nochmal.");
		return false;
	}
}



// bewerbung
function skistufe()
{
	show_ski_quali = (document.bewerbungsformular.job_1wahl.value == 2 || document.bewerbungsformular.job_2wahl.value == 2 || document.bewerbungsformular.job_1wahl.value == 4 || document.bewerbungsformular.job_2wahl.value == 4);
	show_board_quali = (document.bewerbungsformular.job_1wahl.value == 3 || document.bewerbungsformular.job_2wahl.value == 3 || document.bewerbungsformular.job_1wahl.value == 4 || document.bewerbungsformular.job_2wahl.value == 4);

	getLayer('skiquali').style.display = (show_ski_quali) ? 'block' : 'none';
	getLayer('boardquali').style.display = (show_board_quali) ? 'block' : 'none';
}
// bewerbung
function add_termin()
{
	if(document.bewerbungsformular.termine_count.value >= 4)
	{
		alert ("Du kannst nicht mehr als 4 Zeitspannen angeben");
		return
	}
	document.bewerbungsformular.termine_count.value++;
	document.bewerbungsformular.add_value.value = 1;
	document.bewerbungsformular.submit();
}



// forum
function putTag(tag)
{
	if (document.form.body.createTextRange && document.form.body.caretPos) {
		// IE. Proprietäre Funktionen nutzen, um Text an Cursor-Stelle einzufügen
		document.form.caretPos.text = tag;
	}
	else {
		document.form.body.value += tag;
	}
}




function zoomImage(url, width, height)
{
	var scrollbars = 'no';

	if (width > 775) {
		width = 775;
		scrollbars = 'yes';
	}

	if (height > 550) {
		height = 550;
		scrollbars = 'yes';
	}

	popup('/image.php?imagesource='+escape(url), width, height, scrollbars);
	//w.focus();
}


function showLocationVideo(id)
{
	dispNone(id+'-teaser');
	dispBlock(id);
}
function hideLocationVideo(id)
{
	dispBlock(id+'-teaser');
	dispNone(id);
}