
 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());
			});
		});

		nav = $("#nav_"+pageId).position();
		width = $("#nav_"+pageId).width();
		
		
				
				newHeight=$(".outerDiv").height()-$("#contentInnerBox").offset().top;
				$("#contentBox").animate({ marginLeft: -400}, 700, function(){
					query=query+"&sub="+$("#nav_"+pageId).attr("sub")+"&navId="+$("#nav_"+pageId).attr("navId");
					createContentElements(query, pageId);
					
					crateHeaderImage(query);
				});
			
		if(pageId==1){
			$("#appixButton").show();
			
		}else{
			$("#appixButton").hide();
		}
		
		
}



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

}





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(){
					$("#contentBox").animate({marginLeft: 0}, 700, function(){
					
					});
				});	
				
				
			});

		});
	//});
}


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




	tmpObj="";
	$(".mainNavi").click(function(){
		newObj = this;
		index=0;

	});
	
	$(".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 = "";
tmpNav = "";
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'));
			
			
			if($("#nav_"+pageId).parent().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","#000");
				$("#nav_"+pageId).css("color","#000");
				tmpSubNavi = $("#nav_"+pageId);
				
				offsetSub = $("#nav_"+pageId).position();
				offsetTop = offsetSub.top;
				sub=true;
				
			}else{
				var offset = $("#nav_"+pageId).position();
				var width = $("#nav_"+pageId).width();	
				offsetSub = $("#nav_"+pageId).position();
				offsetTop = offsetSub.top+12;
				sub=false;
			}
			
			index=0;

			if(!sub){
				$(".subNaviBoxOuter").each(function(){
					index++;
					
					$(this).slideUp("fast", function(){
						if(index==$(".subNaviBoxOuter").length){
							
							$("#naviPointer").animate({ width: (offset.left+width-10) }, "slow", function(){
								
								$("#nav_"+pageId).addClass("moNaviClick");
								if(tmpNav!=""){
									tmpNav.removeClass("moNaviClick");
								}
								tmpNav = $("#nav_"+pageId);
								if($(".subNaviBox_"+pageId).height()>5){
									$(".subNaviBox_"+pageId).css("width", width+20);
									$(".subNaviBox_"+pageId).slideDown(500, function(){
										query="pageId="+pageId;
										setPage(query, pageId);	
										
									});
								}else{
									query="pageId="+pageId;
									setPage(query, pageId);	
								}
					
							
							
							});
						}
					});
				
				});	
			}else{
				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");
			});
			
		});
	}
}
