/* Google Analytics */
function sendTag(Action, Name, Type){
    try {
        //alert(Action + "," + Name + "," + Type);
        switch (Type) {
            case "stats_weborama":
                try {
                    jQuery('#stats_weborama').remove();
                    var TR = Name;
                    var src = 'http://danone.solution.weborama.fr/fcgi-bin/performance.fcgi?ID=' + ID + '&A=' + A + '&TR=' + TR + '&CL=' + CL + '&AC=' + AC + '&MA=' + MA + '&AR=' + AR + '&AV=' + AV + '';
                    jQuery('#stats_container').append('<img id="stats_weborama" src="' + src + '" border="0" width="1" height="1" alt="" />');
                } 
                catch (exc) {
                
                }
                break;
            default:
            case "google":
            case "stats_google":
                switch (Action) {
                    case "event":
                        _gaq.push(['_trackEvent', "click", Name]);
                        break;
                    default:
                    case "page":
                        _gaq.push(['_trackPageview', Name]);
                        break;
                }
                break;
                
            case "stats_bluestreak":
                bsk_img = new Image();
                bsk_img.src = 'http://s0b.bluestreak.com/ix.e?bb&t=' + Name;
                break;
        }
    } 
    catch (exc) {
    }
}

/*-------------dermatologue popin------*/
function dermatologuePopUp(){

    var size = getPageSize();
    $("#dermatologuePopUp").height(size[1] + 'px');
    $("#dermatologuePopUp").fadeTo('fast', 0.7, function(){
        $("#dermatologuePopUp, #dermatologuePopUpInside").fadeIn(900);
    });
    setTimeout("goToTop()", 300);    
}

function closeDermatologuePopUp(){
    $("#dermatologuePopUp, #dermatologuePopUpInside").fadeOut(900);
}

function goToTop(){
    window.scrollTo(0, 0);
}

function getPageSize(){
    var xScroll, yScroll;
    if (window.innerHeight && window.scrollMaxY) {
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
    }
    else 
        if (document.body.scrollHeight > document.body.offsetHeight) {
            xScroll = document.body.scrollWidth;
            yScroll = document.body.scrollHeight;
        }
        else {
            xScroll = document.body.offsetWidth;
            yScroll = document.body.offsetHeight;
        }
    
    var windowWidth, windowHeight;
    if (self.innerHeight) {
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    }
    else 
        if (document.documentElement && document.documentElement.clientHeight) {
            windowWidth = document.documentElement.clientWidth;
            windowHeight = document.documentElement.clientHeight;
        }
        else 
            if (document.body) {
                windowWidth = document.body.clientWidth;
                windowHeight = document.body.clientHeight;
            }
    
    if (yScroll < windowHeight) {
        pageHeight = windowHeight;
    }
    else {
        pageHeight = yScroll;
    }
    if (xScroll < windowWidth) {
        pageWidth = windowWidth;
    }
    else {
        pageWidth = xScroll;
    }
    
    arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight);
    return arrayPageSize;
}

/*----------random question---------------*/
function substr_count(string, substring, start, length){
    var c = 0;
    if (start) {
        string = string.substr(start);
    }
    if (length) {
        string = string.substr(0, length);
    }
    for (var i = 0; i < string.length; i++) {
        if (substring == string.substr(i, substring.length)) 
            c++;
    }
    return c;
}

var randomlink2;
function swap(){
    var url = window.location.href;
    var urlparts = url.split('?');
    var id = urlparts[1];
    var path;
    if ((substr_count(url, 'deodorants-anti-transpirants-femme') > 0) || (substr_count(url, 'deodorants-anti-transpirants-homme') > 0)) {
        path = '../';
    }
    else 
        path = '';
    
    var links = new Array("<a href='" + path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q1' title=\"Pourquoi transpirons-nous ?\">Pourquoi transpirons-nous ?</a>", "<a href='" + path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q2' title=\"D'où vient la transpiration ?\">D'où vient la transpiration ?</a>", "<a href='" + path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q3' title=\"A quel âge commence-t-on à transpirer ?\">A quel âge commence-t-on à transpirer ?</a>", "<a href='" + path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q4' title=\"Les hommes transpirent-il plus que les femmes ?\">Les hommes transpirent-il plus que les femmes ?</a>", "<a href='" + path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q5' title=\"Est-ce que je transpire moins si je me rase ?\">Est-ce que je transpire moins si je me rase ?</a>", "<a href='" + path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q6' title=\"Pourquoi la transpiration sent-elle mauvais ?\">Pourquoi la transpiration sent-elle mauvais ?</a>", "<a href='" + path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q7' title=\"Qu'est-ce que la pierre d'alun ? Comment agit-elle ?\">Qu'est-ce que la pierre d'alun ? Comment agit-elle ?</a>", "<a href='" + path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q8' title=\"Les sels d'aluminium sont-ils dangereux ?\">Les sels d'aluminium sont-ils dangereux ?</a>", "<a href='" + path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q9' title=\"Quelle quantité de déodorant doit-on appliquer ?\">Quelle quantité de déodorant doit-on appliquer ?</a>", "<a href='" + path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q10' title=\"Auréoles liées au stress, le cercle vicieux\">Auréoles liées au stress, le cercle vicieux</a>", "<a href='" + path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q11' title=\"Comment lutter contre les traces blanches? \">Comment lutter contre les traces blanches? </a>", "<a href='" + path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q12' title=\"C'est mauvais de réguler la transpiration ?\">C'est mauvais de réguler la transpiration ?</a>", "<a href='" + path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q13' title=\"Spray, bille ou stick ?\">Spray, bille ou stick ?</a>", "<a href='" + path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q14' title=\"Que choisir entre déodorant ou anti-transpirant ?\">Que choisir entre déodorant ou anti-transpirant ?</a>", "<a href='" + path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q15' title=\"Le déodorant après l’épilation, ça brûle ?\">Le déodorant après l’épilation, ça brûle ?</a>", "<a href='" + path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q16' title=\"Qu'est-ce que l'hyperhidrose ?\">Qu'est-ce que l'hyperhidrose ?</a>", "<a href='" + path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q17' title=\"Comment lutter contre la transpiration excessive ?\">Comment lutter contre la transpiration excessive ?</a>", "<a href='" + path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q18' title=\"Mains moites, j’ai tout essayé\">Mains moites, j’ai tout essayé</a>", "<a href='" + path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q19' title=\"Comment neutraliser les odeurs de pieds ?\">Comment neutraliser les odeurs de pieds ?</a>");
    var links2 = new Array(path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q1", path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q2", path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q3", path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q4", path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q5", path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q6", path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q7", path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q8", path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q9", path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q10", path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q11", path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q12", path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q13", path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q14", path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q15", path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q16", path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q17", path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q18", path + "questions-reponses-transpiration-deodorants-anti-transpirants.html?Q19");
    
    var x = (Math.floor(Math.random() * links.length));
    randomlink = (links[x]);
    randomlink2 = (links2[x]);
    
    if ($('#randomLink')) {
        $('#randomLink').html(randomlink);
    }
}

$(document).ready(function(){
   /* dermatologue popup */
    $('.dermatologue').click(function(event){
	    sendTag('event', 'fr_PopinDermato', 'stats_google');
    	event.preventDefault();
        dermatologuePopUp();
    });
    
    $('.fermer').click(function(event){
		event.preventDefault();
        closeDermatologuePopUp();
    });
    
    swap();
    $('.last').click(function(){
        location.href = randomlink2;
    });    
    
    /* conseille / questions */
    $('.Q1').click(function(){
        sendTag('event', 'fr_FAQ_Q01', 'stats_google');
    });
    
    $('.Q2').click(function(){
        sendTag('event', 'fr_FAQ_Q02', 'stats_google');
    });
    
    $('.Q3').click(function(){
        sendTag('event', 'fr_FAQ_Q03', 'stats_google');
    });
    
    $('.Q4').click(function(){
        sendTag('event', 'fr_FAQ_Q04', 'stats_google');
    });
    
    $('.Q5').click(function(){
        sendTag('event', 'fr_FAQ_Q05', 'stats_google');
    });
    
    $('.Q6').click(function(){
        sendTag('event', 'fr_FAQ_Q06', 'stats_google');
    });
    
    $('.Q7').click(function(){
        sendTag('event', 'fr_FAQ_Q07', 'stats_google');
    });
    
    $('.Q8').click(function(){
        sendTag('event', 'fr_FAQ_Q08', 'stats_google');
    });
    
    $('.Q9').click(function(){
        sendTag('event', 'fr_FAQ_Q09', 'stats_google');
    });
    
    $('.Q10').click(function(){
        sendTag('event', 'fr_FAQ_Q10', 'stats_google');
    });
    
    $('.Q11').click(function(){
        sendTag('event', 'fr_FAQ_Q11', 'stats_google');
    });
    
    $('.Q12').click(function(){
        sendTag('event', 'fr_FAQ_Q12', 'stats_google');
    });
    
    $('.Q13').click(function(){
        sendTag('event', 'fr_FAQ_Q13', 'stats_google');
    });
    
    $('.Q14').click(function(){
        sendTag('event', 'fr_FAQ_Q14', 'stats_google');
    });
    
    $('.Q15').click(function(){
        sendTag('event', 'fr_FAQ_Q15', 'stats_google');
    });
    
    $('.Q16').click(function(){
        sendTag('event', 'fr_FAQ_Q16', 'stats_google');
    });
    
    $('.Q17').click(function(){
        sendTag('event', 'fr_FAQ_Q17', 'stats_google');
    });
    
    $('.Q18').click(function(){
        sendTag('event', 'fr_FAQ_Q18', 'stats_google');
    });
    
    $('.Q19').click(function(){
        sendTag('event', 'fr_FAQ_Q19', 'stats_google');
    });
});

