﻿// JScript File

     var ImageItemCount=0;
     var ImageItemCountMain=0;
     var nodeId = 1048;
     var length = 2;
     
       $(document).ready(function(){
            LoadImageryLeft();
        });
        
    function LoadImageryLeft() 
    {
       $.getJSON("/ImageryLeft.axd?request=getRandomListAll&nodeId="+pageId,BuildImageryLeft)
    }

    function BuildImageryLeft(ImagesList) 
    {
        if(ImagesList.length == 0)
        {
            ImageItemView = 0;
          //  LoadImageryLeft();
        }
        else
        {
            var div= "";
            var pos=0;
            while(pos<ImagesList.length)
            {
               if(ImagesList[pos] != null && ImagesList[pos].largeImage != null && ImagesList[pos].largeImage != '')
               {
                    if(ImagesList.length > 1)
                    {
                        div += "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"display:none; width:100%;\" ><tr><td class=\"imagery_left_block\"><img src=\"" + ImagesList[pos].largeImage + "\" title=\"" + ImagesList[pos].altText + "\" /></td></tr></table>";
                    }
                    else
                    {
                        div += "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"width:100%;\" ><tr><td class=\"imagery_left_block\"><img src=\"" + ImagesList[pos].largeImage + "\" title=\"" + ImagesList[pos].altText + "\" /></td></tr></table>";
                    }
                    pos++;
               }
               else
               {
                    pos++;
               }
            }
           $(".image").append($(div));
           ImageItemCount = ImagesList.length * 2;
           setTimeout("ResizeLogo()",300);
           setTimeout("startImagery()",1000);
         // startImagery();
         }
   }
    

var ResizeCount = 0;
var CountRepeat = 0;

function ResizeLogo()
{

    LoadCountImages = 0;
    CountImages = 0;
        $(".image img").each(function()
       {
        CountImages++;
	maxWidth = 270;
	maxHeigth = 405;

        originalWidth = this.width;
        originalHeigth = this.height;       
	if(originalWidth > 0 && originalHeigth  > 0)
	{
		// Resample image
		if (originalWidth  > maxWidth)
		{
			$(this).attr("height",(originalHeigth  * (maxWidth / originalWidth)));
			$(this).attr("width", maxWidth);

        		originalWidth = this.width;
        		originalHeigth = this.height;
		}

		if (originalHeigth  > maxHeigth)
		{
			$(this).attr("height", maxHeigth);
			$(this).attr("width", (originalWidth * (maxHeigth / originalHeigth)));
		}
		

		LoadCountImages++;
	}
	
 });
 if(LoadCountImages < CountImages && CountRepeat < 2000)
   {  
        setTimeout("ResizeLogo()",300);
   }
   CountRepeat++;
  
}

function startImagery()
{
$('.image').innerfade({
  speed: 750,
  timeout: 6000,
  containerheight: '500px' })
}
