/**
 * ACTION
 * $.la.action.loginBoxParams
 *
 * MENU
 * $.la.menu.montre(id)
 * $.la.menu.showClassSsRub(id,value)
 * $.la.menu.showClass(id,value)
 * $.la.menu.cache(id)
 *
 * SHOP
 *  $.la.shop.verifyConditions(idCheckbox, idForm)
 *
 * UTILS
 * $.la.utils.showFirstLink(nbphotos)
 *
 * FLASH
 * $.la.flash.showInfo(id,titre,description,mp3,image,image_big)
 *
 * 
 */

(function($){
    $.la = $.la||{};
    $.extend(true,$.la,
    {
        baseUrl:'',
        baseIdForm:'',

        action:{
            settings:{
                loginBox:{title:'Login', width:515, height:500}
            },

            getLoginBoxByCookie:function(LayerId, editUrl, forgotUrl, registerUrl, logoutUrl, loginUrl, BaseUrl, BaseImg)
            {
                var baseUrl = BaseUrl;
                var texte = '';
                if (typeof BaseImg == undefined)
                    BaseImg = "bugundef";
                if($.la.cookie.get("user_logged") == "oui"){
                    var pseudo = $.la.cookie.get("login_gulliland");
                    var prenom = $.la.cookie.get("prenom_gulliland");
                    if(prenom === null || prenom === false || prenom === undefined || prenom === '' || typeof prenom  === 'null' ||  typeof prenom  === 'undefined')
                        prenom = '';
                    texte+='<strong>Bonjour ' + prenom + '</strong>';
                    texte+='<a href="' + logoutUrl + '" title="d&eacute;connexion"  class="sortir"></a>';

                }else{
                    texte+='<form method="post" action="" name="mon_compte" id="mon_compte" onsubmit="return false;">';
                    texte+='	<span class="login_boxes">';
                    texte+='		<label for="pseudo">Pseudo</label><input type="text" name="UserLogin" id="pseudo" tabindex="1" onFocus="this.value=\'\'" />';
                    texte+='		<span class="div3"></span>';
                    texte+='		<label for="passe">Mot de passe</label><input type="password" name="UserPassword" id="passe" tabindex="2" onFocus="this.value=\'\'" onkeypress="if (event.which == 13 || event.keyCode == 13) loginUser( \'' + LayerId + '\', \'' + editUrl + '\', \'' + forgotUrl + '\', \'' + registerUrl + '\', \'' + logoutUrl + '\', \'' + loginUrl + '\', \'' + BaseUrl + '\', \'' + BaseImg + '\', \'loginContent\', \'mon_compte\' ); else return true; "/>';
                    texte+='		<span class="btn_ok">';
                    texte+='			<a href="javascript:void(0);" onclick="$.la.action.loginUser( \'' + LayerId + '\', \'' + editUrl + '\', \'' + forgotUrl + '\', \'' + registerUrl + '\', \'' + logoutUrl + '\', \'' + loginUrl + '\', \'' + BaseUrl + '\', \'' + BaseImg + '\', \'loginContent\', \'mon_compte\' );"></a>';
                    texte+='		</span>';
                    texte+='	</span>';
                    texte+='	<input type="checkbox" id="se_souvenir" name="Cookie" />';
                    texte+='</form>';
                    texte+='<label for="se_souvenir">Se souvenir de moi ?</label>';
                    texte+='<a href="'+registerUrl+'" class="subscribe"></a>';
                }
                texte += '<div id="loginContent" style="display:none"></div>';
                $('#' + LayerId).html(texte);

                if($.la.cookie.get("pseudo_has_error") == "oui"){
                    $.la.cookie.set("pseudo_has_error","non");
                    window.location.href= "/action/edit";
                }
            }
        },

        menu:
        {
            montre: function(id){
                $('#premier_niveau > li').each(function(i){

                    if(parent != id){
                        $(this).attr('class','');
                    }
                });

                for (var i = 0; i <= 10; i++) {
                    $('#smenu' + i).css('display','none');
                }
                $('#' + id).css('display','block');
			    
                $('#' + id).parents('li').each(function(i){
                    $(this).attr('class','actif');
                });
            },

            showClassSsRub: function(id,value){
                $('#' + id + ' a').attr('class',value);
            },

            showClass: function(id,value){
                $('#' + id).attr('class',value);
            },
            cache: function (id){
                $('#' + id).each(function(){
                    $(this).css('display','none');
                });
            }
			
        },
        shop:{
            messages:{
              mustAcceptCondition: 'Tu dois avoir lu et accepté les conditions'
            },

            verifyConditions: function(idCheckbox, idForm) 
            {
                if($('#' + idCheckbox).attr('checked'))
                {
                    $('#'+idForm).submit();
                }
                else
                {
                    alert($.la.shop.messages.mustAcceptCondition);
                }
            }
        },

        utils:{
            showFirstLink:function(nbphotos) {
                if($('#link0')){
                    $('#link0').show();
                    for(var i=1; i<nbphotos; i++){
                        $('#' + 'link' + i).hide();
                    }
                }
            },
            
            displayPartnerTab:function(numero,limite){
            	numero = parseInt(numero);
            	limite = parseInt(limite);
            	
            	for(var i=0; i<limite; i++){
            		if(i == numero){
            			$('#'+ 'partenaire' + i).css('display', 'block');
            		} else {
            			$('#'+ 'partenaire' + i).css('display', 'none');
            		}
            	}
            }
        },

        flash :{
            showInfo:function(id,titre,description,mp3,image,image_big){
                $('#flashImage').attr('src', $.la.sHost + image);
                $('#flashImageA').attr('href',$.la.sHost + image_big);
                $('#flashDescription').html(description);
                //document.getElementById('flashMp3').innerHTML = mp3;
                $('#flashTitre').html(titre);
                $.la.flash.reloadPlayerSon(id);
            //myLightbox.updateImageList();
            },

            reloadPlayerSon: function(id){
                $('#flashContent_playerson').html('');
                $('#flashContent_playerson').flashembed(
                    {
						 src: "/design/gulliland/images/flash/miniplayer_sons.swf",
						 wmode: "opaque",
						 width: 171,
						 height: 48,
						 version: [8,0],
						 bgcolor: "#c5c7c6",
						 id: "playerson"
					 },
                    {son:id}
				 );
            },

            zoomCreation: function(){
               $(".zoomCreation").lightBox().trigger('click');
            },

            zoomCreationAndPrint: function(){
              var win = window.open($(".zoomCreation").attr('href'));
              win.focus();
              win.print();
            },

            creationEnvoiAmi: function(urlAmi){
            	$.la.modalbox.call( '/action/envoi_ami?url=' + urlAmi, {height: 300, width: 510});
            }
        }
    });
    $.la.sHost = 'http://gulliland.gulli.fr';

})(jQuery);

var sHost = "http://gulliland.gulli.fr";
var tb_pathToImage = "http://gulliland.gulli.fr/design/gulliland/images/loading.gif";
