﻿window.onload = function () {
    hideIndicator();
}

function bindPhotoComp(_albumCategoryPC){
    if (_albumCategoryPC == "00"){
        var idxPC = Math.floor(Math.random()*3);
        var acPC = albumPhotoCompetition.split(",")[idxPC];
            _albumCategoryPC = acPC;
    }
    showIndicatorPhotoComp();
    WCFOthers.JSON_PhotoCompetition(_albumCategoryPC, photoCompetitionReturn);
}

    function photoCompetitionReturn(json){
     var data;
            eval("data = " + json);
     var html = '';
     if(data.Data.length > 0){
       document.getElementById("boxPhotoComp").style.display ='';
       for(var i=0;i<data.Data.length;i++){
           html += "<div class='photoCompThumbOut'>"
           html +=    "<div class='photoCompThumb'>"
           html +=       "<a href='"+_rootPath+"/gallery/" + converStrToParam(MyURLDecode(data.Data[i].albumCategoryName)) + "'>"
           html +=         "<img src='" + _rootPath + "/images/photocompetition/" + data.Data[i].albumCode + "/" + data.Data[i].albumRef + "/" +  data.Data[i].ref + "/T' width='80' height='80' alt='photo competition " + MyURLDecode(data.Data[i].albumCategoryName) + "&nbsp;" + MyURLDecode(data.Data[i].screenName) + "' border='0'><br>"
           html +=       "</a>"
           html +=    " </div>"
           html += "</div>"
        
       
            }
             document.getElementById("divPhoto").innerHTML = html;
             document.getElementById("divNext").innerHTML = "<span style='margin-right:220px;color:#5F9F9F; font-size:12px;font-weight:bold;font-family:verdana;'>Mau ikutan ?<a href='myroom/album.kompetisi/" + _AlbumCodePCAct + "' class='aphoto'>&nbsp;Klik disini</a></span><a href='javascript:bindPhotoComp(" + data.Data[0].albumCategory + ")' class='aphotoNext'>Next &gt;&gt;</a>";
           // document.getElementById("divNext").innerHTML = "<span style='margin-right:80px;color:#5F9F9F; font-size:11px;font-weight:bold;font-family:verdana;'>Tunggu photo competition berhadiah lainnya</span><a href='javascript:bindPhotoComp(" + data.Data[0].albumCategory + ")' class='aphotoNext'>Next &gt;&gt;</a>";

          }else{
                document.getElementById("boxPhotoComp").style.display ='none';
          
          }
  
  
   }
   
function MyURLDecode (clearString) {
    var output = '';
    var huruf = new Array(" ", "\"", "#", "$", "%", "&", "+", ",", "/", ":", ";", "<", "=", ">", "?", "@", "[", "\\", "]", "^", "`", "{", "|", "}", "~", String.fromCharCode(13), String.fromCharCode(10));            
    var hurufEncode = new Array("%20", "%22", "%23", "%24", "%25", "%26", "%2b", "%2c", "%2f", "%3a", "%3b", "%3c", "%3d", "%3e", "%3f", "%40", "%5b", "%5c", "%5d", "%5e", "%60", "%7b", "%7c", "%7d", "%7e", "%0d", "%0a");
            
    for (var j = 0; j < hurufEncode.length; j++) {
        while(clearString.indexOf(hurufEncode[j]) > -1)
            clearString = clearString.replace(hurufEncode[j], huruf[j]);
    }
    output = clearString;
    return output;
}



function showIndicatorPhotoComp(){
var html = '';

html +="<div class='photoCompThumbOut'>"
	    html +="<div class='photoCompThumb'>"
		    html +="<img src='" + _rootPath + "webTemplate/"+_websitestyle+"/images/ajax/loading1.gif'  alt='' border='0'><br>"
	    html +=" </div>"
html +=" </div>"
html +="<div class='photoCompThumbOut'>"
	    html +="<div class='photoCompThumb'>"
		    html +="<img src='" + _rootPath + "webTemplate/"+_websitestyle+"/images/ajax/loading1.gif'  alt='' border='0'><br>"
	    html +=" </div>"
html +=" </div>"
html +="<div class='photoCompThumbOut'>"
	    html +="<div class='photoCompThumb'>"
		    html +="<img src='" + _rootPath + "webTemplate/"+_websitestyle+"/images/ajax/loading1.gif'  alt='' border='0'><br>"
	    html +=" </div>"
html +=" </div>"
html +="<div class='photoCompThumbOut'>"
	    html +="<div class='photoCompThumb'>"
		    html +="<img src='" + _rootPath + "webTemplate/"+_websitestyle+"/images/ajax/loading1.gif'  alt='' border='0'><br>"
	    html +=" </div>"
html +=" </div>"

    
 document.getElementById("divPhoto").innerHTML = html;


}
