function loadImage()
{
   if(ImageListlength>0)
   { 
     ShowImage();     
     return false;
   }
}
        
function GoPrevious()
{
    if(ImageListlength>0)
    {
        CurrentImage--;
        ShowButton(CurrentImage,btnNextId,btnPreviousId,ImageListlength);
        ShowLayerImage();
        ShowImage();
        return false;
    }            
}
        
function GoNext()
{
    if(ImageListlength>0)
    {
        CurrentImage++;
        ShowButton(CurrentImage,btnNextId,btnPreviousId,ImageListlength);        
        ShowLayerImage();
        ShowImage();
        return false;
    }
}

function SmallImageClick(ClickImageCurrent)
{   
    CurrentImage=ClickImageCurrent;            
    ShowImage();    
    ShowButton(CurrentImage,btnNextId,btnPreviousId,ImageListlength);
    //document.getElementById(ClickedImageId).style.border="solid 2px #F48283";    
    return false;
}

function LargeImageClick(img_layerImageId)
{       
    divwin=dhtmlwindow.open('divbox', 'div',"div_Layer_Image", "Large Image", 'width=820px,height=630px,left=0px,top=10px,resize=1,scrolling=1');      
    ShowLayerImage();
//    var LayerHeight=document.getElementById(ImgPhoto).style.height;
//    var LayerWidth=document.getElementById(ImgPhoto).style.width;    
//    LayerWidth=LayerWidth.replace('px','');
//    LayerHeight=LayerHeight.replace('px','');    
//    LayerHeight=Number((Number(LayerHeight) * 600)/225);    
//    LayerWidth=Number((Number(LayerWidth) * 800)/300);    
//    var Imagesrc=document.getElementById(ImgPhoto).src;    
//    document.getElementById(img_layerImageId).style.height=LayerHeight+"px";
//    document.getElementById(img_layerImageId).style.width=LayerWidth+"px";    
//    document.getElementById(img_layerImageId).src = Imagesrc;
//    document.getElementById(img_layerImageId).title = document.getElementById(ImgPhoto).title;    
//    ShowButton(CurrentImage,btnNextId,btnPreviousId,ImageListlength);
    return false;
}

    
function ShowButton(current,next,Previous,Total)
{   
    if(Number(current)== 0 && Number(Total)== 1)
    {   
        document.getElementById(next).style.display="none";
        document.getElementById(Previous).style.display="none";    
    }
    else if(Number(current) <= 0)
    {   
        document.getElementById(next).style.display="block";
        document.getElementById(Previous).style.display="none";
    }    
    else if(Number(current) == Number(Total-1))
    {        
        document.getElementById(next).style.display="none";
        document.getElementById(Previous).style.display="block";
    }    
    else
    {
        document.getElementById(next).style.display="block";
        document.getElementById(Previous).style.display="block";                
    }
}

function ShowImage()
{
   var Path=DefaultPath;           
   var Image_List=ImageList.split("~");      
   var Image_Height=strImageHeight.split(",");   
   var Image_Width=strImageWidth.split(",");   
   var Small_Image=SmallImageIds.split(",");
   var Small_Image_Title=strTitle.split("~");
   var IamgeName=Image_List[CurrentImage];   
   Path=Path+IamgeName;         
   document.getElementById(ImgPhoto).src=Path;   
   document.getElementById(ImgPhoto).style.width=Image_Width[CurrentImage]+"px";
   document.getElementById(ImgPhoto).style.height=Image_Height[CurrentImage]+"px";
   document.getElementById(ImgPhoto).title=Small_Image_Title[CurrentImage];
   var SmallImageId;   
   for(i=0;i<ImageListlength;i++)
   { 
     SmallImageId=document.getElementById(Small_Image[i]);     
     if(CurrentImage==i)
     {	        
        SmallImageId.className='Thumb ThumbSelected';        
     }
     else
     {  
        SmallImageId.className='Thumb ThumbMargin';        
     }     
   }   
}
function OnOverBorder(Id)
{
   var Small_Image=SmallImageIds.split(",");
   var SmallImageId;   
   for(i=0;i<ImageListlength-1;i++)
   {	
         SmallImageId=document.getElementById(Small_Image[i]);
         if(Small_Image[i]==Id)
         {	        
            SmallImageId.className='Thumb ThumbSelected';
         }
         else
         {  
            SmallImageId.className='Thumb ThumbMargin';
         }     
   }  
   document.getElementById(Small_Image[CurrentImage]).className='Thumb Thumbhover';
   return false;
}
function OnOutBorder(Id)
{    
   var Small_Image=SmallImageIds.split(",");
   for(i=0;i<ImageListlength-1;i++)
   {	
     SmallImageId=document.getElementById(Small_Image[i]);           
     if(CurrentImage==i)
     {	        
        SmallImageId.className='Thumb ThumbSelected';
     }
     else
     {  
        SmallImageId.className='Thumb ThumbMargin';
     }     
   }   
   return false;
}
//script for book

function ShowLayerImage()
{  
   var Path=DefaultPath;           
   var Image_List=ImageList.split("~");
   var Image_Height=strLayerImageHeight.split(",");   
   var Image_Width=strLayerImageWidth.split(",");   
   var Small_Image=SmallImageIds.split(",");
   var Small_Image_Title=strTitle.split("~");
   var IamgeName = Image_List[CurrentImage];   
   var LayerHeight=Image_Height[CurrentImage];
   var LayerWidth=Image_Width[CurrentImage];   
   //LayerHeight=Number((Number(LayerHeight) * 600)/225);        
   //LayerWidth=Number((Number(LayerWidth) * 800)/300);
   Path = Path + IamgeName;
   document.getElementById(img_layerImage).src=Path;
   document.getElementById(img_layerImage).style.width=LayerWidth+"px";
   document.getElementById(img_layerImage).style.height=LayerHeight+"px";
   document.getElementById(img_layerImage).title=Small_Image_Title[CurrentImage];
   var SmallImageId;   
   for(i=0;i<ImageListlength;i++)
   {	
     SmallImageId=document.getElementById(Small_Image[i]);                
     if(CurrentImage==i)
     {	        
        SmallImageId.className='Thumb ThumbSelected';        
     }
     else
     {  
        SmallImageId.className='Thumb ThumbMargin';
     }     
   }   
   ShowButton(CurrentImage,btnNextId,btnPreviousId,ImageListlength);
}