﻿// JScript File
//Globals
    var slidShowTimeOut=5000;
    var CrossFadeDuration=1.5;
    var slidShowID;
     
    
    function openpresention(img,i)
    {
        //-------------------- Set Divs in Position -----------------//
        
        //detect window size
        var w=screen.width*1-22;
        var h=screen.height*1+280;
        
        var myReference=document.getElementById("divTrancpertPic").style;
        
        myReference.display="block";
        var noPx = document.childNodes ? 'px' : 0;
        myReference.width = w + noPx;
        myReference.pixelWidth = w;
        myReference.height = h + noPx;
        myReference.pixelHeight = h;
        
        //set - divViewer
        myReference=document.getElementById("divViewer").style;
        myReference.display="block";
        var noPx = document.childNodes ? 'px' : 0;
        var offset=document.getElementById("divViewer").offsetWidth*1;
        myReference.left = ((w*1)-(offset*1))/2 + noPx;
        myReference.top = "40" + noPx;
        //-----------------------------------------------------------//
        
        //-------------------- Set Starting Image -----------------//
        var Newsrc= new String(img.src);
        //alert(Newsrc);
        if (i==1)
        {
            Newsrc=Newsrc.replace("169x127", "639x480"); 
        }
        else
        {
            Newsrc=Newsrc.replace("171x128", "639x480");
        }
        Newsrc=Newsrc.replace("Thumb", ""); 
        
        
        //alert(Newsrc);
        document.getElementById("MainImage").src=Newsrc;
        //-----------------------------------------------------------//
        
        //--------------------Set Location Image --------------------//
        var index=WhereFound();
        document.getElementById('NumPic').innerHTML="Image " + (index+1) + " of " + maxlen;
        //-----------------------------------------------------------//
    }
        
        //---------------------function to close windows------------//
    function Close()
    {
        document.getElementById('divTrancpertPic').style.display = "none";
        document.getElementById('divViewer').style.display = "none";
        
        clearInterval(slidShowID);
    }
        //-----------------------------------------------------------//
        
       //-----------------------functions to slide--------------------//
    function Next()
    {
        var index;
        index=WhereFound();
        
        document.images.MainImage.style.filter="blendTrans(duration="+CrossFadeDuration+")";
        document.images.MainImage.filters.blendTrans.Apply();
        
        
        if (index<maxlen)
	    {   
	        index++;
	        document.getElementById('MainImage').src=Images[index];
	        document.getElementById('NumPic').innerHTML="Image " + (index+1) + " of " + maxlen;

	    }
	    if (index==maxlen)
	    {
	        index=0;
	        document.getElementById('MainImage').src=Images[index];
	        document.getElementById('NumPic').innerHTML="Image " + (index+1) + " of " + maxlen;
	    }
	    document.images.MainImage.filters.blendTrans.Play();
    }
    
    function Previous()
    {
        var index;
        index=WhereFound();
        
        document.images.MainImage.style.filter="blendTrans(duration="+CrossFadeDuration+")";
        document.images.MainImage.filters.blendTrans.Apply();
        if (index<maxlen)
	    {   
	        index--;
	        document.getElementById('MainImage').src=Images[index];
	        document.getElementById('NumPic').innerHTML="Image " + (index+1) + " of " + maxlen;
	    }
	    if (index<0)
	    {
	        index=maxlen-1;
	        document.getElementById('MainImage').src=Images[index];
	        document.getElementById('NumPic').innerHTML="Image " + (index+1) + " of " + maxlen;
	    }
	    document.images.MainImage.filters.blendTrans.Play();
    }
    
    function WhereFound()
    {
        var found=0;
        var x=document.getElementById('MainImage').src;
        
        x=x.substr(x.indexOf("images"));
        //alert(x);
        //x=x.replace("http://localhost/in-dot/" ,"");
        
        for (var i=0; i<maxlen; i++)
        {
            if (x==Images[i])
            {
                found=i;
                break;
            }
        }
        return found;
    } 
        //-----------------------------------------------------------//
        
        //-----------------------functions to run image--------------------//
     
     function RunImages()
     {
        clearInterval(slidShowID);
        slidShowID=setInterval("Next()", slidShowTimeOut); 
     }
    

