/**
 * www.museums.ch
 * Custom JS based on jquery
 *
 * @since 2011-06-07
 * @copyright internauta, zurich
 *
 * NOTES:

 */
 
 $(document).ready(function() {
 
 	
	 	
	 /* suchbox: ohne js ist sie per default eingeblendet (accessiblity) , wird per js ausgeblendet*/
	 	$('#suchbox').hide();
	 	$('#volltextsuche').removeClass('active');
	
	 	$("#volltextsuche").mouseover(
					function(e){
						
						$('#suchbox').show();
						$(e.target).addClass('active');
					}
				);
		/*$("#suchbox").mouseleave(
					function(e){
						
						$('#suchbox').hide();
						$('#volltextsuche').removeClass('active');
					}
				);*/
	 	
	 	/* print */
	 	$("#print, .print").mouseover(
	 		function(){
	 			$(this).css({'cursor':'pointer'});
	 		}
	 	);
		$("#print, .print").click(
					function(e){
						
						window.print();
					}
					
				);
				
		/* IE aelter als V 9, last-child selector mit class='lastchild' nachdoppeln*/
		if ($.browser.msie) {
			if(parseInt($.browser.version)<9 ){
 			
				 
					$("#service li:last-child, #main li:last-child, #sub li:last-child, .museumssuche_infoleiste li:last-child, .breadcrumb li:last-child, .infoleiste li:last-child").addClass("lastchild");
					$("hr").replaceWith("<div class='strich'>&nbsp;</div>");
				
 			}
 				/* tooltip ie ausblenden */
	
        		jQuery('img').removeAttr('alt').attr("title", "");
       
       		/* z-index bug in ie7: jede naechst tiefere box wird um einen z-index tiefer gesetzt, damit tooltip ueberlappen koennen*/
       		if(parseInt($.browser.version)<8 ){
       		
       				var zindex=100;
       				$('.formcol2 .fix').each(function(index) {
       						zindex=zindex-1;
       						 $(this).css('z-index', zindex);
       					
       				});
       				
       				zindex=100;
       				$('.kriterien_icons .fix').each(function(index) {
       						zindex=zindex-1;
       						 $(this).css('z-index', zindex);
       					
       				});
       		
       		}
	
		}	
		
	/* Buendelung von Unterseiten: Artikel mit der Class .showlink_0 sollen keinen Link ins Detail anzeigen*/
	$('.showlink_0>.hoverimg a, .showlink_0 a.more, .showlink_0> .infoblock h2 a').attr ('href', '#');
	$('.showlink_0>.hoverimg a, .showlink_0 a.more, .showlink_0> .infoblock h2 a').css('cursor','default');
	$(".showlink_0>.hoverimg a, .showlink_0 a.more, .showlink_0> .infoblock h2 a").click(function() { return false; });	
		
	
	/* alias in ArticleList : snippet zum alias erstellen kann nicht 2mal aufgerufen werden -> Bug? für statistik, setzte id aufruf gleich alias */
	$('.showlink_1').each(function(index) {
		$(this).find('a.more').attr('href', $(this).find('h2 a').attr('href')); 
	});
	
	/* alias in StellenList : snippet If  kann nicht 2mal aufgerufen werden -> Bug? für statistik, setzte id aufruf gleich alias */
	$('.stellenList').each(function(index) {
		$(this).find('a.more').attr('href', $(this).find('h2 a').attr('href')); 
	});
		
	
		
	 $(".showlink_1 .hoverimg img, #banner").hover(
	  	function() {
		 $(this).fadeTo( 100, 0.8);
		
		
	  	},
	  	 function(){
		 $(this).fadeTo( 100, 1);
		 
	  });
	  
	  
	 	
	 	
	 	/* TOOLTIP */
	 	
	 	$(".information, .icon").mouseover(
					function(e){
						
						$(e.target).siblings(".tooltip").fadeIn(500);
						$(e.target).parent().siblings(".tooltip").fadeIn(500);
						
					}
				);
		$(".information, .icon").mouseleave(
					function(e){
					
						
							$(e.target).siblings(".tooltip").fadeOut(500);
							$(e.target).parent().siblings(".tooltip").fadeOut(500);
						
					}
		);
		
		
		$(".icon").hover(
			 function()
			 {
			 	
			  this.src = this.src.replace(".gif","-over.gif");
			  this.src = this.src.replace(".png","-over.png");
			 },
			 function()
			 {
			  this.src = this.src.replace("-over.gif",".gif");
			  this.src = this.src.replace("-over.png",".png");
			 }
		);
		/* end TOOLTIP */
		
		
		
		/* --museen --*/
		
		$(".titelspalte1, .titelspalte2, .titelspalte3").hover(
		
		
			function(){
				$(this).css('color','rgb(68,200,245)');
			
			},
			function(){
				$(this).css('color','black');
			
			}
		);
		
		
		/* --sicherstellen, dass .pdf in neuem fenster heruntergeladen werden */
		var href;
		$(".maincol a").each(function(index) {
				href=$(this).attr('href');
       						if(href.lastIndexOf(".pdf")!=-1){
       								$(this).attr('target', '_blank');
       						
       						}
       						
       					
       	});
});
	

		
