﻿var currentIndex = 0;

function createSlideShow()
{
	var scene = new photoGallery.Page();
	Silverlight.createObjectEx({
		source: "SlideShow.xaml",
		parentElement: document.getElementById("SilverlightControlHost"),
		id: "SilverlightControl",
		properties: {
			width: "169",
			height: "144",
			background:'#00000000',
			isWindowless: 'true',
			version: "1.0"
		},
		events: {
			onLoad: Silverlight.createDelegate(scene, scene.handleLoad)
		}
	});
}

function createSilverlightSplash()
{
    var scene = new photoGallery.Page();
    
	Silverlight.createObjectEx({
		source: "Splash.xaml",
		parentElement: document.getElementById("SilverlightControlHost"),
		id: "SilverlightControl",
		properties: {
			width: "400",
			height: "400",
			background:'#00000000',
			isWindowless: 'true',
			version: "1.0"
		},
		events: {
			onLoad: Silverlight.createDelegate(scene, scene.handleLoad)
		}
	});
}

function createSilverlightPhotoGallary(index)
{
    var div;
    
    div = getObj('divPage');
    var currentArrayIndex = parseInt(index);

    div = getObj('divvehicleCategory');
    div.innerHTML = vCatArray[parseInt(index)];

    div = getObj('divPage');
    div.innerHTML = parseInt(index) + 1;

    if(parseInt(index) > 0)
        showDivObj('divPrev');
    else 
        hideDivObj('divPrev');

    if(parseInt(index) < pageArray.length - 1)
        showDivObj('divNext');
    else 
        hideDivObj('divNext');

    var scene = new photoGallery.Page();
	Silverlight.createObjectEx({
		source: "Page.xaml",
		parentElement: document.getElementById("SilverlightControlHost"),
		id: "SilverlightControl",
		properties: {
			width: "580",
			height: "580",
			background:'#00000000',
			isWindowless: 'true',
			version: "1.0"
		},
		events: {
			onLoad: Silverlight.createDelegate(scene, scene.handleLoad)
		}, 
		initParams: '' + index
	});
}

function createSilverlightPhotoGallaryPrev()
{
    // get div containing page index
    var div;
    
    div = getObj('divPage');
    
    // get display index value
    var currentPageIndex = div.innerHTML;
    
// alert('pageIndex = ' + pageIndex);
    
    var currentArrayIndex = parseInt(currentPageIndex) - 1;

    var prevArrayIndex = parseInt(currentArrayIndex) - 1;
    if(prevArrayIndex < 0)
    {
        prevArrayIndex = 0;
    }
    
    createSilverlightPhotoGallary(prevArrayIndex);
        
}

function createSilverlightPhotoGallaryNext()
{
    // get div containing page index
    var div;
    
    div = getObj('divPage');

// alert('div = ' + div);
    
    // get display index value
    var currentPageIndex = div.innerHTML;
    
// alert('pageIndex = ' + pageIndex);
    
    var currentArrayIndex = parseInt(currentPageIndex) - 1;

    var nextArrayIndex = parseInt(currentArrayIndex) + 1;
    
    if(nextArrayIndex >= pageArray.length)
    {
        nextArrayIndex = pageArray.length - 1;
    }
        
    createSilverlightPhotoGallary(nextArrayIndex);

}

if (!window.Silverlight) 
	window.Silverlight = {};

Silverlight.createDelegate = function(instance, method) {
	return function() {
		return method.apply(instance, arguments);
	}
}
