if (!window.GJHPhotoGallery)
	window.GJHPhotoGallery = {};

GJHPhotoGallery.Page = function() 
{
}

GJHPhotoGallery.Page.prototype =
{
	handleLoad: function(control, userContext, rootElement) 
	{
		this.control = control;
		
		mainSL = control.content.findName("Page");
		mainSL.Background=Master_Background;
		mainSL.Width = Master_Width;
		mainSL.Height = Master_Height;
		
		
		cvsThumbNailMain = control.content.findName("cvsThumbNailMain");
		cvsThumbNailMain["Canvas.Top"] = listThumbNailMainTop;
		cvsThumbNailMain["Canvas.Left"] = listThumbNailMainLeft;
		cvsThumbNailMain.Background = listBackgroundColor;
		
        initImg = control.content.findName("imgMain");
		initImg.Width = MainImageWidth;
		initImg.Height = MainImageHeight;
		initImg["Canvas.Top"] = MainImageTop;
		initImg["Canvas.Left"] = MainImageLeft;
				
		HeaderText = control.content.findName("txtHeader");
		HeaderText["Text"] = txtHeader;
		HeaderText.Foreground = txtColor;
		HeaderText.FontSize = fontSize;
		HeaderText.FontFamily = fontFamily; 
		HeaderText["Canvas.Top"] = txtHeaderTop;
		HeaderText["Canvas.Left"] = txtHeaderLeft;
		
		moveLeftWidth = control.content.findName("moveLeftWidth");
		var x = moveLeftSetWidth - (160 * 4.60);
		moveLeftWidth.SetValue("To", -x);
		
		this.root = control.content.findName("cvsThumbNailHolder");	
		this.downloadButtonXaml();
		
				
	},
	downloadButtonXaml: function(sender, eventArgs)
	{
	    var downloader = this.control.createObject("downloader");
	    downloader.addEventListener("completed", Silverlight.createDelegate(this, this.downloaderCompleted));	    
	    downloader.open("GET", "ListItem.xaml");
	    downloader.send();
	},
	
	downloaderCompleted: function(sender, eventArgs)
	{
	    var arrImgs     = ArrItems;
	    var xamlItem    = sender.getResponseText("");
	    var top         = 5;
	    arrCount        = arrImgs.length //# of images. js array or similar
	    sender.findName("imgMain").Source = arrImgs[0]; //default image source (1st image in array)
	    for (var i=0; i < arrCount; i++)
	    {
	        var item        = this.control.content.createFromXaml(xamlItem, true);
	        this.root.children.add(item);
			var img         = arrImgs[i]; // image
	        new GJHDigital.imgItem(this.control, item, img, left);//control, target, img, x
	        left += imgWidth;
	        lastItemPos     = item.children.getItem(0)["Canvas.Left"];
	    }
	    imgListWidth        = (arrCount * (imgWidth + 10)) / arrCount;
	}	
}
function startRight(sender, mouseEventArgs)
{
	sender.findName("moveLeft").begin();
}
function stopRight(sender, eventArgs)
{
	sender.findName("moveLeft").pause();
}
function startLeft(sender, mouseEventArgs)
{
	sender.findName("moveRight").begin();
}
function stopLeft(sender, eventArgs)
{
	sender.findName("moveRight").pause();
}
function ShowImage(sender, args)
{
    initImg.Source = sender.Source;
}
function HiliteLeft(sender, args)
{
	sender.findName("btnLeft").Fill = LeftButtonColorOn;
}
function deHiliteLeft(sender, args)
{
	sender.findName("btnLeft").Fill = LeftButtonColorOff;
}
function HiliteRight(sender, args)
{
    sender.findName("btnRight").Fill = RightButtonColorOn;
}
function deHiliteRight(sender, args)
{
    sender.findName("btnRight").Fill = RightButtonColorOff;
}

