$(document).ready(function() {

    $("a[href*=#employment]").click(function() { 
       $('#gotoEmploi').submit();
	   return false;
    });
    
    try{
        $("select").select_skin();
    }catch(e){
        if(window.console)console.log(e);
    }
   
    
    $('input').checkBox();
    
    $("#showOkInscrit").fancybox({
        'padding' : 10,
        'titlePosition'     : 'inside',
        'transitionIn'      : 'none',
        'transitionOut'     : 'none', 
        'centerOnScroll'    : true,
        'showCloseButton'   : false
    });
    $("#showOkInscritAnnuaire").fancybox({
        'padding' : 10,
        'titlePosition'     : 'inside',
        'transitionIn'      : 'none',
        'transitionOut'     : 'none', 
        'centerOnScroll'    : true,
        'showCloseButton'   : false
    });
    
    $("a[href*=#blocked]").fancybox({
        'padding' : 0,
        'titlePosition'     : 'inside',
        'transitionIn'      : 'none',
        'transitionOut'     : 'none', 
        'centerOnScroll'    : true,
        'hideOnOverlayClick': false,
        'showCloseButton'   : false
    });
    
    
    $("a[href*=#multimedia]").fancybox({
        'padding' : 0,
        'titlePosition'     : 'inside',
        'transitionIn'      : 'none',
        'transitionOut'     : 'none', 
        'centerOnScroll'    : true,
        'hideOnOverlayClick': true,
        'autoDimensions'	: false,
        'autoScale'	        : false,
        'showCloseButton'   : false
    });
    
    
    
    $('a[href*=#blocked]').click(function() {  
         $(this).show().delay(2000).queue(function() {
            $.fancybox.close();
            $(this).dequeue();
         });
        return false;
    });
    
    $('.blocked').click(function() {  
         $(this).show().delay(2000).queue(function() {
            $.fancybox.close();
            $(this).dequeue();
         });
        return false;
    });
    
    $('a[href*=#closeFancy]').click(function() { 
        parent.$.fancybox.close();
        $.fancybox.close();
        return false;
    });
    
   
    
    $('#cancelFancy, a[href*=#cancelFancy]').click(function() { 
        parent.$.fancybox.cancel();
        $.fancybox.cancel();
        return false;
    });
    
    var need_log = "";
    need_log = getUrlVars()["need_log"];
    var need_rights = "";
    need_rights = getUrlVars()["need_rights"];
    
    var show_registred = "";
    show_registred = getUrlVars()["show_registred"];
    
    /*if(need_log == 1 || need_rights == 1){
        $("#autoDisplayLogAlert").click();
    }
    */
    if (need_rights == 1){
        $("#autoDisplayLogAlert").click();
    }
    if(show_registred == 1){
        $("#showOkInscrit").click();
    }
    if(show_registred == 2){
        $("#showOkInscritAnnuaire").click();
    }
});

function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}
