
 jQuery(function(jQuery)  
 {  
   jQuery.datepicker.regional['de'] = {clearText: 'löschen', clearStatus: 'aktuelles Datum löschen',  
              closeText: 'schließen', closeStatus: 'ohne Änderungen schließen',  
              prevText: '<zurück', prevStatus: 'letzten Monat zeigen',  
              nextText: 'Vor>', nextStatus: 'nächsten Monat zeigen',  
              currentText: 'heute', currentStatus: '',  
              monthNames: ['Januar','Februar','März','April','Mai','Juni',  
              'Juli','August','September','Oktober','November','Dezember'],  
              monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',  
              'Jul','Aug','Sep','Okt','Nov','Dez'],  
              monthStatus: 'anderen Monat anzeigen', yearStatus: 'anderes Jahr anzeigen',  
              weekHeader: 'Wo', weekStatus: 'Woche des Monats',  
              dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],  
              dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],  
              dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],  
              dayStatus: 'Setze DD als ersten Wochentag', dateStatus: 'Wähle D, M d',  
              dateFormat: 'dd.mm.yy', firstDay: 1,   
              initStatus: 'Wähle ein Datum', isRTL: false};  
   jQuery.datepicker.setDefaults(jQuery.datepicker.regional['de']);  
 });  

function setPage(query, pageId){ 

		$.get("core/ajax/page.php",query, function(data){  
			$(data).find("page").each(function(){
				//document.title = ($(this).find("pageTitle").text());
			});
		});


		if(pageId==21){
			$("#checkBoxLabel_1").show();
			
		}else{
			$("#checkBoxLabel_1").hide();
		}
		$("#contentBoxWhite").animate({ marginLeft: -400}, "slow", function(){
			query=query+"&sub="+$("#nav_"+pageId).attr("sub")+"&navId="+$("#nav_"+pageId).attr("navId");
			createContentElements(query, pageId);
			
			crateHeaderImage(query);		
		
		});
		
}



function createContentElements(query, pageId, sub){
	
		//$("#contentInnerBox").fadeOut("slow", function(){
			
			$.get("core/ajax/element.php",query, function(data){ 
				
				$("#contentInnerBox").html(data);
					

					
				//$("#contentInnerBox").fadeIn("slow", function(){
				//});
			});
		//});
			if(pageId==67 || pageId==57){
					$.get("staticContent/maps.htm",null, function(data){
						$("#contentInnerBox").append(data);
					
					});
			}
}





function crateHeaderImage(query){
	query = query+"&do=pluginHeader";
	//$("#bgImg").fadeOut(500, function(){
		$("#bgImg2").attr("src", $('#bgImg').attr('src'));
		$.get("core/ajax/plugin.php",query, function(data){  
			query = query+"&do=pluginText";
			$("#bgImg").hide();
			$.get("core/ajax/plugin.php",query, function(dataText){
				$("#bgImg").attr("src","images/content/uploads/"+data);
				
				$("#bgImg").fadeIn("slow", function(){
					$("#contentBoxWhite").animate({ marginLeft: 0}, "slow");
				});	
				$("#contentInnerBoxZitat").html(dataText);
				
			});

		});
	//});
}


  
$(document).ready(function(){  
	setInterval("checkAnchor()", 300);  


	$(function() {
		$('.dataPicker').datepicker({
			changeMonth: true,
			changeYear: true
		});
	});
	
	$(".dataPicker").change(function(){
		newValue=$(this).val();
		$(".dataPicker").each(function(){
			$(this).attr("value", newValue);
		});
		
	})
	
	$(".closeForm").click(function(){
		$(".reserverPluginBox").slideUp("slow", function(){
			$("#reservationForm").show();
			$("#reservationFormEnd").hide();
		});

		
	});
	
	$(".numField").change(function(){
		newValue=$(this).val();
		$(".numField").each(function(){
			$(this).attr("value", newValue);
		});
	})
	
	$(".guestField").change(function(){
		newValue=$(this).val();
		$(".guestField").each(function(){
			$(this).attr("value", newValue);
		});
	})


	tmpObj="";
	$(".mainNavi").mouseenter(function(){
		if(tmpObj!=this){

			newObj = this;
			index=0;
			$(".subNaviBox").each(function(){
				index++;
				$(this).slideUp("fast");
				if(index==$(".subNaviBox").length){
					$(".subNaviBox_"+$(newObj).attr("id").replace("nav_", "")).slideDown("fast");
					tmpObj = newObj;
				}
			});
		}
	});
	
	$(".navi").mouseenter(function(){
		$(this).addClass("moNavi");
	});
	
	$(".navi").mouseleave(function(){
		$(this).removeClass("moNavi");
	});

	$(".reserverPlugin").click(function(){
		$(".reserverPluginBox").slideDown("slow");
	});
	
	

});  



function showPrice(actPrice, objThis){
	closedBoxes=0;

	$('.saissonBox').slideUp('slow', function(){
		closedBoxes++;
		if(closedBoxes==$('.saissonBox').size())
			$('#'+actPrice).slideDown('slow');
	});
	
	$(".active").removeClass("active");
	$(objThis).addClass("active");
	

}
var currentAnchor = null;  
tmpSubNavi = "";
function checkAnchor(){  
	if(currentAnchor != document.location.hash){  
		currentAnchor = document.location.hash;  
		
		if(!currentAnchor)  
		   query = "pageId=1";  
		else  
		{  
			
			pageId = currentAnchor.substring(currentAnchor.lastIndexOf('-')+1, currentAnchor.indexOf('.html'));
			
			tmpNav = $("#nav_"+pageId);
			if($("#nav_"+pageId).parent().parent().children(0).attr("id")!="naviPointer"){
				var offset = $("#nav_"+pageId).parent().parent().children(0).position();
				var width = $("#nav_"+pageId).parent().parent().children(0).width();
				if(tmpSubNavi!="")
					$(tmpSubNavi).css("color","#646464")
				$("#nav_"+pageId).css("color","#e5e5e5")
				tmpSubNavi = $("#nav_"+pageId);
				
				offsetSub = $("#nav_"+pageId).position();
				offsetTop = offsetSub.top+27;
				
				
			}else{
				var offset = $("#nav_"+pageId).position();
				var width = $("#nav_"+pageId).width();	
				offsetSub = $("#nav_"+pageId).position();
				offsetTop = offsetSub.top+12;
				
			}
			
			
			
			$("#naviPointer").animate({ left: offset.left+"px", width: width }, "slow", function(){
				
			});
			
			//$("#naviPointer2").animate({height: offsetTop+"px" }, "slow", function(){
				
			//});
			
			
		
			
			query="pageId="+pageId;
			setPage(query, pageId);	
	
		}  
		
				

		 
	}
}  

function changeLanguge(languageId){
		query = "language="+languageId;
		
			$.get("core/ajax/language.php",query, function(data){  
			window.location="";
		});
}



function sendForm(objForm, formId){
	error=0;
	$(".formFieldCheck_"+formId).each(function(){
		if($(this).attr("num")=="false"){
			if($(this).val().length<3){
				$(this).addClass("errorForm");
				error=1;
			}else{
				$(this).removeClass("errorForm");
			}
		}else{

			if(isNaN($(this).val())){
				$(this).addClass("errorForm");
				error=1;
			}else{
				$(this).removeClass("errorForm");
			}
		}
		
	});
	if(error!=1){
		query = $(objForm).serialize();

		$.get("staticContent/sendForm.php",query, function(data){  
			$("#reservationForm_"+formId).slideUp("slow", function(){
				$("#reservationFormEnd_"+formId).slideDown("slow");
			});
			
		});
	}
}
