// 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";
}

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=vert'+param);
	}
});

//
// 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' );
}



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;
		
		}
		
	});
  }
  
});