/*function breakOut() {
	if (self != top)
	window.open('http://www.bayern-international.de/','_blank','');
}

if (top.frames.length!=0) {
	if (window.location.href.replace)
	top.location.replace(self.location.href);
	else
	top.location.href=self.document.href; 
}*/

//if (window!=top){top.location.href='http://www.bayern-international.de/';}

$(document).ready(function() {
	
	//breakOut();
	
	/*** clueTip-Konfigurationen (Tooltip-Ersatz) ***/
	//if(!($.browser.msie && $.browser.version <= 6)){
		
	$('[title]:not(.highslide)').cluetip({
		cluetipClass:     	'jtip',		// class added to outermost clueTip div in the form of 'cluetip-' + clueTipClass.
    	positionBy:       	'mouse',	// Sets the type of positioning.
    	topOffset:        	10,       	// Number of px to offset clueTip from top of invoking element.
    	leftOffset:       	20,       	// Number of px to offset clueTip from left of invoking element.
		width: 				275,
    	titleAttribute:   	'title',  	// the attribute to be used for fetching the clueTip's title
		showTitle:			false,
		cursor:           	'',
		cluezIndex:       	1020,     	// Sets the z-index style property of the clueTip
		dropShadow:       	false,     	// set to false if you don't want the drop-shadow effect on the clueTip
   		dropShadowSteps:  	3,        	// adjusts the size of the drop shadow
		arrows:           	false,		// if true, displays arrow on appropriate side of clueTip.
		splitTitle: 		'~',    
		fx: {             				// effect and speed for opening clueTips
			open:       'fadeIn', 		// can be 'show' or 'slideDown' or 'fadeIn'
			openSpeed:  'fast'
		}, 
		hoverIntent: {    
			sensitivity:  3,
			interval:     250,
			timeout:      0
		}
	}).find('> img').attr('title', '');
	
	$('select:not([size]) option[title]').cluetip({
		cluetipClass:     	'jtip',		// class added to outermost clueTip div in the form of 'cluetip-' + clueTipClass.
    	positionBy:       	'auto',		// Sets the type of positioning.
    	topOffset:        	10,       	// Number of px to offset clueTip from top of invoking element.
    	leftOffset:       	20,       	// Number of px to offset clueTip from left of invoking element.
		width: 				275,
    	titleAttribute:   	'title',  	// the attribute to be used for fetching the clueTip's title
		showTitle:			false,
		cursor:           	'',
		cluezIndex:       	3020,     	// Sets the z-index style property of the clueTip
		dropShadow:       	false,     	// set to false if you don't want the drop-shadow effect on the clueTip                     
   		dropShadowSteps:  	3,        	// adjusts the size of the drop shadow
		arrows:           	false,		// if true, displays arrow on appropriate side of clueTip.
		splitTitle: 		'~',    
		fx: {             				// effect and speed for opening clueTips
			open:       'fadeIn', 		// can be 'show' or 'slideDown' or 'fadeIn'
			openSpeed:  'fast'
		}, 
		hoverIntent: {    
			sensitivity:  3,
			interval:     250,
			timeout:      0
		}
	});
	
	$('#menuespalte .menue a[title]').cluetip({
		cluetipClass:     	'jtip menue',	// class added to outermost clueTip div in the form of 'cluetip-' + clueTipClass.
    	positionBy:       	'auto',	// Sets the type of positioning.
    	topOffset:        	30,       	// Number of px to offset clueTip from top of invoking element.
    	leftOffset:       	0,       	// Number of px to offset clueTip from left of invoking element.
		width: 				275,
    	titleAttribute:   	'title',  	// the attribute to be used for fetching the clueTip's title
		showTitle:			true,
		cursor:           	'',
		cluezIndex:       	1020,     	// Sets the z-index style property of the clueTip
		dropShadow:       	false,     	// set to false if you don't want the drop-shadow effect on the clueTip
   		dropShadowSteps:  	3,        	// adjusts the size of the drop shadow
		arrows:           	false,		// if true, displays arrow on appropriate side of clueTip.
		splitTitle: 		'|',    
		fx: {             				// effect and speed for opening clueTips
			open:       'fadeIn', 		// can be 'show' or 'slideDown' or 'fadeIn'
			openSpeed:  'fast'
		}, 
		hoverIntent: {    
			sensitivity:  3,
			interval:     250,
			timeout:      0
		}
	});
	$('#servicemenue ul.kopflinks a[title]').cluetip({
		cluetipClass:     	'jtip menue',	// class added to outermost clueTip div in the form of 'cluetip-' + clueTipClass.
    	positionBy:       	'bottomTop',	// Sets the type of positioning.
    	topOffset:        	10,       	// Number of px to offset clueTip from top of invoking element.
    	leftOffset:       	20,       	// Number of px to offset clueTip from left of invoking element.
		width: 				100,
    	titleAttribute:   	'title',  	// the attribute to be used for fetching the clueTip's title
		showTitle:			true,
		cursor:           	'',
		cluezIndex:       	1020,     	// Sets the z-index style property of the clueTip
		dropShadow:       	false,     	// set to false if you don't want the drop-shadow effect on the clueTip
   		dropShadowSteps:  	3,        	// adjusts the size of the drop shadow
		arrows:           	false,		// if true, displays arrow on appropriate side of clueTip.
		splitTitle: 		'|',    
		fx: {             				// effect and speed for opening clueTips
			open:       'fadeIn', 		// can be 'show' or 'slideDown' or 'fadeIn'
			openSpeed:  'fast'
		}, 
		hoverIntent: {    
			sensitivity:  3,
			interval:     250,
			timeout:      0
		}
	});
	
	$('a.lokal-laden').cluetip({
		cluetipClass:     	'jtip',
		sticky: 			true,
		closePosition: 		'top',
		closeText:			'<img src="/_img/layout/clear.gif" alt="schließen" />',
		activation: 		'click',
		titleAttribute:   	'',
		local: 				true,
		hideLocal: 			true,
		onShow:           function(ct, c) {
			$('#cluetip-title').html('');
			return true;},
		fx: {             				// effect and speed for opening clueTips
			open:       'fadeIn', 		// can be 'show' or 'slideDown' or 'fadeIn'
			openSpeed:  'fast'
		}
	});
				
	//};	
	
	/*** Konfiguration für datepicker (Datumsauswahl mit Kalender) ***/					   
	$('input.datepicker').each(function() {
		$(this).datepicker({
		  dateFormat: 'dd.mm.yy',
		  firstDay: 1,
		  dayNames: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'],
		  dayNamesMin: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
		  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'],
		  //showOtherMonths: true,
		  yearRange: '-1:+5',
		  //gotoCurrent: true,
		  changeMonth: true,
		  changeYear: true,
		  navigationAsDateFormat: true,
		  showButtonPanel: true,
		  currentText: 'Heute',
		  closeText: 'Schließen',
		  nextText: 'Früher',
		  prevText: 'Später',
		  showOn: 'both',
		  buttonImage: '/_img/layout/button-kalender.gif',
		  buttonText: 'Datum wählen',
		  showAnim: 'fadeIn',
		  duration: 'fast',
		  alignment: 'topRight'
		});
	});
	
	/*$.tablesorter.addWidget({
		// give the widget an id
		id: "sortPersist",
		// format is called when the on init and when a sorting has finished
		format: function(table) {
		
		  // Cookie info
		  var cookieName = 'MY_SORT_COOKIE';
		  var cookie = $.cookie(cookieName);
		  var options = {path: '/'};
		
		  var data = {};
		  var sortList = table.config.sortList;
		  var tableId = $(table).attr('id');
		  var cookieExists = (typeof(cookie) != "undefined" && cookie != null);
		
		  // If the existing sortList isn't empty, set it into the cookie and get out
		  if (sortList.length > 0) {
			if (cookieExists) {
			  data = $.evalJSON(cookie);
			}
			data[tableId] = sortList;
			$.cookie(cookieName, $.toJSON(data), options);
		  }
		
		  // Otherwise...
		  else {
			if (cookieExists) { 
		
			  // Get the cookie data
			  var data = $.evalJSON($.cookie(cookieName));
		
			  // If it exists
			  if (typeof(data[tableId]) != "undefined" && data[tableId] != null) {
		
				// Get the list
				sortList = data[tableId];
		
				// And finally, if the list is NOT empty, trigger the sort with the new list
				if (sortList.length > 0) {
				  $(table).trigger("sorton", [sortList]);
				}
			  }
			}
		  }
		}
	})
	$.tablesorter.addParser({
		id: 'germandate',
		is: function(s) {
			return false;
		},
		format: function(s) {
			var a = s.split('.');
			a[1] = a[1].replace(/^[0]+/g,"");
			return new Date(a.reverse().join("/")).getTime();
		},
		type: 'numeric'
	});
	
	$('#veranstaltungen-ergebnis:not(.details)').tablesorter({ 
		// define a custom text extraction function 
		textExtraction: 'complex',    
		widgets: ['sortPersist'],
		headers: { 1: { sorter: 'germandate' }},
		sortList: [[1,0]]
    });
	$('#veranstaltungen-bearbeiten').tablesorter({ 
		headers: { 0: { sorter: 'germandate' }, 2: { sorter: false }}, 
		widgets: ['sortPersist'],
		sortList: [[0,1]]
    });
	
	var sorTable = $('#veranstaltungen-ergebnis:not(.details) thead th, #veranstaltungen-bearbeiten thead th');
	var thText = sorTable.each(function(){ $(this).text(); });
	//sorTable.attr('title', 'Sortieren nach ' + thText);
	sorTable.attr('title', 'Sortieren');*/
	
	/*var sorTable = $('#veranstaltungen-ergebnis, #veranstaltungen-bearbeiten');
	var sorTableHeader = sorTable.find('thead th');
	var sorTableHeaderText = sorTable.each(function(){ sorTableHeader.text(); });
	sorTableHeader.attr('title', 'Sortieren nach ' + sorTableHeaderText);*/
	
	$('#veranstaltungen-bearbeiten:has(tbody:empty)').hide();

	
		
	/*** In ISSET-Markern bei HTML-Ausgabe (Response-Seite) generierte BRs bei Code-Umbrüchen entfernen (-> Extension-Bug!) ***/
	$('div.form ').find('br').remove();
	
	
	if(($.browser.msie && $.browser.version <= 7)){
		$('#form-veranstaltungseintrag input[type=file]').attr('size', '38');
		$('#form-reisenet input[type=file]').attr('size', '30').css('width', 'auto');
	};
	
	$('textarea').autogrow();
	
	/*$('#form-kt-suche.standardsuche input[type=image]').hide();
	$('#form-kt-suche.standardsuche select option:selected').parents('form').find('input[type=image]').show();*/
		
});


/*** Konfigurationen für Highslide JS ***/
hs.graphicsDir = '/_img/highslide/';
hs.showCredits = false;
hs.outlineType = 'custom';
hs.padToMinWidth = true;
hs.dimmingOpacity = 0.1;
//hs.useBox = true;
//hs.width = 640;
//hs.height = 480;
hs.blockRightClick = false;
hs.numberOfImagesToPreload = 10;
hs.captionEval = 'this.thumb.title';
hs.registerOverlay({
	html: '<div class="close-simple-white" onclick="return hs.close(this)" title="Schließen (Esc)"></div>',
	position: 'top right',
	useOnHtml: true,
	fade: 2 // fading the semi-transparent overlay looks bad in IE
});


// Add the slideshow controller
hs.addSlideshow({
	slideshowGroup: 'group1',
	interval: 5000,
	repeat: false,
	useControls: true,
	fixedControls: 'fit',
	overlayOptions: {
		opacity: '0.75',
		position: 'bottom center',
		offsetX: '0',
		offsetY: '-5',
		hideOnMouseOut: true
	}
});

// German language strings
hs.lang = {
	cssDirection: 'ltr',
	loadingText: 'Laden...',
	loadingTitle: 'Zum Abbrechen klicken',
	focusTitle: 'Klicken, um nach vorne zu bringen',
	fullExpandTitle: 'Auf Originalgröße erweitern',
	creditsText: 'Powered by <i>Highslide JS</i>',
	creditsTitle: 'Homepage von Highslide JS besuchen',
	previousText: 'Voriges',
	nextText: 'Nächstes',
	moveText: 'Verschieben',
	closeText: 'Schließen',
	closeTitle: 'Schließen (Esc)',
	resizeTitle: 'Größe wiederherstellen',
	playText: 'Abspielen',
	playTitle: 'Slideshow abspielen (Leertaste)',
	pauseText: 'Pause',
	pauseTitle: 'Slideshow anhalten (Leertaste)',
	previousTitle: 'Voriges (Pfeiltaste links)',
	nextTitle: 'Nächstes (Pfeiltaste rechts)',
	moveTitle: 'Verschieben',
	fullExpandText: 'Vollbild',
	number: 'Bild %1 von %2',
	restoreTitle: 'Zum Schließen klicken, klicken & ziehen zum Verschieben. Pfeiltasten für Vor und Zurück.'
};

/* Fotogalerien */
var config1 = {
	slideshowGroup: 'group1',
	numberPosition: 'caption',
	captionEval: 'this.a.title',
	transitions: ['expand', 'crossfade']
};

/* Minimap-Anzeigen Key Techs */
var config2 = {
	/*slideshowGroup: 0,
	next: 0,
	previous: 0,*/
	/*numberPosition: 'caption',*/
	useControls: false,
	//captionEval: 'this.a.rel',
	headingEval: 'this.a.title',
	transitions: ['expand', 'crossfade'],
	objectType: 'iframe',
	width: 550, 
	height: 400,
	//maxWidth: 700, 
	//maxHeight: 600,
	/*headingText: 'Title from onclick', */
	dimmingOpacity: 0,
	objectLoadTime : 'after',
	preserveContent: true,
	wrapperClassName: 'minimap'
};

/* Bildvergrößerung für News etc. */
var configNews = {
	slideshowGroup: 'group1',
	numberPosition: 'caption',
	captionEval: 'this.thumb.alt',
	transitions: ['expand', 'crossfade'],
	repeat: false
};
