﻿//var _loginName = '';
//var _albumCode = '';

window.onload = function(){
    hideIndicator();
}

function showIndicatorImage(loginName, albumCode) {
    document.getElementById("divImageMain__" + loginName + "__" + albumCode).style.display = "none";
    document.getElementById("divIndicatorImage__" + loginName + "__" + albumCode).style.display = "";
}
 
function hideIndicatorImage(loginName, albumCode) {
    document.getElementById("divIndicatorImage__" + loginName + "__" + albumCode).style.display = "none";
    document.getElementById("divImageMain__" + loginName + "__" + albumCode).style.display = "";
}

function doSetPicture(loginName, albumCode, albumRef) {
    //alert('a');
//    _loginName = loginName;
//    _albumCode = albumCode;
    
    showIndicatorImage(loginName, albumCode);
    WCFAlbum.JSON_getTrMemberAlbumDetailPerLogin(loginName, albumCode, albumRef, doSetPictureOnComplete, doSetPictureOnError);
}

function doSetPictureOnComplete(result) {
    result = eval(result);
    
    var loginName = MyURLDecode(result[0].loginName);
    var albumCode = MyURLDecode(result[0].albumCode);
    var albumRef  = MyURLDecode(result[0].albumRef);
    var imgNo = MyURLDecode(result[0].imgNo);
    var total = MyURLDecode(result[0].total);
    var desc = MyURLDecode(result[0].desc);
    var prevRef =  MyURLDecode(result[0].prevRef);
    var nextRef =  MyURLDecode(result[0].nextRef);
    var id = 'imgMain__' + loginName + '__' + albumCode;
    document.getElementById(id).src = _rootPathDot + 'support/gambar.album/P/' + albumCode + '/' + albumRef + '/0/0/' + loginName;
    if (MyURLDecode(result[0].prevRef) != 0) {
        document.getElementById("divPrevButton__" + loginName + "__" + albumCode).innerHTML="<div align=\"left\"><a href=\"javascript:doSetPicture(\'" + loginName + "\',\'" + albumCode + "\'," + prevRef + ");\"><img border='0' src=\"" + _rootPathDot + "themes/default/images/member/button_kk_prev.gif\" width=\"67\" height=\"18\" id=\"imgPrev\" onmouseover=\"MM_swapImage('imgPrev','','" + _rootPathDot + "themes/default/images/member/button_kk_prev_on.gif',1)\" onmouseout=\"MM_swapImgRestore()\" /></a></div>";
    } else {
        document.getElementById("divPrevButton__" + loginName + "__" + albumCode).innerHTML = "";
    }
    if (MyURLDecode(result[0].nextRef) != 0) {
        document.getElementById("divNextButton__" + loginName + "__" + albumCode).innerHTML = "<div align=\"right\"><a href=\"javascript:doSetPicture(\'" + loginName + "\',\'" + albumCode + "\'," + nextRef + ");\"><img border='0' src=\"" + _rootPathDot + "themes/default/images/member/button_kk_next.gif\" width=\"67\" height=\"18\" id=\"imgNext\" onmouseover=\"MM_swapImage('imgNext','','" + _rootPathDot + "themes/default/images/member/button_kk_next_on.gif',1)\" onmouseout=\"MM_swapImgRestore()\" /></a></div>";
    } else {
        document.getElementById("divNextButton__" + loginName + "__" + albumCode).innerHTML = "";
    }
    
    document.getElementById("divFotoNo__" + loginName + "__" + albumCode).innerHTML = "Foto " + imgNo + " dari " + total;
//    if(desc==''){
//        if(document.getElementById('divKeterangan')!='undefined'){
//            document.getElementById('divKeterangan').style.display = 'none';
//        }
//    }else{
//        if(document.getElementById('divKeterangan')!='undefined'){
//            document.getElementById('divKeterangan').style.display = '';
//        }
//    }
    document.getElementById("divKeterangan__" + loginName + "__" + albumCode).innerHTML = desc;
    
}

function doSetPictureOnError(result) {
    //alert(result.get_message()); 
}
