﻿// *******************************
// Profile Library
// 1.0.0
// (C) 2008 DG2
// *******************************

// *******************************
// plSpice
// *******************************
function plSpice(strGUID, blnOn) {
   
    if (blnOn == 1) {
        $get('pageContent_UcTabMenu_ShowLayout').style.display = 'none';
        $get('pageContent_UcTabMenu_HideLayout').style.display = 'inline';
        $get('mShellSpice').href = $get('mShellSpice').href.replace(/templatedisable/,'template');
        $request('NonVisiblePopDiv','/apps/api/profile/6/','ID='+strGUID+'&Spiced=true');
    }
    
    else { 
        $get('pageContent_UcTabMenu_ShowLayout').style.display = 'inline';
        $get('pageContent_UcTabMenu_HideLayout').style.display = 'none';
        $get('mShellSpice').href = $get('mShellSpice').href.replace(/template/,'templatedisable');
        $request('NonVisiblePopDiv','/apps/api/profile/6/','ID='+strGUID+'&Spiced=false');
    }

}

// *******************************
// plPhotoCommentSave
// *******************************
function plPhotoCommentSave(strGUID, strPictureGUID, strFckName) {

    var strRating = '0';
    
    if (document.forms[0].Rating) {
        for(i = 0; i < document.forms[0].Rating.length; i++){
            if(document.forms[0].Rating[i].checked){
            strRating = document.forms[0].Rating[i].value;
            break;
            }
        }
    }
    
    var oEditor = FCKeditorAPI.GetInstance(strFckName);      
    var strValue = oEditor.GetHTML();

    if (strValue == null) return;
    if (strValue.length == 0) return;
    
    $request('mDialogResponsePH', '/apps/api/popup/11/', '&ID='+strGUID+'&PictureGUID='+strPictureGUID+'&Value='+Url.encode(strValue)+'&Rating='+strRating);

}

// *******************************
// plStatusView
// *******************************
function plStatusView(obj) {

    $get('pbStatus0').style.display = 'none';
    $get('pbStatus1').style.display = 'none'; $get('pbStatus2').style.display = 'none'; $get('pbStatus3').style.display = 'none'; $get('pbStatus4').style.display = 'none';
    $get('pbStatus5').style.display = 'none'; $get('pbStatus6').style.display = 'none'; $get('pbStatus7').style.display = 'none'; $get('pbStatus8').style.display = 'none';
    $get('pbStatus9').style.display = 'none'; $get('pbStatus10').style.display = 'none'; $get('pbStatus11').style.display = 'none'; $get('pbStatus12').style.display = 'none';
    
    $get(obj).style.display = 'block';
    
}

// *******************************
// plContactsSearch
// *******************************
var plSearchFieldObj;
var plSearchVars;
var plSearchOldQuery = 'none';

function plContactsSearch(inputobj, vars) {
    plSearchFieldObj = inputobj;
    plSearchVars = vars;
    
    if (plSearchFieldObj.value.length >= 2) {
        if (plSearchFieldObj.value != plSearchOldQuery) {
            plSearchOldQuery = plSearchFieldObj.value;
            plContactsSearchDoRefresh();
        }
    }
    
    else if (plSearchFieldObj.value.length == 0) {
        $request('pageContent_Buddies', '/apps/api/profile/1/', plSearchVars, false);
    }
    
}

// *******************************
// plBuddiesSearchDoRefresh
// *******************************
function plContactsSearchDoRefresh() {
    if (!$requestrunning()) {
        $request('pageContent_Buddies', '/apps/api/profile/1/', 'Query='+Url.encode(plSearchFieldObj.value)+'&'+plSearchVars+'&Type='+$("input[@name='DgMAX$pageContent$ContactListType']:checked").val(), false);
    }
    else { 
        setTimeout("plBuddiesSearchDoRefresh()",500);
    }
}

// *******************************
// plBuddiesFilter
// *******************************
function plContactsFilter(vars) {
    $get('pageContent_Buddies').innerHTML = 'Laden...';
    vars += '&Type='+$("input[@name='DgMAX$pageContent$ContactListType']:checked").val()
    $request('pageContent_Buddies', '/apps/api/profile/1/', vars, 1, 1);
}

// *******************************
// plJokersSet
// *******************************
var plTypeS;

function plJokersSet(obj, jType) {
    
    plTypeS = jType;
    if ($get('pageContent_Jokers1')) { $get('pageContent_Jokers1').className = 'Button'; }
    if ($get('pageContent_Jokers2')) { $get('pageContent_Jokers2').className = 'Button'; }
    if ($get('pageContent_Jokers3')) { $get('pageContent_Jokers3').className = 'Button'; }
    if ($get('pageContent_NoJokersPH')) { $get('pageContent_NoJokersPH').style.display = 'none'; }
    
    obj.className = 'ButtonBlue';
    $get('pageContent_JokersPH').style.display = 'block';
    
}

// *******************************
// plJokersSend
// *******************************
function plJokersSend(strNickName, strUserNickName, strUserGUID) {
    
    $get('MarkUpPH').style.display = 'none';

    var strM;
       
    if ($get('JokerMessage').innerHTML.length == 0) { 
        strM = $get('JokerMessage').value; 
    }
    
    else { 
        strM = $get('JokerMessage').innerHTML; 
    }

    $get('pageContent_JokersPH').style.height = 'auto';
    $get('pageContent_JokersPH').innerHTML = '<div class="LineHeight">Even wachten...</div>';
    $request('pageContent_JokersPH', '/apps/api/profile/5/', 'ID='+strUserGUID+'&JokerType='+plTypeS+'&JokerMsg='+Url.encode(strM)+'&UserNickName='+strUserNickName+'&NickName='+strNickName);
    
}

// *******************************
// plPollVote
// *******************************
function plPollVote(strNickName, strUserNickName, strUserGUID, intAnswer) {

    $request('pageContent_Poll', '/apps/api/profile/4/', 'NickName='+strNickName+'&UserNickName='+strUserNickName+'&UserGUID='+strUserGUID+'&Answer='+intAnswer);

}
