/* ========================================================================================
  ::  SITE.FO
  	  Version $Id: site.fo.js 41 2010-11-25 10:02:43Z Easy Net Technology $
======================================================================================== */
jQuery( function( $ ) {

	/** Recherche : initialisation des champs *************************/
    	SITE.Utils.FocusBlurField({id:'login', val:SITE.FormDefaultValue.login, bIsRollOverable:true});
    	SITE.Utils.FocusBlurField({id:'pwd', val:SITE.FormDefaultValue.pwd, isPwd:true, bIsRollOverable:true});


    /** Global : Centrer la multi-pagination ****************************************/
		var iWidth = 0;
		$("ul.pagination").each( function(index) {
		    iWidth = 0;
		    $(this).children().each( function(index) {
		        iWidth += $(this).width();
		    });
		    var iTotalWidth = $(this).width();
		    var iPadding = (iTotalWidth - iWidth) / 2;
		    var sPadding = "padding-left:" + iPadding +"px";
		    $(this).css({'padding-left' : iPadding +'px'});
		});

	/** Commande : Gestion des champs en erreur ***********************/
    $('#cli_nom, #cli_prenom, #cli_email, #cli_tel_facturation, #cli_adresse_1_facturation, #cli_cp_facturation, #cli_ville_facturation, #cli_pays_facturation, #cli_nom_livraison, #cli_prenom_livraison, #cli_tel_livraison, #cli_adresse_1_livraison, #cli_cp_livraison, #cli_ville_livraison, #cli_pays_livraison').each(function(){
      $(this).focus(function(){
        if($(this).val() == 'veuillez remplir ce champ'){
          $(this).val('').removeClass('erreur');
        }
      });
      $(this).blur(function(){
        if($(this).val() == ''){
          $(this).val('veuillez remplir ce champ').addClass('erreur');
        }
      });
    });


    $('a[rel="out"]').each(function(index){
      $(this).attr('target','_blank');
    });

  /** Navigation : bouton retour en page précédente *****************/
    $('a[rel="js-btn-rturn"]').each(function(index){
      this.click = null;
      $(this).attr('href','javascript:history.back()');
    });

  /** Global : scroll jusqu'à l'ancre cible *************************/
    $('a[href*="#"]').each(function(){
      this.onclick = null;
      $(this).click(function(){
        var sHash = this.hash;
        if(sHash){
        	$('html, body').animate({scrollTop: $(sHash).offset().top}, 'slow');
		}
        return false;
      })
    });



	/** Navigation : rollover *****************************************/
		SITE.Utils.RollOverNavigation();

});
