// JavaScript Document

var ImageRandom = 
{
	imgObj : null,
	ImageArray : new Array(),
	ImageIndex : 0,
	init : function()
	{
		ImageRandom.imgObj = document.getElementById("backgroundImage1");
		ImageRandom.Get('/avtrucks/images/backgrounds/trucks/imagefiles.asp');
	},
	
	httpRequest : Core.createXHR(),
	Text : '',
    Get: function(path)
    {
        try
		{
			ImageRandom.httpRequest.open('GET', path, true);
            ImageRandom.httpRequest.onreadystatechange = function()
            {  
                if (ImageRandom.httpRequest.readyState == 4)
				{
                    if (ImageRandom.httpRequest.status == 200)
                    {
                        try 
						{ 
							if (ImageRandom.httpRequest.responseText != '')
							{
								ImageRandom.Set(ImageRandom.httpRequest.responseText);
							}
							
						} catch (e){ }
                    }
                }
            }
            ImageRandom.httpRequest.send(null);
			Core.preventDefault(event);

        }catch(e){}
    },
	Set: function(strImages)
	{
		try
		{
			ImageRandom.ImageArray
			var strArray = strImages.split(';#');
			if (strArray.length > 0)
			{
				ImageRandom.imgObj.style.backgroundImage = 'url(/avtrucks/images/backgrounds/trucks/'+strArray[ImageRandom.GetRrandomIndex(strArray.length-1)]+')';
			}
		}catch(e){}
	},
	GetRrandomIndex : function (n)
	{
    	return ( Math.floor ( Math.random ( ) * n ) );
	}

}

//Core.start(ImageRandom); // disabled

