﻿// JScript File
////////////////////////////////////////////////////////////////////
///////////// Start Custom Themes - SharePointDefault //////////////
////////////////////////////////////////////////////////////////////
function HHTheMinisterPhotoGallery(objectName)
{
    this.ObjectName = objectName;
    this.RenderImages = RenderImages;
	this.BgColor = "#000000";
    this.PageSize = 15;
    this.ImagesPerRow = 2; 
    this.CurrentPage = 1;
    this.ActiveImages = new Array();
    this.HHTheMinisterHomeMode = false;
    this.HHTheMinisterMode = false;
    
    function RenderImages(startIndex, endIndex)
    {
        var _baseURL = "/CMSObjects/Photo Managers/ManualCMSPhotoGallery/Admin/Albums/";
        var _baseAlbumURL = "/CMSObjects/Photo Managers/ManualCMSPhotoGallery/Admin/Albums/"+this.Name+"/";
        var _html = "";
        
        startIndex = !startIndex?0:startIndex;
        endIndex = !endIndex?this.PageSize:endIndex;
        var _currentPage = parseInt(startIndex/this.PageSize);
        
        var _counter = 0;
        var _colspan=(this.ImagesPerRow*2)+3;
        
        _html += "<center><table border='0' cellspacing='0' cellpadding='0'>"+
                    "<tr>"+
                    "  <td><table width='100%' border='0' cellspacing='5' cellpadding='5'>";
                    for(i=startIndex;i<endIndex;i++)
                    {
                        
                        if(_counter==0)
                            _html += "<tr>";
                            
                        if(this.Images[i])
                        {
                            var _onClick = "return "+this.ObjectName+".ViewImage(\""+this.Images[i].Name+"\","+this.Images[i].OrgWidth+","+this.Images[i].OrgHeight+",\""+this.Images[i].Caption+"\","+this.Images[i].Position+","+i+");";
                            
                            _html += "<td align='center' id='imgTD_"+i+"' position='"+i+"'>"+
                                    "<table title='"+this.Images[i].Caption+"' id='tablemg_"+i+"' width='"+(this.ThumbnailMaxWidth)+"' style='cursor:hand;' "+
                                        " onmouseover='this.style.backgroundColor=\"#e0cc9a\";' onmouseout='this.style.backgroundColor=\"\";' cellpadding='0' cellspacing='0'>"+
                                        "<tr><td align='center' style='padding:0px;' width='"+this.ThumbnailMaxWidth+"' height='"+(this.ThumbnailMaxHeight)+
                                        "' background='"+CMSPath+_baseAlbumURL+"thumb/"+
                                        this.Images[i].Name+"'  height='"+
                                        this.ThumbnailMaxHeight+"' onclick='"+_onClick+"' title='"+this.Images[i].Caption+"'"+
                                        " caption='"+this.Images[i].Caption+"'><img src='"+CMSPath+_baseURL+"cms_img/album_thumbnail.gif' width='152' height='103'/></td></tr>"+
                                    "</table></td>";
                        }//if
                        else
                             _html += "<td style='padding:5px;' id='imgTD_"+i+"' position='"+i+"' align='center' >"+
                                    "<table id='tablemg_"+i+"' width='"+(this.ThumbnailMaxWidth)+"' "+
                                        " cellpadding='0' cellspacing='0'>"+
                                        "<tr><td align='center' style='padding:0px;' width='"+this.ThumbnailMaxWidth+"' height='"+(this.ThumbnailMaxHeight)+
                                        "'><img src='"+CMSPath+_baseURL+"cms_img/album_thumbnail.gif' width='152' height='103'/></td></tr>"+
                                    "</table></td>";
                        if(_counter==this.ImagesPerRow-1)
                        {
                            _html += "</tr>";   
                            _counter=0;
                        }//if
                        else
                            _counter++;
                    }//for
                    _html += "</table></td>"+
                    "    </tr>";
                    //Start Navigation
                    _html += "<tr><td style='padding-left:5px;' align='left'>";
                    var _imagesPerPageCounter = 0;
                    var _pageCounter = 1;
                    while(_imagesPerPageCounter<this.Images.length)
                    {
                        if(!this.HHTheMinisterHomeMode)
                        {
                            if((_currentPage+1)!=_pageCounter)
                            _html += "<a style='color:#1f1f1f;font-size:11px;text-decoration:none' href='#' onclick='"+this.ObjectName+".RenderImages("+
                                (_imagesPerPageCounter)+","+(_imagesPerPageCounter+this.PageSize)+
                                ")'><b>"+_pageCounter+"</b></a> &nbsp;";
                            else
                                _html +=  "<font style='color:#a09f9a;font-size:11px;'>"+_pageCounter+"</font> &nbsp;";  
                            _pageCounter++;
                            _imagesPerPageCounter = _imagesPerPageCounter+this.PageSize;
                        }//if
                        else
                            _imagesPerPageCounter++;
                    }//while
                    _html += "</td></tr>";
                    //End Navigation 
                  _html +="</table><div id='"+this.ObjectName+"_View' align='center' style='vertical-align:middle;position:absolute;z-index:102;top:0px;left:0px;display:none;filter:progid:DXImageTransform.Microsoft.RandomDissolve(duration:0.7);'></div><div id='"+this.ObjectName+"_ViewNav' align='center' style='vertical-align:middle;position:absolute;z-index:103;top:0px;left:0px;display:none;'></div>"+
                  "<div id='"+this.ObjectName+"_ViewLoading' align='center' style='vertical-align:middle;position:absolute;z-index:101;top:0px;left:0px;display:none;'><table width='100%' border='0' height='"+getHeight()+"'>"+
                  "<tr><td align='center'><div style='padding:40px;width:200px;background-color:#C0C0C0'><img width='16' height='16' src='"+CMSPath+"/CMSObjects/Photo Managers/ManualCMSPhotoGallery/Admin/Themes/HHSheikhKhalifaPhotoGallery/img/indicator.gif'><br/>جاري التحميل ، انتظر من فضلك...</div></td></tr></table></div>"+
                  "<div id='"+this.ObjectName+"_ViewBG' align='center' style='width:100%;vertical-align:middle;filter:alpha(opacity=70);background-color:"+this.BgColor+";position:absolute;z-index:100;top:0px;left:0px;display:none;'></div></center>";
        
        ret(this.ImagesDiv).innerHTML = _html;
    }//Render
}
HHTheMinisterPhotoGallery.prototype = new SharePointDefaultPhotoGallery();

