/* ********************************************************** 
 * File type: 		JavaScript Front End					*
 * Coded by:		Yann Lorber								*
 * 					Freelance Web Developer 				*
 *					http://www.yannlorber.fr				*
 * Date:			June 2009								*
 * ******************************************************* */
$(function() {		

	// TARGET BLANK Replacement
	if( $("a.ext").length )
	{
		$("a.ext").click(function(){
			window.open(this.href); // pop a new window
			return false; // return false to keep the actual link click from actuating				
		});		
	}


	// MAIN MENU 
	if( $('.sf-menu').length )
	{
		$('.sf-menu').superfish({ 
            delay:       0,                            // one second delay on mouseout 
            animation:   {opacity:'toggle'},  // fade-in and slide-down animation 
        });					
	}


	// IMAGE ROLLOVER PREVIEW
	if ($(".preview").length)
	{  	 
		var offsetX = 15;
		var offsetY = 100;
		
		$('.preview').hover(function(e) {
			var href = $(this).attr('rel');

			$("body").append('<p id="bigger"><img width="56" src="'+href+'" /></p>');
			$("#bigger")				
				.css('top', e.pageY - offsetY)
				.css('left', e.pageX + offsetX)
				.show();

		}, function() {
			$('#bigger').remove();
		});

		$('.preview').mousemove(function(e) {
			$("#bigger").css('top', e.pageY - offsetY).css('left', e.pageX + offsetX);
		});
	}


	// SIDE NEWS LINKS
	if($("#side-newslist").length) {
	
		$("#side-newslist li").click( function(){
		
			var link = $(this).children(".left").children("a").attr("href");						
			
			if (!link) {
				window.location = window.location;					
			}else{
				window.location = link;								
			}
		});
	}
	
	
	// IE 6 FIX
	if ( $.browser.msie ) {
		if ( $.browser.version == "6.0") {
			$("#side-newslist li").hover(
		      function () {
		        $(this).children(".left").children("a").children("img").css("opacity","1");
		        $(this).children(".left").children(".date").css("color","#004499");
        		$(this).children(".right").children("h5").css("color","#004499");
		        $(this).children(".right").children(".intro").css("color","#004499");                
		      }, 
		      function () {
		        $(this).children(".left").children("a").children("img").css("opacity","0.45");
		        $(this).children(".left").children(".date").css("color","#999");
        		$(this).children(".right").children("h5").css("color","#666");
		        $(this).children(".right").children(".intro").css("color","#999");                
      		});
      	}
     }
});	