/**
  * @author     : Ludovic Mingot
  * @copyright : Copyright (c) Ludovic Mingot
  */
  
/**
 * SIFR
 *********/ 

var eurofurence = { src: 'http://www.goomeo.com/swf/eurofurence.swf' };
sIFR.activate(eurofurence);
sIFR.fixHover = false; 
sIFR.replace(eurofurence, {
  selector: '.sifrNormalCenter',
  css: ['.sIFR-root { text-align: center; font-weight: normal; font-size:38px; float:left; color:#FFFFFF; } '],
  selectable : false,
  wmode: 'transparent' 
});
sIFR.replace(eurofurence, {
  selector: '.sifrMedCenter',
  css: ['.sIFR-root { text-align: center; font-weight: normal; font-size:28px; float:left; color:#FFFFFF; } '],
  selectable : false,
  wmode: 'transparent' 
});
sIFR.replace(eurofurence, {
  selector: '.sifrSmallCenter',
  selectable : false,
  css: ['.sIFR-root { text-align: center; font-weight: normal; font-size:24px; float:left; color:#FFFFFF; } ','.sIFR-root a{ text-align: center; font-weight: normal; float:left; color:#FFFFFF; } ','.sIFR-root a:hover{ text-align: center; font-weight: normal; float:left; color:#FFFFFF; } '],
  onRelease: function(fi) { alert('sfsdfdf'); },
  wmode: 'transparent' 
});
sIFR.replace(eurofurence, {
  selector: '.sifrUltraSmallCenter',
  selectable : false,
  css: ['.sIFR-root { text-align: center; font-weight: normal; font-size:18px; float:left; color:#FFFFFF; } '],
  onRelease: function(fi) { alert('sfsdfdf'); },
  wmode: 'transparent' 
});

sIFR.replace(eurofurence, {
  selector: '.sifrMedCenterOrange',
  css: ['.sIFR-root { text-align: center; font-weight: normal; font-size:26px; float:left; color:#FF6600; cursor:pointer;} '],
  selectable : false,
  onRelease: function(fi) { alert('sdfdsf'); },
  wmode: 'transparent' 
});
sIFR.replace(eurofurence, {
  selector: '.sifrSmallWhite',
  selectable : false,
  onRelease: function(fi) {alert('sdfsfs')},
  css: ['.sIFR-root { font-weight: normal; font-size:22px; float:left; color:#FFFFFF; cursor:pointer; } '],
  wmode: 'transparent' 
});
sIFR.replace(eurofurence, {
  selector: '.sifrSmallCenterWhite',
  selectable : false,
  onRelease: function(fi) {alert('sdfsfs')},
  css: ['.sIFR-root { text-align: center; font-weight: normal; font-size:24px; float:left; color:#FFFFFF; cursor:pointer; } '],
  wmode: 'transparent' 
});
sIFR.replace(eurofurence, {
  selector: '.sifrCenterGris',
  css: ['.sIFR-root { text-align: center; font-weight: normal; font-size:28px; float:left; color:#555555; } '],
  selectable : false,
  wmode: 'transparent' 
});
sIFR.replace(eurofurence, {
  selector: '.sifrSmallCenterGris',
  css: ['.sIFR-root { text-align: center; font-weight: normal; font-size:20px; float:left; color:#555555; } '],
  selectable : false,
  wmode: 'transparent' 
});

function pitch(){
    $('#pitch').mouseover(function(){
        $('#pitch').animate({
            height:"200px"
        },300);
    });
}

/**
 * module_controller_action
 *********/ 

var member_user_feed = {
    load:function(){
        pitch();
       
    }
}


var default_index_index = {
    load:function(){
        $('#takeTour').click(function(){
            notice.show('info','Désolé vidéo indisponible.<br />En ligne trés bientôt');
        });
        
    }
}

var member_register ={
    load:function(){
        $("#haveAccount").click(function(){
            isilFocus.focus('#login_usr_login');
            jQuery(document).trigger("close.facebox");
            $('#loginBlock').slideDown("normal");
        });
        $("#actionVerifyLogin").click(function(){
            $("#actionVerifyLogin").removeAttr('class');
            $("#actionVerifyLogin").addClass('lnkWait');
            $.ajax({
                type: "get",
                url: urlRoot+"member/account/checklogin/?register_usr_login="+$("#register_usr_login").val(),
                dataType: "json",
                error: function(){ ajaxError(); },
                success: function(response){
                    $("#actionVerifyLogin").removeClass('lnkWait');
                    isilJson.parse(response);
                }
            });
            return false;
        });
        mobileSelectLinked.init();
        isilTooltip.standard();
        isilForm.parse();
        isilButtons();
    }
}


/**
 * Select mobile lié
 *********/ 

var mobileSelectLinked = {
    init:function(){
        $("#man_id").change(function(){
            $('#register_mob_id').children().remove(); 
            if($("#man_id").val() > 0) {
                mobileSelectLinked.unlockMobSelect(); 
                $('#register_mob_id').addClass('selectWait');
                $.ajax({
                    type: "get",
                    url: urlRoot+"default/beta/ajaxmobile/?man_id="+$("#man_id").val(),
                    dataType: "json",
                    success: function(response){
                        $('#register_mob_id').children().remove(); 
                        $.each(response, function(key, data) {
                            $('#register_mob_id').append($("<option></option>").attr("value",data.mob_id).text(data.mob_label));
                        });
                        $('#register_mob_id').removeClass('selectWait');
                    }
                });
            } else {
                mobileSelectLinked.lockMobSelect()
            } 
        });
        mobileSelectLinked.lockMobSelect();
    },
    lockMobSelect:function(){
        $('#register_mob_id').addClass('selectReadonly');
        $('#register_mob_id').children().remove();
        $('#register_mob_id').append($("<option></option>").attr("value","").text(MOBILE)); 
        $('#register_mob_id').focus(function(){
            notice.show('error',CHOOSE_MANUF);
            $('#man_id').focus();
        });    
        $('#register_mob_id').attr('readonly','readonly');
    },
    unlockMobSelect:function(){
        $('#register_mob_id').unbind('focus');
        $('#register_mob_id').removeAttr('readonly','readonly');
        $('#register_mob_id').removeClass('selectReadonly');  
    } 
}

function ajaxError(){
    notice.show("error", "Une erreur inconnue est survenue");
}

/*####### INITIALIZE COMMON BEHAVIORS #############*/
var noticeError;
var noticeOk;
var noticeAction;
var pageBlocJS;
//var urlRoot = "http://www.goomeo.com/";
var urlRoot = "http://"+window.location.hostname+"/";

$('document').ready(function(){
    // notice process
	if(noticeError) notice.show("error",noticeError);
	else if(noticeOk) notice.show("ok",noticeOk);
    else if(noticeAction)  notice.action(noticeAction);

	// init the controller/action code
	var page = document.body.id.split("__");
	for (var i = 0; i < page.length; i++) {
		try{if(eval(page[i])) eval(page[i]).load(this);}catch(e){}
	}
 
    if(pageBlocJS){
    	var func = pageBlocJS.split(",");
    	for (var i = 0; i < func.length; i++) {
    		try{if(eval(func[i])) eval(func[i])() }catch(e){}
    	}
	}
	
	// generic behaviors
	isilTooltip.standard();
	isilForm.parse();
	isilButtons();

    $('#faq dl dt a').click(function(event){
        $(this).parent().next('dd').slideToggle();
        agent = jQuery.browser;
    	if(agent.msie) {
    		event.cancelBubble = true;
    	} else {
    		event.stopPropagation();
    	}
        return false;
    });

    jQuery(document).ready(function() {
        jQuery('a[rel*=facebox],input[rel*=facebox]').facebox({faceboxHtml  : '\
            <div id="facebox" style="display:none;"><div class="popup"><table> \
            <tbody><tr><td class="tl"/><td class="b"/><td class="tr"/></tr> \
                   <tr><td class="b"/> \
                   <td class="body"> \
                        <a href="#" class="close">close</a> \
                        <div class="content"> \
                        </div> \
                      </td> \
                      <td class="b"/> \
                </tr> \
                <tr><td class="bl"/><td class="b"/><td class="br"/></tr></tbody></table></div></div>'
        }); 
    });
});