/**
 * Created by IntelliJ IDEA.
 * User: maximedewelle
 * Date: 20 aožt 2010
 * Time: 13:13:56
 */

/* Redirection en fonction de la langue du navigateur*/

function redirection(lang){

    if (navigator.browserLanguage) var language = navigator.browserLanguage;
    else var language = navigator.language;
    
    if ((language.indexOf('fr') > -1) && (lang != 'fr')) document.location.href = 'fr/';
    else if ((language.indexOf('en') > -1) && (lang != 'en')) document.location.href = 'en/';
    /*else
    document.location.href = 'francais.html'; */

}

jQuery.noConflict();

jQuery(document).ready(function(){
    jQuery.get('src/Ajax.php?searchList=1&lang='+lang, function(data) {
        //alert(data);
        var keywords = data.split(",");
        jQuery("#searchText").autocomplete(keywords);

    });

});

function slideSwitch() {
    var $active = jQuery('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = jQuery('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : jQuery('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order

    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

jQuery(function() {
    setInterval( "slideSwitch()", 7000 );
});

function getHomeText(rootAd,pageId,lang){
    jQuery('#practiceDetail').load(rootAd+'src/Ajax.php?homeText='+pageId+'&lang='+lang, function() {
        //alert('Load was performed.');
        //$('#areasList').css("display", "none");
        document.getElementById('areasList').style.display = 'hidden';
    });

}

function showTeam(idTeam){
    var li = document.getElementById('group-'+idTeam);
    var ul = document.getElementById('teamList-'+idTeam);

    if ( li.className != 'closed' ) {
        li.className = 'closed';
        ul.style.display = 'none';
	}
	else {
        li.className = 'open';
        ul.style.display = 'block';
	}
}

// Script pour les titres dans la police choisie

Cufon.replace('#menu li a');
Cufon.replace('h1');
Cufon.replace('h2');
Cufon.replace('h3');

window.addEvent('domready', function() {
    SqueezeBox.assign($$('a[rel=boxed]'), {
            size: {x: 420, y: 350},
            handler:'iframe'
    });

    SqueezeBox.assign($$('a[rel=pics]'), {
           // size: {x: 640, y: 480},
            handler:'image'
    });

    SqueezeBox.assign($$('a[rel=map]'), {
            size: {x: 640, y: 480},
            handler:'iframe'
    });

    SqueezeBox.assign($$('a[rel=parking]'), {
            size: {x: 300, y: 180},
            handler:'iframe'
    });
});
