/* German initialisation for the jQuery UI date picker plugin. */
/* Written by Milian Wolff (mail@milianw.de). */
jQuery(function($){
	$.datepicker.regional['de'] = {
		closeText: 'schließen',
		prevText: '&#x3c;zurück',
		nextText: 'Vor&#x3e;',
		currentText: 'heute',
		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'],
		dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
		dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
		dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
		weekHeader: 'Wo',
		dateFormat: 'dd.mm.yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};
	$.datepicker.setDefaults($.datepicker.regional['de']);
});
// JavaScript Document
//function HidePanel($obj){
//	$obj.hide("slide", {direction: "down" }, 1000);
//}
// Document.Ready Scripts
jQuery(document).ready(function($) {
	// add fancybox-iframe to 360° button
	//jQuery('#sitebox .threesixty a').addClass('fancybox-iframe');
	// hide/show #logo-panel
	//$("div#hidebutton").click(function(){
	//	$("div#sitebox").hide("slide",{direction:"down"},250);
	//	$("div#hidebutton").hide("fade",{direction:"down"},250);
	//	$("div#showbutton").show("slide",{direction:"down"},250);
	//});
	//$("div#showbutton").click(function(){
	//	$("div#sitebox").show("slide",{direction:"down"},250);
	//	$("div#showbutton").hide("fade",{direction:"down"},250);
	//	$("div#hidebutton").show("fade",{direction:"down"},250);	
	//});
	// datepicker
	var $disabledDays=["31.12.2011"];
	function disableAllThisDays(date){
		var d = date.getDate(), m = date.getMonth(), y = date.getFullYear();
		for (i = 0; i < $disabledDays.length; i++) {
			if($.inArray(d+'.'+(m+1)+'.'+y,$disabledDays)!=-1) {
				return [false];
			}
		}
		return [true];
	}
	var dates = $("#Anreise, #Abreise").datepicker({
		
		minDate: new Date(),
		beforeShowDay: disableAllThisDays,
		dateFormat: 'dd.mm.yy',
		changeMonth: true,
		numberOfMonths: 2,
		onSelect:function(selectedDate){
			var option = this.id == "Anreise" ? "minDate" : "maxDate", instance = $( this ).data( "datepicker" );
			date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings );
			dates.not(this).datepicker("option", option, date);
		}
	});
	$("#Anreise").datepicker();
	$("#Anreise").datepicker($.datepicker.regional['de']);
	$("#Abreise").datepicker();
	$("#Abreise").datepicker($.datepicker.regional['de']);
	// Comment Form validation
	$("#commentform").validate();
	// Startseite Accordion
	//$("#accordion").accordion();
	//$(".accordion .head").click(function(){$(this).next().toggle('fast');return false;}).next().hide();
	// GA CRM
	var z = _uGC(document.cookie, '__utmz=', ';'); 
	$ga_source = _uGC(z, 'utmcsr=', '|'); 
	$ga_medium = _uGC(z, 'utmcmd=', '|'); 
	$ga_keyword = _uGC(z, 'utmctr=', '|'); 
	var $ga_clid   = _uGC(z, 'utmgclid=', '|'); 
	if($ga_clid !="-") { 
		$ga_source = 'google'; 
		$ga_medium = 'cpc';
		}
	$('#source').attr('value',$ga_source);
	$('#medium').attr('value',$ga_medium);
	$('#keyword').attr('value',$ga_keyword);
});
// Google Analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-16079455-1']);
_gaq.push(['_trackPageview']);
(function(){
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
// GA ugc
function _uGC(l,n,s) {
 if (!l || l=="" || !n || n=="" || !s || s=="") return "-";
 var i,i2,i3,c="-";
 i=l.indexOf(n);
 i3=n.indexOf("=")+1;
 if (i > -1) {
  i2=l.indexOf(s,i); if (i2 < 0) { i2=l.length; }
  c=l.substring((i+i3),i2);
 }
 return c;
}
