﻿window.onload = function () {
    hideIndicator();
}

function bindAlbum(albumCategory,currentIndex){
    _idxAG = currentIndex;
    showIndicatorAlbum();
   WCFOthers.JSON_albumGadis(albumCategory, albumGadisReturn);
}

        function albumGadisReturn(json){
        currentIndex = _idxAG;
        var html = '';
        var data;
        var _pageNo = '12';

            eval("data = " + json);
            if (data.Data.length > 0){
            for(var i=0;i<data.Data.length;i++){
                if(i >= (_pageNo*currentIndex) - _pageNo && i < (_pageNo*currentIndex)){
                    if (i % 4 == 0){
                         html += "  <div class='albumGadisAlbum'>"
                         }
					     html += " 			<div class='albumGadisThumb'><a href='" + _rootPath + "/gallery/" + converStrToParam(MyURLDecode(data.Data[i].albumCategoryName)) + "'><img src='" + _rootPath + "/images/albumgadis/" + data.Data[i].albumCode + "/" + data.Data[i].albumRef + "/" +  data.Data[i].ref + "/T' width='80' height='80' alt='Album Gadis " + data.Data[i].albumCategoryName + "&nbsp;" + data.Data[i].screenName + "' border='0'></a><br></div>"
				    if (i % 4 == 3){
					     html += " 	</div>"
                        }
                 }
            }
        document.getElementById("boxAlbum").innerHTML = html;
        var total = Math.ceil( data.Data.length / _pageNo);
        prevNext(currentIndex,total);
        }else{
             document.getElementById("albmGadis").style.display='none';

        }
        }
        
        
function prevNext(currentIndex,total){
    var next;
    var prev;
    var _pageNo = '12';
    var aCG = albumCategory;
    prev = currentIndex - 1;
    if(currentIndex - 1 < 1) {prev = total;}
    currentIndex = currentIndex * 1;
    next = currentIndex +1;

    if(currentIndex + 1 > total) {next = 1;}
  

    
    document.getElementById('idPrev').innerHTML = "<a href='javascript:bindAlbum("+aCG+", "+prev+")' class='aalbum'>Prev</a>"
    document.getElementById('idNext').innerHTML = "<a href='javascript:bindAlbum("+aCG+", "+next+")' class='aalbum'>Next</a>"


}


function showIndicatorAlbum() {    
   var html = '';
     html += "<div class='albumGadisAlbum'>"
        html += "<div style='padding:31px;margin:0 10px 0 0;float:left;border:solid 1px gray;'><img src='" + _rootPath + "webTemplate/"+_websitestyle+"/images/ajax/loading1.gif'  alt='' border='0'><br></div>"
        html += "<div style='padding:31px;margin:0 10px 0 0;float:left;border:solid 1px gray;'><img src='" + _rootPath + "webTemplate/"+_websitestyle+"/images/ajax/loading1.gif'  alt='' border='0'><br></div>"
        html += "<div style='padding:31px;margin:0 10px 0 0;float:left;border:solid 1px gray;'><img src='" + _rootPath + "webTemplate/"+_websitestyle+"/images/ajax/loading1.gif'  alt='' border='0'><br></div>"
        html += "<div style='padding:31px;margin:0 10px 0 0;float:left;border:solid 1px gray;'><img src='" + _rootPath + "webTemplate/"+_websitestyle+"/images/ajax/loading1.gif'  alt='' border='0'><br></div>"
     html += "</div>"
     html += "<div class='albumGadisAlbum'>"
        html += "<div style='padding:31px;margin:0 10px 0 0;float:left;border:solid 1px gray;'><img src='" + _rootPath + "webTemplate/"+_websitestyle+"/images/ajax/loading1.gif'  alt='' border='0'><br></div>"
        html += "<div style='padding:31px;margin:0 10px 0 0;float:left;border:solid 1px gray;'><img src='" + _rootPath + "webTemplate/"+_websitestyle+"/images/ajax/loading1.gif'  alt='' border='0'><br></div>"
        html += "<div style='padding:31px;margin:0 10px 0 0;float:left;border:solid 1px gray;'><img src='" + _rootPath + "webTemplate/"+_websitestyle+"/images/ajax/loading1.gif'  alt='' border='0'><br></div>"
        html += "<div style='padding:31px;margin:0 10px 0 0;float:left;border:solid 1px gray;'><img src='" + _rootPath + "webTemplate/"+_websitestyle+"/images/ajax/loading1.gif'  alt='' border='0'><br></div>"
     html += "</div>"
     html += "<div class='albumGadisAlbum'>"
        html += "<div style='padding:31px;margin:0 10px 0 0;float:left;border:solid 1px gray;'><img src='" + _rootPath + "webTemplate/"+_websitestyle+"/images/ajax/loading1.gif'  alt='' border='0'><br></div>"
        html += "<div style='padding:31px;margin:0 10px 0 0;float:left;border:solid 1px gray;'><img src='" + _rootPath + "webTemplate/"+_websitestyle+"/images/ajax/loading1.gif'  alt='' border='0'><br></div>"
        html += "<div style='padding:31px;margin:0 10px 0 0;float:left;border:solid 1px gray;'><img src='" + _rootPath + "webTemplate/"+_websitestyle+"/images/ajax/loading1.gif'  alt='' border='0'><br></div>"
        html += "<div style='padding:31px;margin:0 10px 0 0;float:left;border:solid 1px gray;'><img src='" + _rootPath + "webTemplate/"+_websitestyle+"/images/ajax/loading1.gif'  alt='' border='0'><br></div>"
     html += "</div>"

   
    document.getElementById("boxAlbum").innerHTML = html;
}




