/* this javascript needs jquery */
  
 function create_icon(icon)
 {
    var newimg=document.createElement('img');
	newimg.setAttribute('src','layout/tierzuchtfonds/img/'+icon+'.gif');
	newimg.setAttribute('class','link-icon');
	return newimg;
 }
 

 $(document).ready(function(){		
	
    $("a:has(img)").addClass("img");
	$("a[href^='javascript:linkTo_UnCryptMailto']").addClass("email");
	// link icons: because of the IE multiline problem do not use css classes
	$("a[href$='.pdf']").append(create_icon('pdf'));
	$("a[href$='.rtf']").append(create_icon('doc'));
	$("a[href$='.doc']").append(create_icon('doc'));
	// in section TRAEGER and PRESSE do not display link icons 
	
	/* No img for external links
	if($("#b1172").length == 0 && $("#b1179").length == 0) 
	{
		$("a[href^='http']").not("[class='img']").append(create_icon('link_extern'));
	}
	*/
	
	// open external links with target _blank	
	$("a[href^='http']").attr('target','_blank');
	$(".search_result a[href^=http]").attr('target','_self');
	
	$("#container a:not([href^=http])").not("[href^=#]").not("[href^='javascript:linkTo_UnCryptMailto']").not("[href$='.pdf']").not("[href$='.doc']").not("[id^='c']").not("[class='img']").prepend("»&nbsp;");
	
	
	$("p:contains('(at)')").each(function(){
		// alert($(this).html());
		var filter = /<span> \(at\) <\/span>/i;
		var at = "@";
		$(this).html($(this).html().replace(filter,at));	
	});	
	    // Infodienst headline indent
	$("#infoservice h3").each(function(){
		// alert($(this).html());
		var filter = /(\w\))/i;
		var rep = "<span>$1</span>";
		$(this).html($(this).html().replace(filter,rep));	
	});		
	$("#infoservice h5").each(function(){
		// alert($(this).html());
		var filter = /(\w\.\w)/i;
		var rep = "<span>$1</span>";
		$(this).html($(this).html().replace(filter,rep));	
	});		
	
		//zebra table
	//$("tr:nth-child(odd)").addClass("odd");
	$("tr:odd").addClass("odd");
	
	
	
	var showLink = "&nbsp;<a class=\"info\" title=\"Text vollständig anzeigen\">[mehr...]<\/a>";	
							
	$(".text2").hide(); 
	$(".text1").append(showLink);
	
	$(".text1 a").click(function(){	
		// $(this).parents("p").next("div").slideToggle("slow");
		$(this).parents("p").next("div").toggle();
		
		if($(this).text() == "[mehr...]")
		{	
			$(this).attr({title:"Text ausblenden"});
			$(this).text("[Text ausblenden]");	
		}
		else
		{	
			$(this).attr({title:"Text vollständig anzeigen"});
			$(this).text("[mehr...]");
		}
	});
	
});