// jQuery Ajax
function load_content (url) {

	$("#content").empty();
    $('#loading').show();
    
    $.ajax({
        success: function (html) { 
            //hide the progress bar
            $('#loading').hide();  
            $("#content").load(url).hide('normal').fadeIn(750);   
        }      
    });
    
}

// jQuery lightbox selector & parameters
$(function() {
	$('a.gallery').lightBox({
	overlayBgColor: '#000',
	overlayOpacity: 0.75,
	imageLoading: '/js/jquery-lightbox/images/lightbox-ico-loading.gif',
	imageBtnClose: '/js/jquery-lightbox/images/lightbox-btn-close.gif',
	imageBtnPrev: '/js/jquery-lightbox/images/lightbox-btn-prev.gif',
	imageBtnNext: '/js/jquery-lightbox/images/lightbox-btn-next.gif',
	containerResizeSpeed: 750,
	txtImage: 'Photo',
	txtOf: 'de'});
});

// superfish menu selector
$(function(){
	$('ul.sf-menu').superfish({ 
            delay:       500,
            animation:   {opacity:'show',height:'show'},
            speed:       'slow',
            autoArrows:  false,
            dropShadows: false
        }).click(function(){
                $(this).find("ul").hide();
        }); ;
});

// iphone / ipod redirection
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
   if (document.cookie.indexOf("iphone_redirect=false") == -1) 
   		window.location = "http://www.francouvertes.com/mobile";
}

$(document).ready(function() {
		
	// Preload all rollovers
	$("#menu img").each(function() {
		// Set the original src
		rollsrc = $(this).attr("src");
		rollON = rollsrc.replace(/.gif$/ig,"-over.gif");
		$("<img>").attr("src", rollON);
	});
		
	// Navigation rollovers
	$("#menu a").mouseover(function(){
		imgsrc = $(this).children("img").attr("src");
		matches = imgsrc.match(/-over/);
			
		// don't do the rollover if state is already ON
		if (!matches) {
			imgsrcON = imgsrc.replace(/.gif$/ig,"-over.gif"); // strip off extension
			$(this).children("img").attr("src", imgsrcON);
		}
			
	});
	
	$("#menu a").mouseout(function(){
		$(this).children("img").attr("src", imgsrc);
	});
	
});

