trace=function(data){
    this.document.getElementById('debug').innerHTML=data+'<br>'+this.document.getElementById('debug').innerHTML;
}
trace_comment=function(data){
    trace('<span class="comment">'+data+'</span>');
}
/**
* Writes the HTML friendlist for the selected user
*/
function writeFriendList(list){
    document.getElementById('friend_list').innerHTML='';
    trace(list.length+' amis');
    for($i=0;$i<list.length;$i++){
        trace_comment("Adding "+list[$i].name);
        document.getElementById('friend_list').innerHTML+='<a href="javascript:ExternalInterface(\'getUserInfos\',\''+list[$i]['id']+'\',\'displayUserProfile\')">'+list[$i].name+"</a><br>";
    }
    if(list.length==0){
        document.getElementById('friend_list').innerHTML='No Friends';
    }
}
/**
* Add users to the "select" html object
**/
function writeUserSelect(list){
    trace(list.length+' users to add');
    for($i=0;$i<list.length;$i++){
        trace_comment("Adding "+list[$i]);
        opt = document.createElement('Option');
        opt.text = list[$i].name!='----'?list[$i].name+"'s friends":list[$i].name;
        opt.innerText=opt.text;
        opt.value = list[$i].id;
        document.getElementById('userlist').appendChild(opt);
    }
}
/**
* Display User Infos
**/
function displayUserProfile(infos){
    html='<br>Phone : ';
    html+=infos.phone!=''?infos.phone:'No phone';
    displayPopup(infos.name,html);
}
/**
* Show & Fill the popup
**/
function displayPopup(title,content){
    $html='<h1>'+title+'</h1>';
    $html+=content;
    document.getElementById('popup_content').innerHTML=$html;
    document.getElementById('popup').style.display='block';
}
/**
* Hide User Infos
**/
function hidePopup(){
    document.getElementById('popup').style.display='none';
}
