function declancherEnvoyerAUnAmi(){
		jQuery('#envoyerAmiFlash').trigger('click');
}

function fairePartager(){
	jQuery('#partagerVideo').trigger('click');
}

// Verifie si c'est Netscape ou IE
var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 &&
                parseFloat(navigator.appVersion) >= 4 &&  parseFloat(navigator.appVersion) < 5) ? 1 : 0;
var isMinIE4 = (document.all) ? 1 : 0;
var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.") >= 0) ? 1 : 0;
var NS6 = (document.getElementById&&!document.all)

function Popup(name,urlstr,w,h) {
  popup=window.open(urlstr,name,"focus=yes,toolbar=yes,directories=yes,status=no,menubar=yes,scrollbars=yes,history=no,resizable=no,width="+w+",height="+h+"");
  popup.focus();
}

function Popup2(name,urlstr,w,h) {
  popup=window.open(urlstr,name,"focus=yes,toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,history=no,resizable=no,width="+w+",height="+h+"");
  popup.focus();
}

function Popup4(name,urlstr,w,h) {
  popup=window.open(urlstr,name,"focus=yes,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,history=no,resizable=no,width="+w+",height="+h+"");
  popup.focus();
}

function Popup3(name,urlstr) {
  popup=window.open(urlstr,name);
  popup.focus();
}

// Fonction pour ecrire dans la barre du bas du navigateur

function di(quel_b,bouton){
  if (document.images) {
    document.images[quel_b].src=eval(bouton+".src");
  }
}

function dm(msgStr){
    document.returnValue = false;
    if (document.images) {
    window.status = msgStr;
    document.returnValue = true;
  }
}

function di2(quel_b,bouton){
  if (document.images) {
    quel_b.src=eval(bouton+".src");
  }
}

function datetoday(){

  var journee = new Array("dimanche", "lundi","mardi","mercredi","jeudi","vendredi","samedi");
  var nommois = new Array("janvier","f&eacute;vrier","mars","avril","mai","juin","juillet","ao&ucirc;t","septembre","octobre","novembre","d&eacute;cembre");
  today = new Date();

  document.write ("le " + journee[today.getDay()] +"  " + today.getDate() +" " + nommois[today.getMonth()] + " " + today.getFullYear());
}


/*********/

function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
  endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
  var j = i + alen;
  if (document.cookie.substring(i, j) == arg)
  return getCookieVal (j);
  i = document.cookie.indexOf(" ", i) + 1;
  if (i == 0) break;
  }
  return null;
}
function SetCookie (name, value) {
  var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? argv[5] : false;
  document.cookie = name + "=" + escape (value) +
  ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
  ((path == null) ? "" : ("; path=" + path)) +
  ((domain == null) ? "" : ("; domain=" + domain)) +
  ((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {
  var exp = new Date();
  exp.setTime (exp.getTime() - 1);
  var cval = GetCookie (name);
  document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}


var telus = false;
    if (document.referrer&&document.referrer!="")
      telus = document.referrer.substring(0,37)=="http://www.globetrotter.net/gt/emploi";
var telusCookie = GetCookie("telus");

if (telus)
{
  var exp = new Date();
  exp.setTime(exp.getTime() + (60*60*1000));
  telusCookie = 1;
  SetCookie("telus", telusCookie, exp, "/");
}
telusCookie = GetCookie("telus");
if ( telusCookie != "" && telusCookie != null )
{
  telusCookie = parseInt(telusCookie);
  if ( telusCookie < 2 )
  {
    if (!telus)
    {
      telusCookie = telusCookie + 1;
      var exp = new Date();
      exp.setTime(exp.getTime() + (60*60*1000));
      SetCookie("telus", telusCookie, exp, "/");
    }
  }
  else
  {
    DeleteCookie("telus");
    telusCookie = null;
  }
}

function popsondage(){
  var sondage = GetCookie("Monemploi-Sondage-Apparitions");
  var dernDate = GetCookie("Monemploi-Sondage-Date");
  var repondu = GetCookie("Monemploi-Sondage-Repondu");
  var aujour = new Date();
  var dern = new Date(dernDate);

  if (aujour.getMonth()!=dern.getMonth() || aujour.getYear()!=dern.getYear())
    sondage = "";
  if ( sondage != "" && sondage != null && (repondu == "" || repondu == null) ){
    if(sondage<3 && aujour.getDay()!=dern.getDay()) {
      Popup2('popsondage','sondage.php',640,500);
      sondage=Number(sondage)+1;
    }
  }
  else if (repondu == "" || repondu == null) {
    sondage=1;
    Popup2('popsondage','sondage.php',640,500);
  }
  var exp = new Date();
  exp.setTime(exp.getTime() + (60*60*24*365*10*1000));
  SetCookie("Monemploi-Sondage-Apparitions", sondage, exp, "/");
  SetCookie("Monemploi-Sondage-Date", aujour, exp, "/");
}
function popsondage2006(){
  var sondage = GetCookie("Monemploi-Sondage2006-Apparitions");
  var dernDate = GetCookie("Monemploi-Sondage2006-Date");
  var repondu = GetCookie("Monemploi-Sondage2006-Repondu");
  var aujour = new Date();
  var dern = new Date(dernDate);
  var affiche = false;

  if (aujour.getMonth()!=dern.getMonth() || aujour.getYear()!=dern.getYear())
    sondage = "";
  if ( sondage != "" && sondage != null && (repondu == "" || repondu == null) ){
    if(sondage<3 && aujour.getDay()!=dern.getDay()) {
      affiche = true;
      sondage=Number(sondage)+1;
    }
  }
  else if (repondu == "" || repondu == null) {
    sondage=1;
    affiche = true;
  }
  var exp = new Date();
  exp.setTime(exp.getTime() + (60*60*24*365*10*1000));
  SetCookie("Monemploi-Sondage2006-Apparitions", sondage, exp, "/");
  SetCookie("Monemploi-Sondage2006-Date", aujour, exp, "/");

  if (affiche == false) document.getElementById('sondage').style.display = "none";
}

function cachelayer(){
  sondagelayer=getLayer('soussondage');
  if (sondagelayer.style.visibility=="hidden") sondagelayer.style.visibility="visible";
  else sondagelayer.style.visibility="hidden";
}

function creerHyperlienHttp(monLien){
  if (monLien.substr(0,7) == "http://"){
    return monLien;
  }
  else{
    return 'http://' + monLien;
  }
}

var dropdownouvert = false;

jQuery(document).ready(function() {


	/*
	 * @section Champs de recherche
	******************************************************************************/
	$('#s').attr('class','vide');
	$('#s').not('.plein').focus(function() {
		if ( $(this).val() == 'Recherche sur monemploi.com' ) {
			$(this).val( '' ).removeAttr('class');
		}
	}).blur( function() {
		if ( $(this).val() == '' ) {
			$(this).val( 'Recherche sur monemploi.com' ).attr('class','vide');
		}
	});


  if (jQuery('div#recrutent').length > 0) {

    if ($.browser.msie && parseInt($.browser.version) <= 7) {
      jQuery('div#recrutent select').mouseover(function(e) {

        if (jQuery(this).width() != 220) {

          dropdownouvert = true;
        }

      }).blur(function() {



      }).change(function() {


        dropdownouvert = false;

      });

      jQuery('div#recrutent form').bind('mouseleave', function() {
        dropdownouvert = false;
      });

      //setTimeout('clearDropDowns()', 2000);

    }

  }
});

jQuery(document).ready(function(){
  if (jQuery('div#livre-random').length > 0) {
    var param = (jQuery('div#livre-random').is('.large')) ? "&large=1" : "";
    jQuery('div#livre-random').load('/include/livre.php?random&couleur=orange'+param);
  }
});


jQuery(document).ready(function(){
  if (jQuery('#outils .partager').length > 0) {

    var partager_urls = {
        'delicious': function() {
	        window.open('http://del.icio.us/post?v=4;url=' + encodeURIComponent(location.href) + ';title=' + encodeURIComponent(document.title), "", "width=1000,height=600,menubar=1,resizable=1,scrollbars=1");
        },
        'publieca': function() {
			window.open('http://publie.ca/submit/?url='+encodeURIComponent(window.location.href.substr(0,1024))+'&title='+encodeURIComponent(document.title.substr(0,64)), "", "width=1000,height=600,menubar=1,resizable=1,scrollbars=1");
        },
        'facebook': function() {
            var d = document,
			f = 'http://www.facebook.com/share',
			l = d.location,
			e = encodeURIComponent,
			p = '.php?src=bm&v=4&i=0&u=' + e(l.href) + '&t=' + e(d.title);
            a = function() { if (!window.open(f + 'r' + p, 'sharer', 'toolbar=0,status=0,resizable=1,width=626,height=436')) l.href = f + p };
            if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0);
            else { a() }
        },
        'google': function() {
        	window.open('http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk=' + encodeURIComponent(location.href) + '&title=' + encodeURIComponent(document.title), "", "width=1000,height=600,menubar=1,resizable=1,scrollbars=1");
        },
		'linkedin' : function() {
			window.open('http://www.linkedin.com/shareArticle?mini=true&title='+ encodeURIComponent( document.title ) +'&url=' + encodeURIComponent(location.href) + '&source=septembre.com', "", "width=1000,height=600,menubar=1,resizable=1,scrollbars=1");
		}
    }


	jQuery('#outils .partager a').click(function(e) {

	    var classe = this.parentNode.className;
		if (partager_urls[classe]) {
			partager_urls[classe].call();
		} else {
			jQuery('#outils .partager').removeClass('visible');
		}

		if ( !$(this).parent().is('.twitter') ) {

			e.preventDefault();
			e.stopPropagation();

			return false;

		}

	});
  }

});


function clearDropDowns() {
  if (dropdownouvert == false) {

  }
  //setTimeout('clearDropDowns()', 2000);
}

jQuery(document).ready(function(){
  if (jQuery('#form_commande').length) {
    jQuery('#form_commande').validate();
  }

});


isValidCreditCardNumber = function(cardNumber, cardType)
{
  var isValid = false;
  var ccCheckRegExp = /[^\d ]/;
  isValid = !ccCheckRegExp.test(cardNumber);
  if (cardNumber == 4508395784903826784)
    return true;
  if (isValid)
  {
    var cardNumbersOnly = cardNumber.replace(/ /g,"");
    var cardNumberLength = cardNumbersOnly.length;
    var lengthIsValid = false;
    var prefixIsValid = false;
    var prefixRegExp;

    switch(cardType.toLowerCase())
    {
      case "mastercard":
        lengthIsValid = (cardNumberLength == 16);
        prefixRegExp = /^5[1-5]/;
        break;

      case "visa":
        lengthIsValid = (cardNumberLength == 16 || cardNumberLength == 13);
        prefixRegExp = /^4/;
        break;


      default:
        prefixRegExp = /^$/;
        alert("Veuillez entrer un type de carte de cr�dit");
    }

    prefixIsValid = prefixRegExp.test(cardNumbersOnly);
    isValid = prefixIsValid && lengthIsValid;
  }

  if (isValid)
  {
    var numberProduct;
    var numberProductDigitIndex;
    var checkSumTotal = 0;

    for (digitCounter = cardNumberLength - 1;
      digitCounter >= 0;
      digitCounter--)
    {
      checkSumTotal += parseInt (cardNumbersOnly.charAt(digitCounter));
      digitCounter--;
      numberProduct = String((cardNumbersOnly.charAt(digitCounter) * 2));
      for (var productDigitCounter = 0;
        productDigitCounter < numberProduct.length;
        productDigitCounter++)
      {
        checkSumTotal +=
          parseInt(numberProduct.charAt(productDigitCounter));
      }
    }

    isValid = (checkSumTotal % 10 == 0);
  }

  return isValid;
}
function validateCreditCard()
{
    if(isValidCreditCardNumber(document.getElementById('no_carte').value, document.getElementById('carte').options[document.getElementById('carte').selectedIndex].value))
    {


        document.form_commande.submit();

      isSubmitted = true;
    }
    else
    {
      document.getElementById('erreurcredit').innerHTML = 'Mauvais num&eacute;ro de carte de cr&eacute;dit.';
    }
}


//
// Autres nouvelels
//


jQuery(document).ready(function(){

  updater_hauteur_liste();

  jQuery('ul#section_nouvelles li').not('.choisi').find('ul').hide();


  jQuery('ul#section_nouvelles li a.sous_menu').click(function(){

    jQuery('li.choisi').removeClass('choisi')

    jQuery(this).parent().addClass('choisi')

    jQuery('ul#section_nouvelles li.choisi').find('ul').show();
    updater_hauteur_liste();
    jQuery('ul#section_nouvelles li').not('.choisi').find('ul').hide()

    return false;

  });

});

function updater_hauteur_liste() {

  var hauteur1 = jQuery('ul#section_nouvelles li.choisi').find('ul').height();
  var hauteur2 = jQuery('ul#section_nouvelles').height();
  if (hauteur1 > hauteur2){
    hauteur=hauteur1;
  }
  else {
    hauteur=hauteur2;
  }
  var hauteur_p = jQuery('p.encadre').height();
  jQuery('#wrap_liste').height( (hauteur+hauteur_p*2)+'px' );
}


//
// Random Copilote
//

jQuery(document).ready(function(){

  if (jQuery('#commentaires').length > 0) {
    var commentaires = [{
      commentaire: 'Les r&eacute;sultats du test &Ecirc;tes-vous un bon chercheur d\'emploi sont tr&egrave;s utiles et pratiques. Mon rapport personnalis&eacute; m\'a permis d\'apprendre &agrave; mieux me conna&#238;tre et &agrave; concentrer mes efforts aux bons endroits.',
      auteur: 'Yves Gu&eacute;rin, Qu&eacute;bec'
    }, {
      commentaire: 'Le test &Ecirc;tes-vous un bon chercheur d\'emploi est facile &agrave; compl&eacute;ter. J\'ai obtenu mes r&eacute;sultats rapidement. Ils constituent un excellent compl&eacute;ment &agrave; une d&eacute;marche que j\'avais entreprise avec une firme en r&eacute;orientation de carri&egrave;re',
      auteur: 'Jean, Montr&eacute;al'
    }, {
      commentaire: 'J\'ai pass&eacute; le test &Ecirc;tes-vous un bon chercheur d\'emploi. Les r&eacute;sultats et informations fournies sont utiles. Ce test s\'adresse surtout &agrave; ceux qui sont d&eacute;j&agrave; impliqu&eacute;s dans un processus de recherche d\'emploi',
      auteur: 'Marquis, Montr&eacute;al'
    }];

    var random = Math.floor(Math.random() * commentaires.length);
    var commentaire = commentaires[random];

    jQuery('div.encadre#commentaires p').replaceWith('<p><em>&#171;&nbsp;' + commentaire.commentaire + '&nbsp;&#187;</em><br /><br />' + commentaire.auteur + '</p>');

  }

});

jQuery(document).ready(function() {

	if($('body').is('.offre-emploi')){
		jQuery('div.boutons-social').html("");
		//(function() {
																		
			/*var html = '<div class="boutons-social"><div class="facebook-bt"><iframe src="http://www.facebook.com/plugins/like.php?href=%{url}&amp;layout=normal&amp;show_faces=false&amp;width=350&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:350px; height:35px;" allowTransparency="true"></iframe></div><div class="google-1"><g:plusone size="medium"></g:plusone></div></div>';
			html = html.replace(/%{url}/, escape(window.location.toString()) )
			$(this).append(html);*/
		//});
	}

	$('.liste-emplois ul li a').click(function(e){
		e.preventDefault();
		var popup	= window.open($(this).attr('href'),'detailOffre','height=630,width=722,top=100,left=100,scrollbars=yes,toolbar=no');
	});

	if($('#offresEmplois').length > 0){
		$('#offresEmplois').hide();

		$('.liste-emplois a.toggle span.action').html('Ouvrir').addClass('fermer');

		$('.liste-emplois a.toggle').click(function(e){
			e.preventDefault();
			if($('#offresEmplois').is(':visible')){
				$('#offresEmplois').slideUp();
				$('.liste-emplois a.toggle span.action').html('Ouvrir').addClass('fermer').removeClass('ouvert');
			}
			else{
				$('#offresEmplois').slideDown();
				$('.liste-emplois a.toggle span.action').html('Fermer').addClass('ouvert').removeClass('fermer');
			}
		});

	}

});





jQuery(document).ready(function(){

	// menu principal
	$('#menu-principal li.drop').hover(function(){
		$(this).addClass('hover');
												
	},
	function(){
		$(this).removeClass('hover');
	});

});
