//UPDATE IE/FLASH
function embedFlash(){
var l=arguments.length;var ll;var h=[];function e(s){h[h.length]=s;}
if(l>2){e('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="');e(arguments[1]);e('" height="');e(arguments[2]);e('" ');if(l>3 && document.all){e('" name="');e(arguments[3]);e('" ')};if(l>3 && document.all){e('id="');e(arguments[3]);e('" ');}
if(l>4){e('align="');e(arguments[4]);e('" ');}
e('>');e('<param name="movie" value="');
e(arguments[0]);e('" />');ll=l;while(ll>5){e('<param name="');e(arguments[ll-2]);e('" value="');e(arguments[ll-1]);e('" />');ll=ll-2;}
e('<embed src="');e(arguments[0]);e('" width="');e(arguments[1]);e('" height="');e(arguments[2]);if(l>3 && !document.all){e('" name="');e(arguments[3]);e('" ');};if(l>3 && !document.all){e('id="');e(arguments[3]);e('" ');};
if(l>4){e('align="');e(arguments[4]);e('" ');}
ll=l;while(ll>5){e(arguments[ll-2]);e('="');e(arguments[ll-1]);e('" ');ll=ll-2;}
e('type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');e('</object>');}
document.write(h.join(''));
}

var current = -1;
var imgObj;
var aObj;
var hrefs = new Array();
var srcs = new Array();
var images = new Array();
var ready = new Array();

var otherCurrent = -1;
var otherImgObj;
var otherAObj;
var otherHrefs = new Array();
var otherSrcs = new Array();
var otherImages = new Array();
var otherReady = new Array();

function initSlideshow()
{
	imgObj = arguments[0];
	aObj = arguments[0].parentNode;
	hrefs = [aObj.href];
	srcs = [imgObj.src];
	for( var i = 1; i < arguments.length; i++ ) {
		if (i%2 > 0)
			srcs.push(arguments[i]);
		else
			hrefs.push(arguments[i]);
	}
	images[0] = imgObj;
	ready[0] = true;
	current = 0;
	for (var i=1; i< srcs.length; i++)
	{
		ready[i] = false;
		images[i] = new Image();
		images[i].style.display = 'none';
		(function (index) {
			images[index].onload = function(){setReady(index);};
		})(i);
		images[i].src = srcs[i];
		aObj.appendChild(images[i]);
	};
};

function setReady(which)
{
	ready[which] = true;
	startIfReady();
};

function startIfReady()
{
	for (var i = 0; i<ready.length; i++)
	{
		if (!ready[i])
			return false;
	}
	if (images.length > 1)
	{
		setTimeout(switchImage,4000);
	}
};

function switchImage()
{
	images[current].style.display = 'none';
	increase();
	images[current].style.display = 'inline';
	
	if (current < hrefs.length)
		aObj.href = hrefs[current];
		
	setTimeout(switchImage,4000);
};

function increase()
{
	current++;
	if (current > images.length -1)
	{
		current = 0;
	}
};

function otherInitSlideshow()
{
	otherImgObj = arguments[0];
	otherAObj = arguments[0].parentNode;
	otherHrefs = [otherAObj.href];
	otherSrcs = [otherImgObj.src];
	for( var i = 1; i < arguments.length; i++ ) {
		if (i%2 > 0)
			otherSrcs.push(arguments[i]);
		else
			otherHrefs.push(arguments[i]);
	}
	otherImages[0] = otherImgObj;
	otherReady[0] = true;
	otherCurrent = 0;
	for (var i=1; i< otherSrcs.length; i++)
	{
		otherReady[i] = false;
		otherImages[i] = new Image();
		otherImages[i].style.display = 'none';
		(function (otherIndex) {
			otherImages[otherIndex].onload = function(){otherSetReady(otherIndex);};
		})(i);
		otherImages[i].src = otherSrcs[i];
		otherAObj.appendChild(otherImages[i]);
	};
};

function otherSetReady(which)
{
	otherReady[which] = true;
	otherStartIfReady();
};

function otherStartIfReady()
{
	for (var i = 0; i < otherReady.length; i++)
	{
		if (!otherReady[i])
			return false;
	}
	if (otherImages.length > 1)
	{
		setTimeout(otherSwitchImage, 4000);
	}
};

function otherSwitchImage()
{
	otherImages[otherCurrent].style.display = 'none';
	otherIncrease();
	otherImages[otherCurrent].style.display = 'inline';
	
	if (otherCurrent < otherHrefs.length) {
		otherAObj.href = otherHrefs[otherCurrent];
	}
		
	setTimeout(otherSwitchImage, 4000);
};

function otherIncrease()
{
	otherCurrent++;
	if (otherCurrent > otherImages.length -1)
	{
		otherCurrent = 0;
	}
};
