/*========================================================================
JS www.adress-company.fr
========================================================================*/

//Rollover Menu TOP
function initRollMenuTop()
{
	if( $(".li-menu-top") )
	{
		$('.li-menu-top').hover(
		 function()
		 {
		 		if($(this).children(".pad-ssmenu"))
		 		{
		 			$(this).children(".pad-ssmenu").css('display', 'block');
		 		}
				if($(this).attr("class")=="li-menu-top")
				{
					$(this).addClass("li-menu-top-over");
				}
		 },
		 function()
		 {
		 		if($(this).children(".pad-ssmenu"))
		 		{
		 			$(this).children(".pad-ssmenu").css('display', 'none');
		 		}
				if($(this).attr("class")=="li-menu-top li-menu-top-over")
				{
					$(this).removeClass("li-menu-top-over");
				}
		 }
		);
	}
}

//Rollover Pad prod HOME
function initRollHomeProd()
{
	if( $("#home-btn1-off") )
	{
		$('#home-btn1-off').click(
		 function()
		 {
			 	$('#home-prod2').css("display", "none");
			 	$('#home-prod1').css("display", "block");

                        $("#home-btn2-off").show();
                        $("#home-btn2").hide();
                        $("#home-btn1-off").hide();
                        $("#home-btn1").show();
		 }
		);
	}
	if( $("#home-btn2-off") )
	{
		$('#home-btn2-off').click(
		 function()
		 {
		 	$('#home-prod1').css("display", "none");
		 	$('#home-prod2').css("display", "block");

                        $("#home-btn2-off").hide();
                        $("#home-btn2").show();
                        $("#home-btn1-off").show();
                        $("#home-btn1").hide();
		 }
		);
	}
}

// Cache les msg d'erreur
function hide_error () {
	div  = (document.layers) ? document.layers['errorPad'] : document.getElementById('errorPad');
	div2  = (document.layers) ? document.layers['erlogPad'] : document.getElementById('erlogPad');
	div.className = "error_hide";
	div2.className = "error_hide";
}

/*==== Focus sur les fields ====*/
function GetFocus(field) {
	if (field.value==field.title) {field.value=''}
}

/*==== Blur sur les fields ====*/
function GetBlur(field) {
	if (field.value=='') {
		field.value=field.title;
	} 
}
function changeImgProd(elem) {
    $('#main_img').attr('src', $(elem).attr('src'));
    $('#main_link').attr('href', $(elem).attr('rel'));
    $('#zoom_link').attr('href', $(elem).attr('rel'));
}

// Affiche les r�f�rences 
function display_real($id_ref) {
	$('.blog-actu-atricle-title-left a').css('font-weight','normal');
	$('.list-actu-article').css('display','none');
	$('.laa-'+ $id_ref).css('display','block');
	$('.anchor-'+ $id_ref).css('font-weight','bold');
}
/*------ANIMATION ACTU-----*/
var nb_slide = 0;
$(document).ready(function() {
    $('.blog-actu-atricle-title-left:first a').css('font-weight', 'bold');

    $('.home-actu-article').each(function(){
        nb_slide++;
    });
    $('.next-actu img').click(function() {
    var i = 0;
    var current_shown;
    var current_shown_index;

            $('.home-actu-article').each(function(){
                i++;
                if($(this).css('display') != 'none')
                {
                    current_shown = $(this);
                    current_shown_index = i;
                }

            });


                    $(current_shown).hide();
                    if(current_shown_index == nb_slide) {

                        var _first = true;
                        $('.home-actu-article').each(function(){
                            if(_first == true)
                            {
                                _first = false;
                                $(this).show();
                            }
                        });
                    }
                    else {
                        $(current_shown).next().show();
                    }
    });
    $('.prev-actu img').click(function() {
    var i = 0;
    var current_shown;
    var current_shown_index;

            $('.home-actu-article').each(function(){
                i++;
                if($(this).css('display') != 'none')
                {
                    current_shown = $(this);
                    current_shown_index = i;
                }

            });


                    $(current_shown).hide();
                    if(current_shown_index == 1) {

                        var _first = true;
                        $('.home-actu-article').each(function(){
                            if(_first == true)
                            {
                                _first = false;
                                $(this).show();
                            }
                        });
                    }
                    else {
                        $(current_shown).prev().show();
                    }
    });
    var inter = window.setInterval("nextSlide()", 8000);
});
function nextSlide() {
    var i = 0;
    var current_shown;
    var current_shown_index;
    
            $('.home-actu-article').each(function(){
                i++;
                if($(this).css('display') != 'none')
                {
                    current_shown = $(this);
                    current_shown_index = i;
                }
                
            });


                    $(current_shown).hide();
                    if(current_shown_index == nb_slide) {
                        
                        var _first = true;
                        $('.home-actu-article').each(function(){
                            if(_first == true)
                            {
                                _first = false;
                                $(this).show();
                            }
                        });
                    }
                    else {
                        $(current_shown).next().show();
                    }
                
}
