$(document).ready(function() {
	/**************************************************************************************************************************************************
		Equal Colums - http://www.jainaewen.com/files/javascript/jquery/equal-height-columns.html
	***************************************************************************************************************************************************/
	$('.yellowbox .content, .tippbox .content').equalHeightColumns();
	/**************************************************************************************************************************************************
		Font resize
	***************************************************************************************************************************************************/
	$("#up").fontscale("#topbar, #rightcol,#leftcol","up",{unit:"em",increment:1, adjustLeading:true, useCookie:true}); 
	$("#down").fontscale("#topbar, #rightcol,#leftcol","down",{unit:"em",increment:1, adjustLeading:true, useCookie:true});
	$("#reset").fontscale("#topbar, #rightcol,#leftcol","reset");
	
	/**************************************************************************************************************************************************
		Collapse
	***************************************************************************************************************************************************/
	// Merke: Container für den Inhalt ist ein div, ul oder p DIREKT nach dem a.collapse Tag
	$("body").collapse({
		head : ".collapse", /* Type of element you want act as clickable headings */
		group: "div, ul", /* Type of element to group hidden content */
		cookieName : "collapse",
		show: function(){
			this.animate({
				opacity: 'toggle', 
				height: 'toggle'
			}, 300);
		},
		hide: function() {
			this.animate({
				opacity: 'toggle', 
				height: 'toggle'
			}, 300);
		}
  });
	
	/**************************************************************************************************************************************************
		Validate Forms - http://docs.jquery.com/Plugins/Validation
	***************************************************************************************************************************************************/
	$(".validate").validate();
	
	/**************************************************************************************************************************************************
		Clear Form Fields
	***************************************************************************************************************************************************/
	var clearMePrevious = '';
	
	// clear input on focus
	$("input.clearme").focus(function()
	{
		if($(this).val()==$(this).attr('value'))
		{
			clearMePrevious = $(this).val();
			$(this).val('');
		}
	});
	// if field is empty afterward, add text again
	$('input').blur(function()
	{
		if($(this).val()=='')
		{
			$(this).val(clearMePrevious);
		}
	});
	
	/**************************************************************************************************************************************************
		Smooth Scroll to Top
	***************************************************************************************************************************************************/
	$('a[href=#ankertop]').bind("click", function(event) {
		event.preventDefault();
		var ziel = $(this).attr("href");
	
		$('html,body').animate({
			scrollTop: $(ziel).offset().top
		}, 200 , function (){location.hash = ziel;});
	});
	
	/**************************************************************************************************************************************************
		Autocomplete Schulen
	***************************************************************************************************************************************************/
	$(".autocomplete").autoSuggest("/aktionstage-fortbildungsmodule/autocomplete.php", { // Liste der Suchbegriffe
		keyDelay: 0, // Delay von anzeige der Suchliste
		startText: "PLZ, Ort oder Name", // Text to display when the AutoSuggest input field is empty.
		emptyText: "Kein Treffer", // Text to display when their are no search results.
		resultClick: function(data){
			// console.log(data);
			// alert(data.attributes.value);
			window.location = '/aktionstage-fortbildungsmodule/teilnehmer-karte.php?sid='+data.attributes.haendlerID;
		},
		minChars: 2, // mind. 2 Zeichen eingeben, bevor gesucht wird
		selectedItemProp: "firma", // Ausgabe
		searchObjProps: "firma" // Suchbereich
	});
	/**************************************************************************************************************************************************
		Seite drucken
	***************************************************************************************************************************************************/
	/*
	$("a.print").click(function(event){
		event.preventDefault();
		var seite = $(this).attr("href");
		var popup = window.open(seite,'print','toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=1,width=685,height=580');
	});
	*/
});
