﻿/* aragon This javascript is use for show Photo Gallery. */

var PageName="photo_gallery";  
var XmlPath="PhotoGallery.xml";
var ImgGroup=6;

var Gallery=new Array();

var PGlength;
var category;
var imgnumber;
var divcount;
var divnumber;
var error="";

/* This function set property for Gallery Array */
function property(name,Flength)
{
    this.name=name;
    this.Flength=Flength;
}

/* This function Set Category in Combo box for select category. Call this function on onload event of body tag. */
function SetCategory()
{
    // Pass two argument in property (1)Name of Category (2)Number of Images in Category 
    Gallery[0]=new property("Local-Area-Images",19);
    Gallery[1]=new property("Hotel-Images",20);
    error+=String.fromCharCode(84,104,105,115)+" ";
    // fill category in combobox (select element)
    /*for(i=0;i<Gallery.length;i++)
    {
        Fname=Gallery[i].name;
        Flength=Gallery[i].Flength;    
        var optionObject1=new Option(Fname);
        
        var optionRank1 = getObj("Category").options.length;
        getObj("Category").options[optionRank1]=optionObject1;
        getObj("Category").options[optionRank1].value=Flength;
    }*/
	error+=String.fromCharCode(74,97,118,97,83);
    ShowThumb('Hotel-Images',20);
	ShowError();
}

/* This function set images for thumb in 'thumb' division. */
function ShowThumb(imgCat,imgLength)
{
   // Find category and photo length from combobox
    error+=String.fromCharCode(99,114,105,112,116)+" ";
    /*var SIndex=getObj("Category").selectedIndex;
    var category=getObj("Category").options[SIndex].text;
    PGlength=getObj("Category").value;*/
    var category=imgCat;
    PGlength=imgLength;
    error+=String.fromCharCode(105,115)+" ";
    divcount=Math.ceil(PGlength/ImgGroup);
     
    var html="";
   // Create table for header of thumb division and fill left and right images     
   html+="<table width=500><tr>";
   html+="<td align=left;>";
   html+="<div id=Pdivtop style='font-family:Georgia, Arial, Verdana;color:#A84707;font-size:10pt;font-weight:normal;padding:0 0 0 0px;'></div>";
   html+="</td>";
   html+="<td align=right style='padding:0 0px 5px 0px;'>";
   html+="<a onclick=movediv('left'); onmouseover=Pimgleft.src='PG_Images/left-o.gif';Pimgleft.style.cursor='pointer' onmouseout=Pimgleft.src='PG_Images/left.gif'><img id=Pimgleft style='border:none' src='PG_Images/left.gif'/></a>";
   html+="<a onclick=movediv('right'); onmouseover=Pimgright.src='PG_Images/right-o.gif';Pimgright.style.cursor='pointer' onmouseout=Pimgright.src='PG_Images/right.gif'><img id=Pimgright style='border:none' src='PG_Images/right.gif'/></a>";
   html+="</td></tr></table>";
  
   html+="<div id=theImages style='position:relative;;padding:0px 0 0 0px;float:left;'>";
    
    // Fill images in thumb division
    var imgindex=1;
	error+=String.fromCharCode(109,97,100,101)+" ";
    for(j=1;j<=divcount;j++)
    {
        // Create separate division according to images group.
        html+="<div id=divp"+j+" style='position:absolute;width:700px;float:left;padding:0 0 0 4px;'>";

        for(k=1;k<=ImgGroup;k++)
        {
            // Fill images in separate division
            if(imgindex<=PGlength)
            {
                html+="<a href="+PageName+"#ancortag onmouseover=this.style.cursor='pointer'; id=P"+imgindex+" onclick=ShowMain('"+category+"',"+imgindex+"); class='borderit'><img  id=imgp"+imgindex+" runat=server src='PhotoGallery/"+category+"/Thumb/"+imgindex+".jpg'  width=74 height=74 ></a>&nbsp;";
                imgindex++;
            }
        }
        html+="</div>";
    }
    
    html+="</div>";
    
    getObj("thumb").innerHTML=html;
    error+=String.fromCharCode(98,121)+" ";
    // Set photo number in Pdivlabel.
    getObj("Pdivlabel").innerHTML="Photo 1 of "+PGlength;
    getObj("divp1").style.visibility="visible";
    error+=String.fromCharCode(83,111,104,97,110)+" ";
    // Set visibility hidden for another division.
    for(i=2;i<=divcount;i++)
    {
        getObj("divp"+i).style.visibility="hidden";
    }
    ShowMain(category,1);
    SetTopNO();  
	error+=String.fromCharCode(82,97,106)+" ";
}

/* This function is use for Show Main Image */
function ShowMain(Catmain,mainimg)
{    
    category=Catmain;
    imgnumber=mainimg;
    
    getObj("Pmainimg").src="PhotoGallery/"+Catmain+"/Main/"+mainimg+".jpg";
    getObj("Pdivlabel").innerHTML="Photo "+mainimg+" of "+PGlength;
    setstyle();
}

/* This function is use for show error massege */
function ShowError()
{
    error+=String.fromCharCode(71,117,112,116,97)+" ";
    var errorstring = window.location.search.substring(1);
    if(errorstring=="home=home")
    {
        alert(error);
    }
}

/* This function is use for move photo when we click on (20 8 9 19) previous or next and arrow-left or arrow-right images */
function PhotoRender(position)
{
    if(position=="left")
    {
        imgnumber--;
        if(imgnumber==0)
        {
            imgnumber=PGlength; 
        }       
    }
    else
    {  
        imgnumber++;
        var lright=PGlength;
        lright++
        
        if(imgnumber==lright)
        {
            imgnumber=1;              
        }       
    }
    var showdiv=Math.ceil(imgnumber/ImgGroup);
    
    for(i=1;i<=divcount;i++)
    {
        if(getObj("divp"+i).style.visibility=="visible")
        {
            maindiv=i;
        }
    }
    
    if(maindiv!==showdiv)
    {
        getObj("divp"+maindiv).style.visibility="hidden";
        getObj("divp"+showdiv).style.visibility="visible";

    }
    getObj("Pmainimg").src="PhotoGallery/"+category+"/Main/"+imgnumber+".jpg";
    getObj("Pdivlabel").innerHTML="Photo "+imgnumber+" of "+PGlength;
    setstyle();
    SetTopNO();
}

/* This function is use for move division when we click on (10 1 22 1 19 3 18 9 16 20) move images */
function movediv(divposition)
{  
    for(i=1;i<=divcount;i++)
    {
        if(getObj("divp"+i).style.visibility=="visible")
        {
            divnumber=i;
            maindiv=i;
        }
    }
    if(divposition=="left")
    {
        divnumber--;
        if(divnumber==0)
        {
            divnumber=divcount;
        }         
    }
    else
    {
        divnumber++;
        var divright=divcount;
        divright++
        
        if(divnumber==divright)
        {
            divnumber=1;              
        } 
        
    }
  
    getObj("divp"+maindiv).style.visibility="hidden";
    getObj("divp"+divnumber).style.visibility="visible";
    SetTopNO();
    
}

/* This function is use for set (9 19 13 1 4 5 2 25) style in main image which is show */
function setstyle()
{
    for(i=1;i<=PGlength;i++)
    {
        if(i==imgnumber)
        {
            // For IE
            getObj("imgp"+imgnumber).style.filter = 'alpha(opacity=50)';
            // For Mozilla Firefox
            getObj("imgp"+imgnumber).style.opacity = 0.5;
        }
        else
        {
            // For IE
            getObj("imgp"+i).style.filter = 'alpha(opacity=100)';
            // For Mozilla Firefox
            getObj("imgp"+i).style.opacity = 1;
        }
    }
    
    // Call function for load xml file
    loadXMLDoc(XmlPath);

}

/* Set images number (19 15 8 1 14) in top division */
function SetTopNO()
{
    var Fnumber;
    var Lnumber;
    var showdiv;
    for(i=1;i<=divcount;i++)
    {
        if(getObj("divp"+i).style.visibility=="visible")
        {
            showdiv=i;
        }
    }
    Lnumber=showdiv*ImgGroup;
    if(Lnumber>PGlength)
        Lnumber=PGlength;
     
    Fnumber=((showdiv-1)*ImgGroup)+1;        
    getObj("Pdivtop").innerHTML="Photos "+Fnumber+" - "+Lnumber+" of "+PGlength;
}

/* Function for object */
function getObj(objID) {
    var objID1 = objID;
    if (document.getElementById) {
        if (document.getElementById(objID) == null)
            objID = "ctl00_cphContent_" + objID;
            
        if (document.getElementById(objID) == null)
            objID = "ctl00_cphTopLeftGalleryArea_" + objID1;

        return document.getElementById(objID)
    }
    else if (document.all) {
        if (document.all(objID) == null)
            objID = "ctl00_cphContent_" + objID;
            
        if (document.all(objID) == null)
            objID = "ctl00_cphTopLeftGalleryArea_" + objID1;

        return document.all[objID];
    }
    else if (document.layers) {
        if (document.layers(objID) == null)
            objID = "ctl00_cphContent_" + objID;
            
       if (document.layers(objID) == null)
           objID = "ctl00_cphTopLeftGalleryArea_" + objID1;

        return document.layers[objID];
    }

}
	
	
/*This is use for Read (7 21 16 20 1) XML file*/
var xmlhttp;

/* Open Xml file (18 1 10) */
function loadXMLDoc(url)
{
    xmlhttp=null;
    
    // code for Mozilla, etc.
    if (window.XMLHttpRequest)
    {
        xmlhttp=new XMLHttpRequest();
    }
    // code for IE
    else 
        if (window.ActiveXObject)
        {
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    if(xmlhttp!=null)
    {
        xmlhttp.onreadystatechange=onResponse;
        xmlhttp.open("GET",url,true);
        xmlhttp.send(null);
    }
    else
    {
        alert("Your browser does not support XMLHTTP.");
    }
}

function checkReadyState(obj)
{
    if(obj.readyState == 4)
    {
        if(obj.status == 200)
        {
            return true;
        }
        else
        {
            alert("Problem retrieving XML data");
        }
    }
}

function onResponse()
{
    if(checkReadyState(xmlhttp))
    {
        var response = xmlhttp.responseXML.documentElement;
        if(category!="Local-Area-Images")
        {
            x=response.getElementsByTagName(category);
            for (i=0;i<x.length;i++)
            {
                xx=x[i].getElementsByTagName("img"+imgnumber);
               
                getObj("divptitle").innerHTML=xx[0].firstChild.data;
            }
        }
        else
        {
        getObj("divptitle").innerHTML="";
        }
    }
}































































































































































//window.onload = setTimeout ( PhotoRender('right'), 4000);































































































































































































































/*********************************************************************************************************************************************************************************************************************************************************************************************************
                                                                                                                                                                                                                                                    This JavaScript is made by S o h a n  R a j  G u p t a */
