document.write('<style>.noscript { display: none; }</style>');

// adding special effects
jQuery.fn.fadeToggle = function(speed, easing, callback) {
	return this.animate({opacity: 'toggle'}, speed, easing, callback);
};
// helper functions
function initSmartlist(){
	if ($("#sl").length > 0 && $(".item").length > 1) {
		$.smartlist({
		  baseName:               "sl",
		  itemClass:              "item",
		  showFlagCount:          true,
		  itemFlagClass:          "flags",
		  itemFlagSeparator:      ",",
		  itemChangeEffect:       "Blind", // "FadeAppear", "Blind", ""
		  itemChangeDuration:     500, // ms for jQuery
		  pageChangeEffect:       "FadeAppear", // "FadeAppear", "Blind", ""
		  pageChangeDuration:     500, // ms for jQuery
		  numItemsPerPage:        10,
		  paginationLeft:         "\u00ab",
		  paginationRight:        "\u00bb",
		  maxPaginationLinks:     20,
		  defaultDropdownOptText: "Alle Resultate anzeigen"
		});
		$("#sl-flag-dropdown select").uniform();
	}
	$("#sl-pagination-previous").click(function() {
		//alert(1);
		return false;
	});
	$("#sl-pagination-next").click(function() {
		return false;
	});
	// versuch, pagination zu klonen
	// $('#sl-pagination').clone(true).appendTo('#sl-pagination_clone');
}
function uniformForms() {
	if ($("#frmReservation, #formID").length > 0) {
		$("select, input:checkbox, input:radio, input:file, input:text, textarea, input:submit, input:reset").uniform();
	}
	if ($("#frmSubscribe, #frmUnsubscribe").length > 0) {
		$("input:text, input:submit").uniform();
	}
}
// AJAX callbacks
function initAdvancedSearch() {
	$("#simpleSearchContainer").slideUp();
	$("input:checkbox,input:text, select, #tx_ncrestaurant_pi1_goAS, #tx_ncrestaurant_pi1_reset").uniform();
	$("#advancedSearchContainer").slideDown();
	$(".ncrestaurant_advancedSearch").slideDown();
	//$("#titleAdvancedSearch").slideDown();
	$("#searchResultContainer").fadeOut(100);
	$(".simpleSearch").toggle();
	$(".advancedSearch").toggle();
	$("#loader").fadeOut(100);
	
	// Erweiterte Suche feuern
	$("#tx_ncrestaurant_pi1_goAS").click(function(){
		$(".ac_results").hide();
		if ($("#ncrestaurant_name").val()!='' || 
			$("#ncrestaurant_street").val()!='' ||
			$("#ncrestaurant_postalcode").val()!='' ||
			$("#ncrestaurant_place").val()!='' ||
			$("#ncrestaurant_holder").val()!='' ||
			$("#ncrestaurant_director").val()!='' ||
			$("#ncrestaurant_tel").val()!='' ||
			$("#select_category_1").val()!='' ||
			$("#select_category_2").val()!='' ||
			$("#select_category_3").val()!='' ||
			$("#select_category_4").val()!='' ||
			$("#select_category_5").val()!='' ||
			$("#select_category_6").val()!='' ||
			$("#select_category_7").val()!='' ||
			$("#select_category_8").val()!='' ||
			$("#select_category_9").val()!='') {
			
			$("#loaderAS").fadeIn();
			xajax_getListViewAjaxAS(xajax.getFormValues("advancedSearch"));
		}else{
			$("#ncrestaurant_name").focus();
		}
		return false;
	});
}
function initListView() {
	setTimeout('initSmartlist();',200);
	//initSmartlist();
	$(".item").css('opacity',0.8);
	$("#searchResultContainer").fadeOut(100);
	$("#searchResultContainer").fadeIn().delay(100);
	$("#loader").fadeOut(100);
	$(".ac_results").hide();
	// DIV rollover- und click-handling
	$(".item").mouseover(function(){
		$(this).css('opacity',1);
		$(this).css('cursor','pointer');
	});
	$(".item").mouseout(function(){
		$(this).css('opacity',0.8);
		$(this).css('cursor','default');
	});
	
	$(".item").click(function(){
		window.location=$(".mainLink",this).attr('href');
		return false;
	}); 
	// Banner hack
	$("#c551, #c542, #c548").slideUp(100);
}
function initListViewAS() {
	$(".ac_results").hide();
	initSmartlist();
	$(".item").css('opacity',0.8);
	
	//$("#titleAdvancedSearch").fadeOut();
	$(".ncrestaurant_advancedSearch").slideUp();
	$("#advancedSearchContainer").fadeOut();
	$("#loaderAS").fadeOut();
	$(".advancedSearch").toggle(0);
	$(".simpleSearch").toggle(0);
	$("#simpleSearchContainer").slideDown();
	
	
	$("#searchResultContainer").fadeIn();
	$("#loader").fadeOut(100);
	
	// DIV rollover- und click-handling
	$(".item").mouseover(function(){
		$(this).css('opacity',1);
		$(this).css('cursor','pointer');
	});
	$(".item").mouseout(function(){
		$(this).css('opacity',0.8);
		$(this).css('cursor','default');
	});
	
	$(".item").click(function(){
		window.location=$(".mainLink",this).attr('href');
		return false;
	}); 
}

jQuery(document).ready(function($) {
	
	$('#formID').attr('action','');
	
// h�he bei detail anpassen
	if($(".left_cube").height() > $(".restaurant-open").height()) {
		$(".restaurant-open").height($(".left_cube").height());
	}else{
		$(".left_cube").height($(".restaurant-open").height());
	}
	
// Setze Fokus auf Suchfeld
	setTimeout('$("#tx_ncrestaurant_pi1_searchTerm").focus();',200);
	
// AJAX-Handlings
	// Erweiterte Suche
	$(".advancedSearch").click(function(){
		if($("#advancedSearchContainer").html()!=''){
			$(".ncrestaurant_advancedSearch").toggle();
			$("#advancedSearchContainer").slideDown();
			$("#simpleSearchContainer").slideToggle();
			//$("#titleAdvancedSearch").slideToggle();
			$(".advancedSearch").toggle();
			$(".simpleSearch").toggle();
			$("#searchResultContainer").fadeOut(100);
			
		}else{
			$("#loader").fadeIn(100);
			xajax_getAdvancedSearch();
		}
		return false;
	});
	
	// Einfache Suche
	$(".simpleSearch").click(function() {
		$("#advancedSearchContainer").slideToggle();
		//$("#titleAdvancedSearch").fadeOut();
		$(".advancedSearch").toggle(0);
		$(".simpleSearch").toggle(0);
		$("#simpleSearchContainer").slideDown();
		$("#searchResultContainer").fadeIn();
		return false;
	});
	
	$('#tx_ncrestaurant_pi1_searchTerm').keyup(function(e) {
		if(e.keyCode == 13) {
			$("#tx_ncrestaurant_pi1_go").click();
			return false;
		}
	});
	
	
	// Suche feuern
	$("#tx_ncrestaurant_pi1_go").click(function(){
		//alert('search');
		$(".ac_results").hide();
		if($("#tx_ncrestaurant_pi1_searchTerm").val().length > 2) {
			$("#loader").fadeIn(100);
			
			xajax_getListViewAjax($("#tx_ncrestaurant_pi1_searchTerm").val());
		}else{
			$("#tx_ncrestaurant_pi1_searchTerm").focus();
		}
		return false;
	});
	
	// Erweiterte Suche feuern
	$("#tx_ncrestaurant_pi1_goAS").click(function(){
		$("#advancedSearchContainer").slideToggle();
		//$("#titleAdvancedSearch").fadeOut();
		$(".advancedSearch").toggle(0);
		$(".simpleSearch").toggle(0);
		$("#simpleSearchContainer").slideDown();
		
		xajax_getListViewAjaxAS(xajax.getFormValues("advancedSearch"));
		return false;
	});
	
// autocomplete
	if ($("#tx_ncrestaurant_pi1_searchTerm").length > 0) {
		jQuery("#tx_ncrestaurant_pi1_searchTerm").autocomplete("index.php?eID=tx_ncrestaurant_autocomplete", {
	        minChars: 3,
	        selectFirst: false,
	        max: 10,
	        autoFill: 0,
	        delay: 1,
	        matchContains: 1,
	        scroll: 1,
	        multiple: 0,
	        multipleSeparator: ' '
		});
	}
	// listview
	//initListView(1);
	// DIV rollover- und click-handling
	$(".item").mouseover(function(){
		$(this).css('opacity',1);
		$(this).css('cursor','pointer');
	});
	$(".item").mouseout(function(){
		$(this).css('opacity',0.8);
		$(this).css('cursor','default');
	});
	
	$(".item").click(function(){
		window.location=$(".mainLink",this).attr('href');
		return false;
	});
	// Smartlist
	//setTimeout('initSmartlist();',1000);
	//initSmartlist();
	//initSmartlist();
	// Uniform form styles
	uniformForms();
	
	// validate
	if ($("#frmReservation, #frmSubscribe, #frmUnsubscribe").length > 0){
		jQuery.extend(jQuery.validator.messages, {
		    required: "Bitte machen Sie eine Eingabe",
		    email: "Bitte geben Sie eine korrekte E-Mail-Adresse ein"
		});
		$("#frmReservation, #frmSubscribe").validate();
		$("#frmUnsubscribe").validate();
		/*
		$('#tel').keyup(function(){
			if ($(this).val().length > 0) {
				$('#email').removeClass('required');
			}else{
				$('#email').addClass('required');
			}
		});
		*/
	}

// Initialize date-time-picker
	if ($("#datetime").length > 0){
		
		$('#datetime').datetimepicker({
			showSecond: false,
			showButtonPanel: true,
			timeFormat: 'hh:mm',
			stepHour: 1,
			stepMinute: 15,
			timeOnlyTitle: 'Zeit ausw�hlen',
			timeText: 'Zeit',
			hourText: 'Stunde',
			minuteText: 'Minute',
			secondText: 'Sekunde',
			currentText: 'Jetzt',
			monthNames: ['Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'],
			monthNamesShort: ['Jan','Feb','Mar','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: 'KW',
			dateFormat: 'dd. MM yy | Zeit:',
			firstDay: 1,
			closeText: 'OK',
			hourGrid: 4,
			minuteGrid: 15
		});
	}

// gallery initialisieren
	if ($("#thumbs").length > 0){
		// We only want these styles applied when javascript is enabled
		$('div.navigation').css({'width' : '300px', 'float' : 'left', 'min-height' : '317px'});
		$('div.content').css('display', 'block');
	
		// Initially set opacity on thumbs and add
		// additional styling for hover effect on thumbs
		var onMouseOutOpacity = 0.67;
		$('#thumbs ul.thumbs li').opacityrollover({
			mouseOutOpacity:   onMouseOutOpacity,
			mouseOverOpacity:  1.0,
			fadeSpeed:         'fast',
			exemptionSelector: '.selected'
		});
		
		// Initialize Advanced Galleriffic Gallery
		var gallery = $('#thumbs').galleriffic({
			delay:                     2500,
			numThumbs:                 36,
			preloadAhead:              10,
			enableTopPager:            true,
			enableBottomPager:         true,
			maxPagesToShow:            1,
			imageContainerSel:         '#slideshow',
			controlsContainerSel:      '#controls',
			captionContainerSel:       '#caption',
			loadingContainerSel:       '#loading',
			renderSSControls:          true,
			renderNavControls:         false,
			playLinkText:              'Diashow abspielen',
			pauseLinkText:             'Diashow anhalten',
			prevLinkText:              '&lsaquo;&lsaquo;',
			nextLinkText:              '&rsaquo;&rsaquo;',
			nextPageLinkText:          'Next &rsaquo;',
			prevPageLinkText:          '&lsaquo; Prev',
			enableHistory:             true,
			autoStart:                 false,
			syncTransitions:           true,
			defaultTransitionDuration: 900,
			onSlideChange:             function(prevIndex, nextIndex) {
				// 'this' refers to the gallery, which is an extension of $('#thumbs')
				this.find('ul.thumbs').children()
					.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
					.eq(nextIndex).fadeTo('fast', 1.0);
			},
			onPageTransitionOut:       function(callback) {
				this.fadeTo('fast', 0.0, callback);
			},
			onPageTransitionIn:        function() {
				this.fadeTo('fast', 1.0);
			}
		});
	
		/**** Functions to support integration of galleriffic with the jquery.history plugin ****/
	
		// PageLoad function
		// This function is called when:
		// 1. after calling $.historyInit();
		// 2. after calling $.historyLoad();
		// 3. after pushing "Go Back" button of a browser
		function pageload(hash) {
			// alert("pageload: " + hash);
			// hash doesn't contain the first # character.
			if(hash) {
				$.galleriffic.gotoImage(hash);
			} else {
				gallery.gotoIndex(0);
			}
		}
	
		// Initialize history plugin.
		// The callback is called at once by present location.hash. 
		$.historyInit(pageload, "advanced.html");
	
		// set onlick event for buttons using the jQuery 1.3 live method
		$("a[rel='history']").live('click', function(e) {
			if (e.button != 0) return true;
			
			var hash = this.href;
			hash = hash.replace(/^.*#/, '');
	
			// moves to a new page. 
			// pageload is called at once. 
			// hash don't contain "#", "?"
			$.historyLoad(hash);
	
			return false;
		});
	}

				/****************************************************************************************/
});
