

function ClearDefaultValue(jqueryItem){
    jqueryItem.attr('spellcheck', false);
    jqueryItem.addClass('defaultValue');
    jqueryItem.focus(function(){
        if($(this).val() == this.defaultValue){
            $(this).val('');
            $(this).removeClass('defaultValue');
            jqueryItem.removeAttr('spellcheck');
        }
    });
    jqueryItem.blur(function(){
       if($(this).val() == ''){
           $(this).val(this.defaultValue);
           $(this).addClass('defaultValue');
           jqueryItem.attr('spellcheck', false);
       } 
    });
}

function loadDetailsFanPage(idfanPage){
    $('#notificationDetails').load('/fanpage/details', {id : idfanPage}, function(){
        
        $('#newsLink').click(function(){
            $('#contentProfile').load('/fanpage/news', {idfanpage : idfanPage}, function(){
                 selectProfile();
            });
         });
        
        $('#infoLink').click(function(){
            $('#contentProfile').load('/fanpage/infos', {id : idfanPage}, function(){
                 selectProfile();
            });
         });
         
         $('#wallLink').click(function(){
            $('#contentProfile').load('/fanpage/wall', {id : idfanPage}, function(){
                 selectProfile();
            });
         });
    });

}


function loadNotificationDetails(iduser, oldCount){
    $('#notificationDetails').load('/notification/details', {id : iduser}, function(){
         $('#newsLink').click(function(){
            $('#contentProfile').load('/notification/index', {id : iduser}, function(){
                selectProfile();
            }); 
        });
        $('#friendLink').click(function(){
            $('#contentProfile').load('/user/friends', {id : iduser}, function(){
                selectProfile();
            }); 
        });
        $('#messageLink').click(function(){
            $('#contentProfile').load('/user/mailbox', {id : iduser}, function(){
                selectProfile();
            }); 
        });
        
        $('#winkLink').click(function(){
            $('#contentProfile').load('/wink/index', {id : iduser}, function(){
                selectProfile();
            });
            $.post('/notification/read', {id: iduser, type:"wink"},function(){
                loadNotificationDetails(iduser);
            });

        });
        $('#bipLink').click(function(){
            $('#contentProfile').load('/bip/index', {idUser : iduser}, function(){
                selectProfile();
            });
            $.post('/notification/read', {id: iduser, type:"bip"},function(){
                loadNotificationDetails(iduser);
            });
        });
         $('#infoLink').click(function(){
            $('#contentProfile').load('/user/info', {id : iduser}, function(){
                selectProfile();
            });
         });
         
    });

    return oldCount;
}

function selectProfile() {
    $('#tabVehicles').removeClass('tabSelected');
    $('#tabVehicles').addClass('tabBackground');
    
    $('#tabProfile').removeClass('tabBackground');
    $('#tabProfile').addClass('tabSelected');
    
    $('#contentTabVehicles').hide();
    $('#contentTabProfile').show();
}

function selectVehicles() {
    $('#tabProfile').removeClass('tabSelected');
    $('#tabProfile').addClass('tabBackground');
    
    $('#tabVehicles').removeClass('tabBackground');
    $('#tabVehicles').addClass('tabSelected');
    
    $('#contentTabProfile').hide();
    $('#contentTabVehicles').show();
}
