function changeContenu(contenu){
    if (contenu != 'blog') {
        var lecontenant = document.getElementById("contenant");
        lecontenant.innerHTML = textes[contenu];
        if (window.document.f) 
            window.document.f.s.value = contenu;
    } else {
		callBlog(10);
	}
}

function callBlog(day) {
	$('#contenant').fadeOut("slow", function(){
		$('#contenant').load("blog.php?lg="+lg+"&day="+day, function() {
			$('#contenant').fadeIn("slow");
		});
	});
}
function callBlogDetail(blog_id, lg, day) {
	if($('#day_blog').css("display") == "block")
		$('#day_blog').fadeOut("slow");
	if($('#day_blog_detail').css("display") == "block")
		$('#day_blog_detail').fadeOut("slow");
	
	$('#day_blog_detail').load("blog_detail.php?blog_id="+blog_id+"&lg="+lg+"&day="+day, function(){		
			$('#day_blog_detail').fadeIn("slow");		
	});
}

function flashInitialized(){
    var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
    
    // get flash object
    //alert(isInternetExplorer)
    flashObject = isInternetExplorer ? document.getElementById("som_nunavik_home") : document.myflash1;
    //alert(flashObject)
    // call action script function
}

function callTheFlash(theday){
    if (flashObject != 'none') {
        if (flashObject == undefined) {
            flashObject = document.getElementsByName("som_nunavik_home")[0];
            //alert(flashObject)
        }
        flashObject.setDay(theday);
        //frameToCall.location.href = "tiny.swf?speech="+theday;
    }
    return false;
}

/**
 * Function that will toggle between simple and detailed view of an artist.
 * It uses jQuery.
 */
function simple_detailed_artists(element, flag){
    if (flag) {
        $(".simple").hide("slow");
        $(element).parent().parent().parent().children(".detailed").show("slow");
    }
    else {
        $(element).parent().hide("slow");
        $(".simple").show("slow");
    }
}

function EmailValid(e){
    var carateres_permis = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789._-@";
    var valide = true;
    for (j = 0; j < e.length; j++) {
        if (carateres_permis.search(e.substr(j, 1)) == -1) {
            valide = false;
            break;
        }
    }
    if (e.indexOf("..") > 0 ||
    e.indexOf("@") == 0 ||
    e.lastIndexOf("@") == (e.length - 1) ||
    e.indexOf("@") != e.lastIndexOf("@") ||
    e.indexOf(".") < 1 ||
    e.lastIndexOf(".") == (e.length - 1) ||
    e.indexOf(".") == (e.indexOf("@") - 1) ||
    e.indexOf(".") == (e.indexOf("@") + 1)) {
        valide = false;
    }
    return valide;
}

function VerifData_en(){
    var f = window.document.f;
    var MsgErreurs = new Array();
    var i = 0;
    var TexteErreurs = "";
    
    if (f.name.value.length == 0) 
        MsgErreurs[i++] = "- Name";
    
    if (f.lastname.value.length == 0) 
        MsgErreurs[i++] = "- Last Name";
    
    if (f.email.value.length == 0) 
        MsgErreurs[i++] = "- Email";
    
    if (MsgErreurs.length > 0) {
        TexteErreurs += "Please fill out these fileds:\n\n";
        for (i = 0; i < MsgErreurs.length; i++) {
            TexteErreurs += "  " + MsgErreurs[i] + "\n";
        }
        alert(TexteErreurs);
    }
    else 
        if (!EmailValid(f.email.value)) {
            f.email.focus();
            f.email.select();
            alert("Please enter a valid Email address");
        }
        else 
            f.submit();
}

VerifData_iu = VerifData_en;

function VerifData_fr(){
    var f = window.document.f;
    var MsgErreurs = new Array();
    var i = 0;
    var TexteErreurs = "";
    
    if (f.name.value.length == 0) 
        MsgErreurs[i++] = "- Prénom";
    
    if (f.lastname.value.length == 0) 
        MsgErreurs[i++] = "- Nom";
    
    if (f.email.value.length == 0) 
        MsgErreurs[i++] = "- Courriel";
    
    if (MsgErreurs.length > 0) {
        TexteErreurs += "Ces champs sont obligatoires :\n\n";
        for (i = 0; i < MsgErreurs.length; i++) {
            TexteErreurs += "  " + MsgErreurs[i] + "\n";
        }
        alert(TexteErreurs);
    }
    else 
        if (!EmailValid(f.email.value)) {
            f.email.focus();
            f.email.select();
            alert("Le courriel entré n'est pas valide");
        }
        else 
            f.submit();
}

function MM_swapImgRestore(){ //v3.0
    var i, x, a = document.MM_sr;
    for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) 
        x.src = x.oSrc;
}

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];
            }
    }
}

function MM_findObj(n, d){ //v4.01
    var p, i, x;
    if (!d) 
        d = document;
    if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document;
        n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) 
        x = d.all[n];
    for (i = 0; !x && i < d.forms.length; i++) 
        x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) 
        x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) 
        x = d.getElementById(n);
    return x;
}

function MM_swapImage(){ //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments;
    document.MM_sr = new Array;
    for (i = 0; i < (a.length - 2); i += 3) 
        if ((x = MM_findObj(a[i])) != null) {
            document.MM_sr[j++] = x;
            if (!x.oSrc) 
                x.oSrc = x.src;
            x.src = a[i + 2];
        }
}

function openWindow(theURL, winName, features){
    window.open(theURL, winName, features);
}

