
var start_topSearch = '';
var start_topAnreise = '';
var start_topAbreise = '';
var start_topZimmmer = '';

/**
	Pruefung Form. Zimmer
*/
function checkDPickTop(){
	var dp_from   = $('#dpickVon').val();
	var dp_to     = $('#dpickBis').val();
	var dp_zimmer = $('#dpickZimmer').val();
	var er        = '';
	if( dp_from=='' || dp_from==start_topAnreise ){
		er+= 'Der Tag der Anreise wurde nicht gewaehlt.\n';
	}
	if( dp_to=='' || dp_to==start_topAbreise ){
		er+= 'Der Tag der Abreise wurde nicht gewaehlt.\n';
	}
	if( isInt( $('#dpickZimmer').val() )==false ){
		er+= 'Die Zimmeranzahl wurde nicht angegeben.\n';
	}
	if( er!='' ){
		alert( er );
		return false;
	}
	return true;
}

/**
	Pruefung Suchform.
*/
function checkSearchForm(){
	return $('#strSuche').val()=='' || $('#strSuche').val()==start_topSearch ? false : true
}

/**
	onLoad Events fuer Formular-Felder
*/
$(document).ready(function () {
	
	start_topAnreise = $('#dpickVon').val();
	$('#dpickVon').datePicker({
		startDate : new Date().addDays(0).asString(),
		endDate: new Date().addDays( 356*10 ).asString(),
		createButton: false,
		closeOnSelect: true,
		displayClose: true,
		clickInput: true
	});//.val(new Date().asString()).trigger('change');
	
	start_topAbreise = $('#dpickBis').val();
    $('#dpickBis').datePicker({
		startDate : new Date().addDays(0).asString(),
		endDate: new Date().addDays( 356*10 ).asString(),
		createButton: false,
		closeOnSelect: true,
		displayClose: true,
		clickInput: true
    }).focus(function(){
			if( this.value==start_topAbreise && $('#dpickVon').val()!=start_topAnreise )this.value = $('#dpickVon').val(); 
	});//.val(new Date().asString()).trigger('change');
	
	start_topZimmmer = $('#dpickZimmer').val();
	$('#dpickZimmer').click(function(){
		this.value = ''
	}).blur(function(){
		if( this.value == '' )this.value = start_topZimmmer;
	});
	
	start_topSearch = $('#strSuche').val();
	$('#strSuche').focus(function(){
		this.value = '';
	}).blur(function(){
		if( this.value == start_topSearch || this.value=='' ){
			this.value = start_topSearch;
		}
	});
	
	//---------------------------------------------
	//Buchungsform
	$('.date-pick').datePicker({
		startDate : new Date().addDays(0).asString(),
		endDate: new Date().addDays( 356*10 ).asString(),
		createButton: true,
		closeOnSelect: true,
		displayClose: true,
		clickInput: false
	}).bind(
		'dateSelected',
		function(e, selectedDate, $td)
		{
			var dateStr = selectedDate.asString();
			//alert( dateStr );
			check_buchung(0);
		}
	);
	
	$("#speziId").change(function(){
		check_buchung(0);
		//var url = 'sites/site1/json.php?mod=bg_date&von='+$('#dpickBgVon').val()+'&bis='+$('#dpickBgBis').val()+'&spezi='+$('#speziId option:selected').val();
	});
	
	//---------------------------------------------
	//Last-Minute Info
	$("#lastMinuteLayer").hide();
	$("#lastMinuteButton").hover(
		function(){ $("#lastMinuteLayer").fadeIn();},
		function(){ $("#lastMinuteLayer").fadeOut();}
	);

	//---------------------------------------------
	//Last-Minute Info
	$("#TagungSpezLayer").hide();
	$("#TagungSpezButton img").hover(
		function(){ $("#TagungSpezLayer").fadeIn();},
		function(){ $("#TagungSpezLayer").fadeOut();}
	);
	
	//---------------------------------------------
	//Spezial-Angebote
	$('#centerBox .spezialAngebot').each(function( ix, val ){
		if( ix%2 > 0 ){
			$(this).after('<div class="clearer"></div>');
		}
	});
});

//---------------------------------------------
//Buchungsform
function check_buchung( blSend ){
	//alert('json');
	var doSend = true;
	$.getJSON('sites/site1/json.php?',{
			'mod': 'bg_date',
			'von': $('#dpickBgVon').val(),
			'bis': $('#dpickBgBis').val(),
			'spezi': $('#speziId option:selected').val(),
			'blSend': blSend
		},function(data) {
			if( data==null )return;
			//$('#bgTest').html( data.jdebug );
			jQuery.each( data.arZimkatAll, function() {
				$("#zimkatTR" + this+" td").hide();
			});
			jQuery.each( data.arZimkatShow, function() {
				$("#zimkatTR" + this+" td").show();
			});
			if( data.error ){
				jAlert( data.error, "Es ist ein Fehler aufgetreten" );
				doSend = false;
			}
		});
	return doSend;
	//alert('OK');
}



/**
	SLIDESHOW
	
	<div id="headSlideShow">  
		<a href="#" class="show"><img src="images/....jpg" alt="Text" title="" width="580" height="360" rel="<h3>Beschrg.Ueberschrift</h3>Fliesstext" /></a>  
		<a href="#"><img src="images/....jpg" alt="Grass Blades" title="" width="580" height="360" rel="<h3>Uber</h3>text" /></a>  
		<div class="caption"><div class="content"></div></div>  
	</div>  
	<div class="clearer"></div>
*/
function headSlideShow() {  
	//Set the opacity of all images to 0  
	$('#headSlideShow a').css({opacity: 0.0});  
	//Get the first image and display it (set it to full opacity)  
	$('#headSlideShow a:first').css({opacity: 1.0});  
	//Set the caption background to semi-transparent  
	$('#headSlideShow .caption').css({opacity: 0.7});  
	//Resize the width of the caption according to the image width  
	$('#headSlideShow .caption').css({width: $('#headSlideShow a').find('img').css('width')});  
	//Get the caption of the first image from REL attribute and display it  
	//$('#headSlideShow .content').html($('#headSlideShow a:first').find('img').attr('rel')).animate({opacity: 0.7}, 400);  
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds  
	setInterval('headGallery()',5000);  
}  
   
function headGallery() {  
	//if no IMGs have the show class, grab the first image  
	var current = ($('#headSlideShow a.show')?  $('#headSlideShow a.show') : $('#headSlideShow a:first'));  
	//Get next image, if it reached the end of the slideshow, rotate it back to the first image  
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#headSlideShow a:first') :current.next()) : $('#headSlideShow a:first'));     
	//Get next image caption  
	var caption = '';//next.find('img').attr('rel');   
	//Set the fade in effect for the next image, show class has higher z-index  
	next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 2000);  
	//Hide the current image  
	current.animate({opacity: 0.0}, 1000).removeClass('show');  
	//Set the opacity to 0 and height to 1px  
	//$('#headSlideShow .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 });   
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect  
	//$('#headSlideShow .caption').animate({opacity: 0.7},100 ).animate({height: '100px'},500 );  
	//Display the content  
	//$('#headSlideShow .content').html(caption);  
}

/**
	STAT
*/
var id="edison";
var pphPath="http://www.hotel-edison.de/pp/";
if(showme==null)var showme='n';if(st==null)var st='js';var v=navigator.appName;var c=0;if(v!="Netscape")c=screen.colorDepth;else c=screen.pixelDepth;var s=screen.width+"x"+screen.height;var t=escape(document.title);var f="";if(typeof(pp_frames)!="undefined")if(pp_frames)f=top.document.referrer;if((f=="")||(f=="[unknown origin]")||(f=="unknown")||(f=="undefined"))if(document["parent"]!=null)if(parent["document"]!=null)if(parent.document["referrer"]!=null)if(typeof(parent.document)=="object")f=parent.document.referrer;if((f=="")||(f=="[unknown origin]")||(f=="unknown")||(f=="undefined"))if(document["referrer"]!=null)f=document.referrer;if((f=="")||(f=="[unknown origin]")||(f=="unknown")||(f=="undefined"))f="";f=escape(f);var r="?id="+id+"&referer="+f+"&r="+s+"&c="+c+"&showme="+showme+"&st="+st+"&title="+t;if(jslogid==null)var jslogid=0;else r=r+"&jslogid="+jslogid;if(st=='js'){if(v!="Microsoft Internet Explorer")r=r+"&url="+document.URL;document.open();document.write("<script language=\"JavaScript\" type=\"text/javascript\" src=\""+pphPath+"pphlogger.php"+r+"\"></script>");document.close()}else{rand=Math.round(1000*Math.random());r=r+"&b="+rand;document.open();document.write("<img src=\""+pphPath+"pphlogger.php"+r+"\" alt=\"\" border=\"0\">");document.close()}



