/* this javascript needs jquery */
  
 function create_icon(icon)
 {
    return '<img src="layout/ensser/img/'+icon+'.gif" class="link-icon" />';
 }
 

 $(document).ready(function(){
							
    /* Helper for mm_forum templates */
	$('.tx-mmforum-pi1-markread').next('<br />').remove();
	
    $("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']").not("[class='img']").append(create_icon('pdf'));
	$("a[href$='.rtf']").not("[class='img']").append(create_icon('doc'));
	$("a[href$='.doc']").not("[class='img']").append(create_icon('doc'));
	// in section TRAEGER and PRESSE do not display link icons 
	
		// if ther follows a , or a . or a ) the link, img will get class link-icon2
    // IE has it's own html() 
	$("p a img.link-icon").parents('p').each(function(){
		// alert($(this).html());
        var expr = /link-icon([^>]*)><\/a>([,\.\)]{1})/gi;
		var repl = 'link-icon2$1></a>$2';
		$(this).html($(this).html().replace(expr,repl));	
	});	
	
	/* 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');
	
	if(!$('.tx-mmforum-pi1').length){
		$("#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));	
	});	

	
		//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...]");
		}
	});
	
});