

/**
 *  Togo2010 - Main Js
 *  @author     alex, frank, paul
 *  @version    spip.2.0.10
 */



//      1. Slogan Header

var slogans = new Array(
    'Essou n&eacute;n&eacute;. Essou&thinsp;!',
    'Yes to go&thinsp;! Yes Togo&thinsp;!'
);
var slogans_index = 0;
var slogan_timeout = setInterval( "shift_slogan()", 4000 );

/**
 *  Slogan Header
 */
function shift_slogan()
{
	i = ( slogans_index + 1 ) % slogans.length;
	slogans_index = i;
	$("#titre3").fadeOut( "slow", function() { $(this).html( slogans[ slogans_index ]).fadeIn( "slow" ); });
}


//      2. Col de droite

/**
 *  On Load
 */
$(function()
{
	//      texte du champ de recherche
	$('#recherche').click(function()
	{
        if ( $(this).val() == 'Rechercher...' ) $(this).val('');
    });
    $('#recherche').blur( function()
    {
        if ( $(this).val() == '' ) $(this).val("Rechercher...");
    });
	
	//      imprimer
	$('#outils-imp').click(function()
	{
		window.print();
		return false;
	});
	
	//      soutenez Kofi Yamgnane
	$('#bouton-soutenir, #soutenir-login .popup-overlay, #soutenir-login .btn-fermer').click(function()
	{
        $('#soutenir-login').toggle();
	});
	
	//      paiement
	$('#dons .content a').click(function()
	{
        if ( confirm( "Vous allez être redirigé sur la page de paiement sécurisé." ))
            window.location.href = "http://paypal.sursauttogo.org/index.php?option=com_virtuemart&page=shop.browse&category_id=1&Itemid=53";
        return false;
	});


//      3. Formulaires

    $(".obligatoire").parent().find("label").append( '<span style="color:red"> * </span>' );


//==============================================================================================================================
    
    //init_adjust_height()
    setTimeout( "init_adjust_height()", 200 );
    
});


var count_adjust_height = 0;
var adjust_height_interval = 0;


/**
 *  TODO: clearfix this !
 */
function init_adjust_height()
{
    adjust_height_interval = setInterval( "adjust_height()", 500 );
}


/**
 *  TODO: clearfix this !
 */
function adjust_height()
{
	//      calage des hauteurs pour la sidebar
	var height = Math.max( $('#content').height(), $('#sidebar').height() );
	$('#content').css( 'height', height );
	$('#sidebar').css( 'height', height );
	
	//      on laisse pas cette horreur tourner indéfiniment
	count_adjust_height ++;
	if ( count_adjust_height > 10 )
	{
        clearInterval( adjust_height_interval );
        //console.log( 'adjust_height out' );
    }
}

/* Browser Css Selectors */

$(function() { 
    var ua = navigator.userAgent.toLowerCase(); 
    var myBrowsers = { 
        // Déjà détectés en natif par jQuery 
        mozilla: $.browser.mozilla, 
        safari:  $.browser.safari, 
        opera:   $.browser.opera, 
        ie:      $.browser.msie, 
        // Quelques améliorations et ajouts 
        ie6:     $.browser.msie && ($.browser.version < 7), 
        ie7:     $.browser.msie && ($.browser.version == 8), 
        ie8:     $.browser.msie && ($.browser.version > 7), 
        iphone:  /iphone/.test(ua), 
        chrome:  /chrome/.test(ua), 
        firefox: /firefox/.test(ua), 
        webkit:  /webkit/.test(ua), 
        // Détection de plateformes 
        osx:     /mac os x/.test(ua), 
        win:     /win/.test(ua), 
        linux:   /linux/.test(ua) 
    }; 
    $.each(myBrowsers, function(a, b) { 
        if (b) $('html').addClass(a); 
    }); 
});
