/* =============================================================================
                         	PRECHARGEMENT IMAGES
* ===========================================================================*/	
function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

MM_preloadImages('/images/menu_btn_left.png', '/images/menu_btn_middle.png', '/images/menu_btn_right.png');
/* =============================================================================
* ===========================================================================*/


/* =============================================================================
                                        JQUERY
* ===========================================================================*/
/*back top page*/
$(function(){
	$('#backTop').click(function() {
		if($.browser.opera){$('html').animate({ scrollTop: $('#main').offset().top }, 1200);}
		else{$('html,body').animate({ scrollTop: $('#main').offset().top }, 1200);}
	});
});


this.tooltip = function(){    

        /* position par rapport au curseur */
        xOffset = -15;
        yOffset = 20;
        
    $(".point_map").hover(function(e){
        this.t = this.title;
        this.title = ""; 
		$(this).css('z-index', '999');
        $("body").append("<p id='tooltip'>"+ this.t +"</p>");
        $("#tooltip")
            .css("top",(e.pageY - xOffset) + "px")
            .css("left",(e.pageX + yOffset) + "px")
            .fadeIn("fast");        
    },
    function(){
		$(this).css('z-index', '10');
        this.title = document.getElementById('tooltip').innerHTML;        
        $("#tooltip").remove();
    });    
    $(".point_map").mousemove(function(e){
        $("#tooltip")
            .css("top",(e.pageY - xOffset) + "px")
            .css("left",(e.pageX + yOffset) + "px");
    });            
};
$(function(){
    //tooltip();
	
	/*$('#slider').hover(function(){
			alert('toto');
		},
		function(){
	
	});*/

	$('#slider').galleryView({
		panel_width: 994,
		panel_height: 277,
		transition_speed: 1500,
		transition_interval: 5000,
		nav_theme: 'dark',
		border: '0',
		pause_on_hover: true,
		background_color: 'transparent'
	});
});

/*=========MENU==========*/
$(function(){
	$('#menu li').hover(function(){		
		var padding_a_top = parseInt($(this).find('.subMenu a').css('padding-top').replace("px", ""));
		var padding_a_bottom = parseInt($(this).find('.subMenu a').css('padding-bottom').replace("px", ""));
		var height_a = $(this).find('.subMenu a').height()+padding_a_top+padding_a_bottom;
		var _height = $(this).find('.subMenu > *').length * height_a;
		
		/*var _width = $(this).find('.menu').width();		
		$('.subMenu').css('width', _width+'px');*/
		$(this).find('.subMenu').stop().animate({height: _height+'px'}, {queue:false, duration:600});
	}, function(){
		$(this).find('.subMenu').stop().animate({height: '0px'}, {queue:false, duration:270});
	});
	
	$('.subMenu a').hover(function(){
		$(this).stop().animate({paddingLeft: '40px'}, {queue:false, duration:150});
	}, function(){
		$(this).stop().animate({paddingLeft: '20px'}, {queue:false, duration:450});
	});
});




	/*================================
				CHAMP INPUT
	=================================*/
$(function(){	
	/* style des champs input par default */	
	var styleInput_color = '#777';
	var styleInput_fsize = '10px';
	var styleInput_fstyle = 'italic';
	var styleInput_talign = 'right';
	var styleInput_marginTop = '8px';
	
	/* style des champs input :focus */	
	var styleInput_color2 = '#000';
	var styleInput_fsize2 = '12px';
	var styleInput_fstyle2 = 'normal';
	var styleInput_talign2 = 'left';
	var styleInput_marginTop2 = '6px';
	
	$('.input').each(function(){				
		if($(this).attr('value') != '')
		{
			/* valeur initial du champ input */
			//window['default_input_value'] = $(this).attr('value');
			
			/* attribution d'un nouveau style au champ input si il n'est pas vide lors du chargement de la page */
			$(this).css({
				'color': styleInput_color,
				'font-size': styleInput_fsize,
				'font-style': styleInput_fstyle,
				'text-align': styleInput_talign,
				'margin-top': styleInput_marginTop
			});
		}
	});

	$('.input_bg .input').focus(function(){
		
		/* effet bleuté sur le focus du champ*/
		if(navigator.appVersion.indexOf('MSIE') != -1){
			$(this).parent().children('.input_bg_over').stop().animate({opacity: 0.2}, {queue: false, duration: 300});
		}else{
			$(this).parent().children('.input_bg_over').stop().animate({opacity: 1}, {queue: false, duration: 300});
		}
		/* déplacement du label hors du champ input */
		$(this).parent().children('.label').css('color', '#005192');
		$(this).parent().children('.label').stop().animate({marginTop: '-16px'}, {queue: false, duration: 100});
		/* positionnement de la value du champ input */
		$(this).stop().animate({marginTop: styleInput_marginTop2, color: styleInput_color2}, {queue: false, duration: 100});
		$(this).css({'text-align': styleInput_talign2, 'font-style': styleInput_fstyle2});
		$(this).css('color', '#333');
		
	}).blur(function(){
		
		/* suppression de l'effet bleuté */
		$(this).parent().children('.input_bg_over').stop().animate({opacity: 0}, {queue: false, duration: 450});
		
		/* si la value par default n'a pas changé, on réinitialise le champ */
			$(this).css('color', '#005192');
			$(this).stop().animate({marginTop: styleInput_marginTop}, {queue: false, duration: 100});
			$(this).css('text-align', styleInput_talign);
			
			$(this).parent().children('.label').css('color', '#444');
			$(this).parent().children('.label').stop().animate({marginTop: '6px'}, {queue: false, duration: 200});			
		
		/* repositionnement du label uniquement si le champ est vide */
		if($(this).attr('value') == '')
		{
			$(this).parent().children('.label').css('color', '#444');
			$(this).parent().children('.label').stop().animate({marginTop: '6px'}, {queue: false, duration: 200});	
			$(this).css({
				'color': styleInput_color2,
				'font-size': styleInput_fsize2,
				'font-style': styleInput_fstyle2,
				'text-align': styleInput_talign2,
				'margin-top': styleInput_marginTop2
			});
		}
		
	});
	
	/*================================
				TEXTAREA
	=================================*/
	$('.textarea').each(function(){				
		if($(this).html() != '')
		{
			$(this).css({
				'color': styleInput_color,
				'font-size': styleInput_fsize,
				'font-style': styleInput_fstyle
			});
		}
	});	
	
	$('.textarea_bg .textarea').focus(function(){
		
		/* effet bleuté sur le focus du champ*/
		if(navigator.appVersion.indexOf('MSIE') != -1){
			$(this).parent().children('.textarea_bg_over').stop().animate({opacity: 0.2}, {queue: false, duration: 300});
		}else{
			$(this).parent().children('.textarea_bg_over').stop().animate({opacity: 1}, {queue: false, duration: 300});
		}
		/* déplacement du label hors du champ input */
		$(this).parent().children('.label').css('color', '#005192');
		$(this).parent().children('.label').stop().animate({marginTop: '-16px'}, {queue: false, duration: 100});
		/* positionnement de la value du champ input */
		$(this).stop().animate({color: styleInput_color2, paddingTop: '5px', height: '140px'}, {queue: false, duration: 100});
		$(this).css('font-style',styleInput_fstyle2);
		$(this).css('color', '#333');
		
	}).blur(function(){
		
		/* suppression de l'effet bleuté */
		$(this).parent().children('.textarea_bg_over').stop().animate({opacity: 0}, {queue: false, duration: 450});
		/* repositionnement du label */
		$(this).parent().children('.label').css('color', '#444');
		$(this).parent().children('.label').stop().animate({marginTop: '6px'}, {queue: false, duration: 200});
		/* positionnement de la value du champ input */
		$(this).css('color', '#005192');
		$(this).stop().animate({paddingTop: '20px', height: '125px'}, {queue: false, duration: 100});
			
		/* repositionnement du label uniquement si le champ est vide */
		if($(this).attr('value') == '')
		{
			$(this).css({
				'color': styleInput_color2,
				'font-size': styleInput_fsize2,
				'font-style': styleInput_fstyle2
			});
		}
		
	});
	
	
	$('.input_bg_over').click(function(){
		$(this).next('input').focus();
	});
	

});


/* =============================================================================
* ===========================================================================*/





function PopupCentrer(page,name,largeur,hauteur,options) 
{
    var top=(screen.height-hauteur)/2;
    var left=(screen.width-largeur)/2;
    window.open(page,name,"top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}
    
function openShadowbox( _page, _width, _height, _player) {

	if(typeof(_width) == 'undefined'){
		_width = 950;
	}
	if(typeof(_height) == 'undefined'){
		_height = 800;
	}		
	if(typeof(_player) == 'undefined'){
		_player = 'iframe';
	}	
    Shadowbox.open({player:_player, content:_page, height:_height, width:_width, options:{fadeDuration:0.1, resizeDuration:0.1, animSequence:"sync"}});
}

function closeShadowbox( _goto ) {
    Shadowbox.close();
    
    if(typeof(_goto) != 'undefined')
        document.location.replace(_goto);
}

function is_mail(mail){
	var filter_email=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	return filter_email.test(mail);
}

var t_res;
function preload( t_img ) 
{
	t_res = new Array()
	for(var i=0;i<t_img.length;i++)
	{
		var el = new Image();
		el.src = t_img[i];
		t_res.push( el );
	}
}

function nqToolTip() {
	xOffset = 5;
	yOffset = 5;
	
	Dom.getElementsBy(function(e){return e.className=='screenshot';}, 'a', document.body, function(e) {
		YAHOO.util.Event.addListener(e, "mouseover", function(ev) {
			var p = document.createElement('p');
			p.id = 'screenshot';
			p.innerHTML += "<img src='"+ e.rel +"' />";
			document.body.appendChild(p);
			Dom.setStyle(p,'top',(YAHOO.util.Event.getPageY(ev) + xOffset) + "px");
			Dom.setStyle(p,'left',(YAHOO.util.Event.getPageX(ev) + yOffset) + "px");
			Dom.setStyle(p,'display','block');
			});
		YAHOO.util.Event.addListener(e, "mouseout", function(ev) {
			document.body.removeChild(Dom.get('screenshot'));
			});
		YAHOO.util.Event.addListener(e, "mousemove", function(ev) {
			Dom.setStyle('screenshot','top',(YAHOO.util.Event.getPageY(ev) + xOffset) + "px");
			Dom.setStyle('screenshot','left',(YAHOO.util.Event.getPageX(ev) + yOffset) + "px");
			}); 
	});
}

