// JavaScript Document
// CSS conditionnels navigateurs spéciaux
if(navigator.userAgent.indexOf("Safari")!=-1)document.write('<link href="css/hacks-safari.css" rel="stylesheet" type="text/css" />');
if(navigator.userAgent.indexOf("Chrome")!=-1)document.write('<link href="css/hacks-chrome.css" rel="stylesheet" type="text/css" />');
if(navigator.userAgent.indexOf("Opera")!=-1)document.write('<link href="css/hacks-opera.css" rel="stylesheet" type="text/css" />');


// Menu de reroutage pour les combos de filtres
function jumpMenu(targ,selObj,restore){
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// Test des emails
function checkEmail(email) {
	var regexp = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-z]{2,4}$/;
	if (regexp.exec(email) == null) return false;
	else return true;
}

/* 
éviter les bugs liés au console.log de firebug
usage : if(isdefined('console')) { console.log(); }
*/
function isdefined( variable)
{
    return (typeof(window[variable]) == "undefined")?  false: true;
}

// gestion des fonts en js cufon

Cufon.replace('.titre', { fontFamily: 'Gill', hover: true});
Cufon.replace('.mtitre', { fontFamily: 'Apolline', hover: true});
Cufon.replace('.mlien', { fontFamily: 'Apolline', hover: true});
Cufon.replace('.titre-page', { fontFamily: 'Gill', hover: true});
Cufon.replace('.sitemap-lvl-1 h3', { fontFamily: 'Gill', hover: true});
Cufon.replace('.sitemap-title', { fontFamily: 'Apolline', hover: true});


 
jQuery(document).ready(function() {
	// gestion du menu accordeon
	var panes = $("#top-menu div.pane");
	panes.each(function (i) {
		if (panes.height() > 198 ) {
			$("#top-menu div#pane-"+i).css({ 'height' : 198 });
        }
    });		
	$("#top-menu").tabs("#top-menu div.pane", {tabs: 'h2.mtitre', effect: 'slide', initialIndex: null});
	// gestion des overlays
	if( jQuery("a.overlay-link").get(0) ) {
		$("a.overlay-link").overlay({
	    	target: '#gallery',
			expose: { 
				color: '#000',
				loadSpeed: 200, 
				opacity: 0.8 
			}
		}).gallery();
	}
});


/* SAME HEIGHT ON BLOCKS (ALL BROWSERS) */
mySameHeight = function(elt) {
	var heightBlockMax=0;
	$(elt).each(function(){ if( $(this).height() > heightBlockMax ) heightBlockMax = $(this).height(); }); // get max height
	if (jQuery.browser.msie) {
		$(elt).each(function(){ $(this).css("height",heightBlockMax); }); // assign max height
	} else {
		$(elt).each(function(){ $(this).css("min-height",heightBlockMax); }); // assign max height
	}
	heightBlockMax=0;
}

