$(document).ready(function(){
// no news ausblenden
if($("div#sidebarWrap p").text() == "Keine News in dieser Ansicht.") $("div#sidebarWrap p").hide();


// Downloads
$("title:contains('Downloads')").each(function(){
	$(".content-element-wrap h1:not(.noSlideDown)").css("cursor", "pointer");
	$(".content-element-wrap h1:not(.noSlideDown)").each(function(){
		$(this).siblings().wrap('<div class="downloadWrap" />');
		$(".downloadWrap").hide().css("opacity", 0.0);
	});
	$(".content-element-wrap h1:not(.noSlideDown)").click(function(){
		$(this).siblings(".downloadWrap:visible").animate({"opacity": 0.0}).slideUp("slow");
		$(this).siblings(".downloadWrap:hidden").slideDown("slow").animate({"opacity": 1.0});
		
	});
});


// Lightbox
$("a.openColorbox").colorbox();
$("a.lightbox").colorbox({close: '<img src="fileadmin/templates/gkg/images/closeButton.png" alt="schließen" />', next: 'weiter', title: '&nbsp;', previous: 'zur&uuml;ck', current: 'Bild {current} von {total}', maxWidth: '800px'});

// Alarm
$alarm = $("#alarm").text();
// Erste News ID (aktuellster Alarm)
$news_id = $(".news-id:first").text();
$news_date = $(".news-date:first").text();
$cookie = $.cookie("alarm-"+$news_id);

// DEBUG
// alert($news_id+" / "+$news_date+" / "+$cookie);

// Alarmaufruf
if($cookie != $news_date)
{
	if($alarm != "Keine News in dieser Ansicht." && $alarm != "")
	{
		$.colorbox({inline:true, href:'#alarm', close: '<img src="fileadmin/templates/gkg/images/closeButton.png" alt="schließen" />', onClosed: function(){
			$.cookie("alarm-"+$news_id, $news_date, {expires: 1, path: '/'}); // Cookie mit NewsID und Datum setzen
		}});
	}
}

// ELWIS Charts
$('img[src^="http://elwis.de/gewaesserkunde/"]').addClass("openColorbox").wrap('<div class="elwisCharts" />');
$('img[src^="http://elwis.de/gewaesserkunde/"]').click(function(){
	$src = $(this).attr("src");
	$.colorbox({href: $src, photo: true, close: 'schlie&szlig;en', rel: 'colorbox'});
});

// Tabelle Kundenlogin 
$(".tx-syngkgpreise-pi1 table tr:odd, table.contenttable tr:odd").addClass("odd");
$(".tx-syngkgpreise-pi1 table tr td:nth-child(2), table.contenttable tr td:nth-child(2), .tx-syngkgpreise-pi1 table tr td:nth-child(4), table.contenttable tr td:nth-child(4)").css("background-color", "#f8f8f8");
$(".tx-syngkgpreise-pi1 table tr.odd td:nth-child(2), table.contenttable tr.odd td:nth-child(2), .tx-syngkgpreise-pi1 table tr.odd td:nth-child(4), table.contenttable tr.odd td:nth-child(4)").css("background-color", "#ebebeb");
$(".tx-syngkgpreise-pi1 table th:nth-child(2), table.contenttable th:nth-child(2), .tx-syngkgpreise-pi1 table th:nth-child(4), table.contenttable th:nth-child(4)").css("background-color", "#e9a900");

// Mitarbeiter Hintergrund weiß
$(".content-element-wrap:has(.fce-person-element)").each(function(){
$(this).addClass("white");
});

// Startseite Hover-Effekt Schnellauswahl
$("#indexLaunch ul li").hover(function(){
$class = $(this).attr("class");
$("#indexLaunch ul li:not(."+$class+")").each(function(){
$(this).stop().animate({"opacity": 0.5});
});
}, function(){
$("#indexLaunch ul li").each(function(){
$(this).stop().animate({"opacity": 1.0});
});
});	

		$("div#teaser div.csc-textpic-imagewrap").fadeIn(1000);

		var img_sources = [];
			$( "div.fce-crossslide-element img" ).each(
			function() {
				img_sources.push({src: $(this).attr("src")});
			}
		);

		$("div.fce-crossslide-container").fadeIn("slow", function() {
			$(this).crossSlide({
				sleep: 5,
				fade: 2
			}, img_sources);
		});

		$("form#search-form").submit(function() {
			if ($("input#search-form-input").val().length > 1) {
				return true;
			}

			return false;
		});
});

function searchform_submit() {

	if (jQuery("#search-form-input").val().length > 1) {
		jQuery("#search-form").submit();
	}

}

