/* Bewirkt verschwinden des Textes SUCHE in Suchbox on click  fuer IE und Firefox */

function activatePlaceholders() {
var detect = navigator.userAgent.toLowerCase(); 
if (detect.indexOf("safari") > 0) return false;
var inputs = document.getElementsByTagName("input");
for (var i=0;i<inputs.length;i++) {
  if (inputs[i].getAttribute("type") == "text") {
   if (inputs[i].getAttribute("placeholder") && inputs[i].getAttribute("placeholder").length > 0) {
    inputs[i].value = inputs[i].getAttribute("placeholder");
    inputs[i].onclick = function() {
     if (this.value == this.getAttribute("placeholder")) {
      this.value = "";
     }
     return false;
    }
    inputs[i].onblur = function() {
     if (this.value.length < 1) {
      this.value = this.getAttribute("placeholder");
     }
    }
   }
  }
}
}
window.onload=function() {
activatePlaceholders();
}
/* Quicknews */
/*
$(function() {
	if ($('.wirtschaft_quick_news_single h4').length) {	
		$('body').append('<div id="tooltip" style="display:none"></div>');
		$('.wirtschaft_quick_news_single h4 a').removeAttr('title').removeAttr('href');
		$('.wirtschaft_quick_news_single h4').tooltip({
			events: {def: 'mouseenter, click'},
			position:'bottom center',
			tip:'#tooltip',
			fadeOutSpeed:500,
			predelay: 100,
			effect:'fade',
			onBeforeShow: function() {
				var proxy = this;
				$(document).one('click', function() { proxy.hide(); });
				$('#tooltip').html(this.getTrigger().next().html());
			}
		});
	}
	if ($('div#block_aktuelle_meldungen div.inner_wrap_all_boxes').length) {	
		$('body').append('<div id="tooltip_homepage" style="display:none"></div>');
		$('div#block_aktuelle_meldungen div.inner_wrap_all_boxes a').removeAttr('title').removeAttr('href');
		$('div#block_aktuelle_meldungen div.inner_wrap_all_boxes').tooltip({
			events: {def: 'mouseenter, click'},
			position:'bottom center',
			tip:'#tooltip_homepage',
			fadeOutSpeed:500,
			predelay: 100,
			effect:'fade',
			onBeforeShow: function() {
				var proxy = this;
				$(document).one('click', function() { proxy.hide(); });
				$('#tooltip_homepage').html(this.getTrigger().next().html());
			}
		});
	}	
});*/
/* end */

/* */
$(function() {
	var curCat = $('div#folgeseiten_block_geoanzeiger > div:first').next();
	curCat.find('div.inner_wrap_headlines_grau_weiss_geoanzeiger p.bodytext a').each(function(idx, el) {
		curCat = curCat.next();
		curCat.next().find('p.bodytext').append($(el).clone());
	});
	$('div#folgeseiten_block_geoanzeiger > div:first').next().next().find('p.bodytext').css({'font-size':'0.8em','font-weight':'bold'}).append("Artverwandte Artikel:");
});
/* end */

/* Zenith Termine Calendar */
$(function(){if($("#zenithcal").length){$("#datepicker").after('<div id="zenithcallist" class="ui-widget ui-widget-content ui-helper-clearfix"></div>');var a=$("#zenithcallist").jScrollPane({showArrows:false,maintainPosition:false}).data("jsp");var c=new Array();$.ajax({type:"GET",url:"/fileadmin/termine/ZenithTermine.ics",dataType:"text",async:true,success:function(e){var d=$.icalendar.parse(e);$(d.vevent).each(function(f,i){var h=i.summary?i.summary.replace(/\\/gm,""):"";var g=i.location?i.location.replace(/\\/gm,""):"";c.push(new b(h,g,i.url?i.url._value:"",new Date(i.dtstart._value),new Date(i.dtend._value)))});c.sort(function(h,i){if(h.start<i.start){return -1}if(h.start>i.start){return 1}return 0});$.datepicker.setDefaults($.datepicker.regional.de);$("#datepicker").datepicker({inline:true,minDate:"-1m",maxDate:"+1y",onChangeMonthYear:function(g,i,h){$("#zenithcallist").css("height",($("#zenithcal").height()-$("#datepicker").height()-2)+"px");a.getContentPane().empty().append("<ul></ul>");var f=new Date(g,i-1,1);$(c).each(function(j,k){if(k.inMonth(f)){a.getContentPane().find("ul").append('<li><a href="'+k.url+'" class="ui-state-default" target="_blank">'+k.print()+"&nbsp;&nbsp;&nbsp;"+k.ort+"</a><br />"+k.title+"</li>")}});a.reinitialise()},beforeShowDay:function(g){var f=false;var h="nodatefix";var i=new Array();$(c).each(function(j,k){if(k.inDay(g)){f=true;h="";i.push(k.title)}});return[f,h,i.join(" || ")]}});$("#datepicker a.ui-datepicker-prev").trigger("click");$("#datepicker a.ui-datepicker-next").trigger("click")}})}function b(g,f,e,h,d){this.title=g;this.ort=f;this.url=e;this.start=h;this.end=d;this.inMonth=function(i){return i.getFullYear()==this.start.getFullYear()&&(i.getMonth()==this.start.getMonth()||i.getMonth()==this.end.getMonth())};this.inDay=function(i){return(i.getFullYear()==this.start.getFullYear()&&(i.getMonth()==this.start.getMonth()||i.getMonth()==this.end.getMonth()))&&i.getDate()>=this.start.getDate()&&i.getDate()<=this.end.getDate()};this.print=function(){return this.end.getDate()!=this.start.getDate()?this.printDate(this.start)+" - "+this.printDate(this.end):this.printDate(this.start)+" "+this.printTime(this.start)+"-"+this.printTime(this.end)};this.pad=function(i){return i<10?"0"+i:i};this.printDate=function(i){return this.pad(i.getDate())+"."+this.pad(i.getMonth()+1)};this.printTime=function(i){return this.pad(i.getHours())+":"+this.pad(i.getMinutes())}}});
/* end */

/* Top Link Carousel */
(function(b){var a={};b.fn.Slides=function(d){var c={};b.fn.Slides.setup(c,b.fn.Slides.defaults,d);var e=this;b.fn.Slides.init(this,function(){return e.each(function(){b(e).Slides.start()})})};b.fn.Slides.defaults={wait:0,pause:3000,fade:1000};b.fn.Slides.setup=function(c,e,d){a=b.extend({},c||{},e||{},d||{})};b.fn.Slides.init=function(d,f){a.main=b(d);a.pipes=new Object();a.pipes.urls=new Array();a.pipes.functions=new Array();var e=false;var c=function(){e=true;a.toggle=a.main.wrap("<span></span>").parent().css({display:"block",overflow:"hidden",height:a.main.height()+"px",width:a.main.width()+"px"});b.fn.Slides.preloadNextImage()};a.main.load(function(){if(e){return}c();f.call()});if(a.main[0].complete&&!e){c();f.call()}};b.fn.Slides.preloadNextImage=function(){var c=b.fn.Slides.getNextImage();var d=new Image();d.src=c;a.nextImage=d};b.fn.Slides.getNextImage=function(){var d=a.images.shift();a.images.push(d);if(a.urls){var c=a.urls.shift();a.urls.push(c);a.pipes.urls.push(c)}if(a.functions){var e=a.functions.shift();a.functions.push(e);a.pipes.functions.push(e)}return d};b.fn.Slides.start=function(){setTimeout(b.fn.Slides.execute,a.wait)};b.fn.Slides.execute=function(){var c=false;setInterval(function(){if(c){a.main.attr("src",a.nextImage.src).animate({opacity:1},a.fade);c=false}else{a.toggle.css({background:"transparent url("+a.nextImage.src+") left top no-repeat"});a.main.animate({opacity:0},a.fade);c=true}if(a.pipes.urls.length>0){a.main.click(function(){window.location.href=a.pipes.urls.shift()})}if(a.pipes.functions.length>0){a.pipes.functions.shift()()}b.fn.Slides.preloadNextImage()},a.pause)}})(jQuery);
$(function(){
	function nextTeaser(i) {
		$('div.background_topstories_label').each(function(e) {
			$(this).removeClass('active');
		});
		$('div.background_topstories_label').eq(i).addClass('active');
		if ($('#sliderimgcaption' + (i + 1)).length > 0) {
			var sp = $('#sliderimgcaption' + (i + 1)).text().split('|', 2);
			var gCap = $('#sliderimgdisplay dd.csc-textpic-caption');
			if (sp.length > 1) {
				gCap.html('<span class="caption-h1">' + sp[0] + '</span> ' + sp[1] + '');
				//gCap.switchClass('img-caption-20', 'img-caption-40', 300);
			} else {
				gCap.text(sp[0]);
			}
		}
	}
	/*function nextT(i) {
		$('div.background_topstories_label').each(function(e) {
			$(this).removeClass('active');
		});
		$('div.background_topstories_label').eq(i).addClass('active');
	}
	if ($('#c727').length) {
		$('#c727 img').Slides({
			images: ['/fileadmin/img/content/frontpage/slider_top/frontpage_image_top_politi_seerecht.jpg', '/fileadmin/img/content/frontpage/slider_top/frontpage_image_top_gesell_expkk.jpg', '/fileadmin/img/content/frontpage/slider_top/frontpage_image_top_wirtsc_gosaibi.jpg', '/fileadmin/img/content/frontpage/slider_top/frontpage_image_top_kultur_steinigung.jpg'],
			urls: ['/deutsch/politik//artikel/das-recht-fragt-nicht-nach-motiven-002006/', '/deutsch/gesellschaft//artikel/zwischenstation-irak-001990/', '/deutsch/wirtschaft//artikel/dead-man-walking-001995/', '/deutsch/kultur/kunst//artikel/die-steinigung-an-der-wohnzimmerwand-001993/'],
			functions: [function(){nextT(0);}, function(){nextT(1);}, function(){nextT(2);}, function(){nextT(3);}]
		});
		nextT(0);
		$('div.background_topstories_label').eq(0).click(function(){window.location.href='/deutsch/politik//artikel/das-recht-fragt-nicht-nach-motiven-002006/'});
		$('div.background_topstories_label').eq(1).click(function(){window.location.href='/deutsch/gesellschaft//artikel/zwischenstation-irak-001990/'});
		$('div.background_topstories_label').eq(2).click(function(){window.location.href='/deutsch/wirtschaft//artikel/dead-man-walking-001995/'});
		$('div.background_topstories_label').eq(3).click(function(){window.location.href='/deutsch/kultur/kunst//artikel/die-steinigung-an-der-wohnzimmerwand-001993/'});
	}*/
	if ($('#frontpage_accordion_topstories #sliderimgdisplay').length || $('#mediathek_accordion_topstories #sliderimgdisplay').length) {
		$('#sliderimgdisplay img').Slides({
			images: [
				$('#sliderimg1 img').length?$('#sliderimg1 img').attr('src'):'',
				$('#sliderimg2 img').length?$('#sliderimg2 img').attr('src'):'', 
				$('#sliderimg3 img').length?$('#sliderimg3 img').attr('src'):'', 
				$('#sliderimg4 img').length?$('#sliderimg4 img').attr('src'):''
			],
			urls: [
				$('#sliderurl1').length?$('#sliderurl1').text():'',
				$('#sliderurl2').length?$('#sliderurl2').text():'',
				$('#sliderurl3').length?$('#sliderurl3').text():'',
				$('#sliderurl4').length?$('#sliderurl4').text():''
			],
			functions: [function(){nextTeaser(0);}, function(){nextTeaser(1);}, function(){nextTeaser(2);}, function(){nextTeaser(3);}]
		});
		nextTeaser(0);
		$('#sliderimgdisplay img').attr('src', $('#sliderimg1 img').length?$('#sliderimg1 img').attr('src'):'');
		$('div.background_topstories_label').eq(0).click(function(){window.location.href=$('#sliderurl1').length?$('#sliderurl1').text():''});
		$('div.background_topstories_label').eq(1).click(function(){window.location.href=$('#sliderurl2').length?$('#sliderurl2').text():''});
		$('div.background_topstories_label').eq(2).click(function(){window.location.href=$('#sliderurl3').length?$('#sliderurl3').text():''});
		$('div.background_topstories_label').eq(3).click(function(){window.location.href=$('#sliderurl4').length?$('#sliderurl4').text():''});
	}
	function nextFotoTeaser(i) {
		$('div.background_topstories_label').eq(0).hide();
		$('div.background_topstories_label span.label').eq(0).text($('#sliderlabel' + (i + 1)).text());
		$('div.background_topstories_label').eq(0).effect('slide', {}, 400);
		$('div.background_topstories_label').eq(0).click(function(){window.location.href=$('#sliderur' + (i + 1)).length?$('#sliderur' + (i + 1)).text():''});
		if ($('#sliderimgcaption' + (i + 1)).length > 0) {
			var sp = $('#sliderimgcaption' + (i + 1)).text().split('|', 2);
			var gCap = $('#sliderimgdisplay dd.csc-textpic-caption');
			if (sp.length > 1) {
				gCap.html('<span class="caption-h1">' + sp[0] + '</span> ' + sp[1] + '');
				//gCap.switchClass('img-caption-20', 'img-caption-40', 300);
			} else {
				gCap.text(sp[0]);
			}
		}
	}
	if ($('#mediathek_accordion_topstories_fotopreis #sliderimgdisplay').length) {
		$('div.background_topstories_label').eq(0).hide();
		var fotopreis_imgs = new Array();
		var fotopreis_urls = new Array();
		var fotopreis_funcs = new Array();
		$('#frontpage_accordion_target img:gt(0)').sort(function(a,b){return 0.5 - Math.random()}).each(function(){
			var i = $(this).parent().attr('id').match(/(\d+)/)[0] - 1;
			fotopreis_imgs.push(this.src);
			fotopreis_urls.push($('#sliderur' + (i + 1)).text());
			fotopreis_funcs.push(function(){nextFotoTeaser(i);});
		});
		$('#sliderimgdisplay img').Slides({
			images: fotopreis_imgs,
			urls: fotopreis_urls,
			functions: fotopreis_funcs
		});
		$('div.background_topstories_label').eq(0).click(function(){window.location.href=$('#sliderur1').length?$('#sliderur1').text():''});
	}
});
/* end */
