jQuery.noConflict();
jQuery(function($){
	
	if( !$('body').hasClass('en') ){
		
		$.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']);
		
	}
	
	/* INPUT_LABELS: */
		$.each($('#meta_search .txtInput, form.short input'), function(){
			$(this).attr('alt', $(this).val())
			.focus(function(){
				if( $(this).val()==$(this).attr('alt') ){
					$(this).val('');
				}
			})
			.blur(function(){
				if( $(this).val()=='' ){
					$(this).val( $(this).attr('alt') );
				}
			});
		});
	/* :INPUT_LABELS */
	
	/* GALLERIES: */
		$("div.svw").slideView();
		if( jQuery('.svw_wrapper').length>0 ){
			var svwInterval = setInterval(function(){
				var $current = jQuery('.svw_wrapper .stripTransmitter a.current');
				var $last = jQuery('.svw_wrapper .stripTransmitter a:last');
				if( $current.html()==$last.html() ){
					jQuery('.svw_wrapper .stripTransmitter a:first').click();
				}else{
					$current.parent().next().find('a').click();
				}
			}, 4000);
			jQuery('.svw_wrapper .stripTransmitter a').mouseover(function(){
				clearInterval(svwInterval);
			});
		}
		
		$("div.svwp").slideViewerPro({
			galBorderWidth: 0,
			thumbsBorderWidth: 0,
			thumbsPercentReduction: 8,
			leftButtonInner: "<img src='/fileadmin/templates/images/panorama_arrow_l.gif' style='margin-top:20px;' />",
			rightButtonInner: "<img src='/fileadmin/templates/images/panorama_arrow_r.gif' style='margin-top:20px;' />",
			autoslide: true
		}); 
	/* :GALLERIES */
	
	/* FULL_CLICK: *
		$('.teaser_box3 > div, .teaser').click(function(){
			if( $(this).find('a').length>0 ){
				window.open($(this).find('a').attr('href'), '_self');
			}
		}).css({cursor:'pointer'});
	*/
		$('.teaser_box3 > div, .teaser').click(function(){
			if( $(this).find('a').length>0 ){
				var target = $(this).find('a').attr('target');
				if( typeof(target)=='undefined' || target=='' ){ target = '_self'; }
				var link = $(this).find('a:first').attr('href');
				if( link=='' && $(this).find('a:eq(1)').length>0 ){
					link = $(this).find('a:eq(1)').attr('href');
				}
				if( link.substr(0,1)!='/' && link.substr(0,7)!='http://' && link.substr(0,11)!='javascript:' ){
					link = '/'+link;
				}
				if( link!='' ){
					window.open(link, target);
				}
			}
			return false;
		});
		$.each($('.teaser_box3 > div, .teaser'), function(){
			if( $(this).find('a').length>0 ){
				$(this).css({cursor:'pointer'});
			}
		});
	/* :FULL_CLICK: */
	
	/* EVENTS: */
		
		jQuery('.tx-rlmpeventdb-pi1-listrow-item-content').hide();
		jQuery('.tx-rlmpeventdb-pi1-listrow-item-eventshortname a').click(function(){
			//jQuery(this).toggleClass('active').parent().next().next().toggle();
			jQuery(this).toggleClass('active').parent().parent().find('.tx-rlmpeventdb-pi1-listrow-item-content').toggle();
			return false;
		});
		
	/* :EVENTS */
	
	/* COMBOBOX: */
		
		if( jQuery.browser.mozilla && ( parseFloat(jQuery.browser.version.substr(0,3))<1.9 || parseFloat(jQuery.browser.version.substr(0,3))>=1.9 && parseFloat(jQuery.browser.version.substr(4,3))<=1.5 ) ){
			// 1.9.1.5 = Firefox/3.5.5
			// 1.9.2.3 = Firefox/3.6.3
			// do something special for ff3.5.5 and older..
		}else if( jQuery.browser.ie && parseFloat(jQuery.browser.version) <= 7.0 ){
			// do something special for ie7 and older..
		}else{
			$('form.short select').combobox();
		}
		
	/* :COMBOBOX */
	
	/* LIGHTBOX_LINKS: */
		jQuery.each(jQuery('.jqOverlay'), function(){
			var $this = jQuery(this);
			var $content = $this.next();
			$content.addClass('overlay').appendTo('body');
			$this.overlay({
				expose: '#000',
				effect: 'default',
				target: $content
			});
		});
		
		$('body').append('<div id="lightbox_flash_content"><div id="lightbox_flash_replace"></div></div>');
		jQuery.each(jQuery('.jqOverlaySwf'), function(){
			var $this = jQuery(this);
			var flash = $this.attr('href');
			$this.overlay({
				expose: '#000',
				effect: 'default',
				target: jQuery('#lightbox_flash_content'),
				onBeforeLoad: function(){
					//jQuery('#lightbox_flash_content').html('here should load your flash file: ' + flash );
					swfobject.embedSWF('/' + flash, "lightbox_flash_replace", "700", "350", "9.0.0", "/fileadmin/templates/swf/expressInstall.swf");
				}
			});
		});
	/* :LIGHTBOX_LINKS */
	
	
	/* EVENT-MOVIE LINKS: */
		
		$('body').append('<div id="event_movie_content"><div id="event_movie_flash"><a href="#" id="event_movie_player"></a></div></div>');
		jQuery.each(jQuery('.jqOverlayFlv'), function(){
			var $this = jQuery(this);
			var flash = $this.attr('href');
			$this.overlay({
				expose: '#000',
				effect: 'default',
				target: jQuery('#event_movie_content'),
				onBeforeLoad: function(){
					$('#event_movie_flash').html('<a href="'+flash+'" id="event_movie_player" style="display:block;width:675px;height:380px"></a>');
					flowplayer("event_movie_player", "/fileadmin/templates/swf/flowplayer-3.2.2.swf");
				}
			});
		});
		
	/* :EVENT-MOVIE LINKS */
	
	
	/* TEASERBOX ARROW: */
	
		var teaser_box3_a_image = 'http://www.utokulm.ch/fileadmin/templates/images/teaser_arrow.gif';
		if( document.location.href.indexOf('kreaktiv-events.ch')>0 ){
			teaser_box3_a_image = 'http://www.utokulm.ch/fileadmin/templates/images/kreaktiv/teaser_arrow.gif';
		}
		if( document.location.href.indexOf('wohnungen-disentis.ch')>0 ){
			teaser_box3_a_image = 'http://www.utokulm.ch/fileadmin/templates/images/disentis/teaser_arrow.gif';
		}
		$('.teaser_box3 a').append('<img src="' + teaser_box3_a_image + '" style="float:none; margin:0 0 -2px 5px;" />');
	
	/* :TEASERBOX ARROW */
	
	
	/* WEBCAM KLICK: */
		$('.webcam_footer a').click(function(){
			$('.webcam_content').hide();
			$('.webcam_footer a').removeClass('active');
			$('.webcam_content:eq('+ $(this).attr('href').substr(1) +')').show();
			$(this).addClass('active');
			return false;
		});
		
		$('.webcam_footer a:eq(3)').click();
	/* :WEBCAM KLICK */
	
	/* EMPTY EVENT FIX: */
		
		if( jQuery('.tx-rlmpeventdb-pi1').length>0 ){
			var current_url = document.location.href;
			if( current_url.indexOf('tx_rlmpeventdb_pi1[swordfrom]')<0 && jQuery('.tx-rlmpeventdb-pi1-listrow .tx-rlmpeventdb-pi1-listrow-item, .tx-rlmpeventdb-pi1-listrow .tx-rlmpeventdb-pi1-listrow-item-odd').length<=0 ){
				var url = jQuery('.tx-rlmpeventdb-pi1-listrow-months li.active').next().find('a').attr('href');
				document.location.href = 'http://www.utokulm.ch/' + url;
			}
		}
		
	/* :EMPTY EVENT FIX */
	
});