var baseUrl = getMainDomain();
var addthis_pub = "diltoo";

function getMainDomain(){
    var domain = window.location.hostname;
    if(domain.substring(0, 4)!='www.'){
        return 'http://www'+domain.substring(domain.indexOf('.'), domain.length)+'/';
    }
    return 'http://'+domain+'/';
}

function recherche(){
    if(document.getElementById('q').value.length>0){
        document.getElementById('searchbox_017697679654030155034:w-4gaeorscm').submit();
    }
}

function GoTo(arg){
    window.location.href = baseUrl + arg +'.html';
}

function Go(arg){
    window.location.href = baseUrl + arg;
}

function AfficheCarte(arg){
    window.location.href= baseUrl + 'P_Affichage/carte-annonce.html?num=' + arg;
}

function showPicture(idPicture){
    var nbimg=pictureList.length;
    for (i=1; i<=nbimg; i++) {
        document.getElementById('Mphoto'+i).style.border='0px';
    }
    document.getElementById('Mphoto'+idPicture).style.border='2px solid #FF3300';
    currentPicture=idPicture;
    window.document.Gphoto.src=pictureList[(currentPicture-1)];
    self.location.hash='#photos-annonce';
}

function showNextPicture(){
    var nbimg=pictureList.length;
    if(currentPicture<nbimg){
        document.getElementById('Mphoto'+currentPicture).style.border='0px';
        currentPicture=currentPicture+1;
    }else{
        document.getElementById('Mphoto'+nbimg).style.border='0px';
        currentPicture=1;
    }

    document.getElementById('Mphoto'+currentPicture).style.border='2px solid #FF3300';
    window.document.Gphoto.src=pictureList[(currentPicture-1)];
    self.location.hash='#photos-annonce';
}

function backgroundLoadJs(uri){
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = baseUrl + uri;
    document.getElementsByTagName('head')[0].appendChild(script);
}

function backgroundLoadJsPublication(){
    backgroundLoadJs('P_Publication/lib/protoaculous.1.8.1.min.js');
    backgroundLoadJs('P_Publication/lib/formate_chaine.js');
    backgroundLoadJs('Ressources/JavaScript/Verif_Inscription2.js');
}

function backgroundLoadJsCompte(){
    backgroundLoadJs('Ressources/JavaScript/Compte.js');
    backgroundLoadJs('Ressources/JavaScript/Valid_Tel.js');
}