function showRecent(r){
    showFragment("recentUsers.jsp?rp="+r,"recent");
}
//var lastNick = null;
//function showProfilePeek(nickName){
//    lastNick = nickName;
//    AjaxRequest("GET","profilepeek.jsp?nickName="+nickName,profilePeekResult);
//}
//function profilePeekResult(){
//    if (xmlHttp.readyState==4)
//        { 
//            if(lastNick!=null){
//                var res = xmlHttp.responseText;
//                if(res.indexOf("<!--profilepeek-->")!=-1){
//                    document.getElementById("profilepeek").innerHTML= res;
//                    document.getElementById("profilepeek").style.top =(getTop(document.getElementById(lastNick))+30)+"px";
//                    document.getElementById("profilepeek").style.left =(getLeft(document.getElementById(lastNick))+20)+"px";
//                    document.getElementById("profilepeek").style.display="block";
//                    if(tId!=null){
//                        clearTimeout(tId);
//                    }
//                    tId = setTimeout ( "hideProfilePeek()", 10000);
//                }
//            }
//        }
//    }
var tId = null;
var lastId = null;
function showFriendPeek(nickName,lId){
    lastId = lId;
    AjaxRequest("GET","profilepeek.jsp?nickName="+nickName,showFriendPeekResult,null);
}
function showFriendPeekResult(){
    if (xmlHttp.readyState==4)
        { 
            if(lastId!=null){
                document.getElementById("profilepeek").innerHTML= xmlHttp.responseText;
                document.getElementById("profilepeek").style.top =(getTop(document.getElementById(lastId))+37)+"px";
                document.getElementById("profilepeek").style.left =(getLeft(document.getElementById(lastId))+25)+"px";
                document.getElementById("profilepeek").style.display="block";
                if(tId!=null){
                    clearTimeout(tId);
                }
                tId = setTimeout ( "hideProfilePeek()", 5000);
            }
        }
    }
    function hideProfilePeek(){
        document.getElementById("profilepeek").style.display="none";    
    }
    function contructProfileInfo(){
        var result ="";
        result+="&fullname="+document.getElementById('fullname').value;
        result+="&city="+document.getElementById('city').value;
        result+="&country="+document.getElementById('country').value;
        //result+="&description="+document.getElementById('description').innerHTML;
        result+="&birthday="+getBirthday();
        return result;                
    }
    function getBirthday(){
        var result = "";
        var in1 = document.getElementById("month").selectedIndex;
        var in2 = document.getElementById("day").selectedIndex;
        var in3 = document.getElementById("year").selectedIndex;
        if(!((in1==0)&&(in2==0)&&(in3==0))){
            result=document.getElementById("year")[in3].text+"/"+(in1+1)+"/"+(in2+1);
        }
        return result;
    }
    function checkProfileInfo(){
        var p = document.getElementById('description').innerHTML;
        var result = "";
        if(p.length>4095){
            result =  "Description is too long. Please limit to 4096 characters.";
        }
        return result;
    }
    function submitProfile(){
        var check = checkProfileInfo();
        if(check==""){
            showPane("POST","ProfileCenter?"+contructProfileInfo(),document.getElementById('description').innerHTML);
            uploadImage();
        }else{
        document.getElementById("gpPane").innerHTML=check;
    }
}
function uploadImage(){
    var f = document.getElementById("profileImageForm");
    var inp = document.getElementById("profileImage");
    if((f!=null)&&(inp!=null)){
        var fName = getFilename(inp.value);
        if(fName!=""){
            updateUploadMessage("Uploading "+fName+"...");
            f.setAttribute("action","UploadImage?task=uploadImage&fName="+fName);
            f.submit();
            updateUploadMessage("Uploading "+fName+"... done.");
        }
    }
}
function updateUploadMessage(message){
    document.getElementById("uploadStatus").innerHTML = message;
}

