function GetRandomValue(low, high) 
{ 
	return Math.floor(Math.random() * (1 + high - low) + low); 
}
function RandomImage(slide_show_name,width,height,align,my_links,no_bottom_border,swc)
{
	//alert(width+":"+height);

	var random_number=1;//GetRandomValue(1, 1)
	width=width+0;
	if (my_links) { height=height+20; }
	else { height=height}
	
	image_comment_height=35;
	if (typeof ImageDescriptions != 'undefined')
	{
		//alert("Has Image Description");
		height=height+image_comment_height;//+20;
	}

	max_width="";
	document.write('<div style="float:'+align+';vertical-align:top;width:'+width+'px;height:'+height+'px;padding:0px;border:0px solid black;font-size:9pt;margin:0px;background-color:#FFFFFF;">');
	document.write("<table width='100%' cellspacing='0' cellpadding='0' border='0'><tr><td align='center' style='width:"+width+"px;height:"+height+"px;' valign='top'>");
	document.write("<img name=\""+slide_show_name+"\" src=\"image" + random_number + ".jpg\" "+max_width+" border=\"0\" align=\"center\" hspace=\"0\" vspace=\"0\" alt=\"\">");
	if (my_links)
	{
		//alert(unescape(my_links));
		document.write(unescape(my_links));
		
	}

	if (typeof ImageDescriptions != 'undefined')
	{
		//alert(width);
		document.write("<br clear='all'>");
		if (no_bottom_border)
		{
			if (document.all) 	{document.write('<div id="image_description" style="overflow:auto; text-align:left; horizontal-align: left;vertical-align:top;width:100.2%;height:'+image_comment_height+'px;padding:2px;color:gray;font-size:8pt;margin-left:-1px;margin-right:0px;margin-top:0px;margin-bottom:0px;background-color:#FFFFFF;font-style:italic;font-family:Verdana,Arial;BORDER-LEFT: 0px solid #DfDfDf; BORDER-right:  0px solid  #dfDfDf;BORDER-TOP: 0px solid #dfDfDf;BORDER-BOTTOM: 0px solid  #DfDfDf;">');	}
			else				{document.write('<div id="image_description" style="overflow:auto; text-align:left; horizontal-align: left;vertical-align:top;width:98%;height:'+image_comment_height+'px;padding:2px;color:gray;font-size:8pt;margin-left:-1px;margin-right:0px;margin-top:0px;margin-bottom:0px;background-color:#FFFFFF;font-style:italic;font-family:Verdana,Arial;BORDER-LEFT: 0px solid #DfDfDf; BORDER-right:  0px solid  #dfDfDf;BORDER-TOP: 0px solid #dfDfDf;BORDER-BOTTOM: 0px solid  #DfDfDf;">');	}
		}
		else if (swc)
		{
			if (document.all)	{document.write('<div id="image_description" style="overflow:auto; text-align:left; horizontal-align: left;vertical-align:top;width:100.2%;height:'+image_comment_height+'px;padding:2px;color:gray;font-size:8pt;margin:0px;background-color:#FFFFFF;font-style:italic;font-family:Verdana,Arial;BORDER-LEFT: 1px solid #DfDfDf; BORDER-right:  1px solid  #dfDfDf;BORDER-TOP: 1px solid #dfDfDf;BORDER-BOTTOM: 1px solid  #DfDfDf;">');}
			else				{document.write('<div id="image_description" style="overflow:auto; text-align:left; horizontal-align: left;vertical-align:top;width:97%;height:'+image_comment_height+'px;padding:2px;color:gray;font-size:8pt;margin:0px;background-color:#FFFFFF;font-style:italic;font-family:Verdana,Arial;BORDER-LEFT: 1px solid #DfDfDf; BORDER-right:  1px solid  #dfDfDf;BORDER-TOP: 1px solid #dfDfDf;BORDER-BOTTOM: 1px solid  #DfDfDf;">');}
		}
		else
		{
			if (document.all)	
			{
				
				if (width>500)
				{
					document.write('<div id="image_description" style="overflow:hidden; text-align:left; horizontal-align: left;vertical-align:top;width:100%;height:'+image_comment_height+'px;padding:2px;color:gray;font-size:8pt;margin:0px;background-color:#FFFFFF;font-style:italic;font-family:Verdana,Arial;BORDER-LEFT: 1px solid #DfDfDf; BORDER-right:  1px solid  #dfDfDf;BORDER-TOP: 1px solid #dfDfDf;BORDER-BOTTOM: 1px solid  #DfDfDf;">');
				}
				else
				{ 
					document.write('<div id="image_description" style="overflow:hidden; text-align:left; horizontal-align: left;vertical-align:top;width:100%;height:'+image_comment_height+'px;padding:2px;color:gray;font-size:8pt;margin:0px;background-color:#FFFFFF;font-style:italic;font-family:Verdana,Arial;BORDER-LEFT: 1px solid #DfDfDf; BORDER-right:  1px solid  #dfDfDf;BORDER-TOP: 1px solid #dfDfDf;BORDER-BOTTOM: 1px solid  #DfDfDf;">');
				}
			}
			else
			{ 
				document.write('<div id="image_description" style="overflow:hidden; text-align:left; horizontal-align: left;vertical-align:top;width:98%;height:'+image_comment_height+'px;padding:2px;color:gray;font-size:8pt;margin:0px;background-color:#FFFFFF;font-style:italic;font-family:Verdana,Arial;BORDER-LEFT: 1px solid #DfDfDf; BORDER-right:  1px solid  #dfDfDf;BORDER-TOP: 1px solid #dfDfDf;BORDER-BOTTOM: 1px solid  #DfDfDf;">');
			}
		}	
		document.write('');
		document.write('</div>');
	}
	document.write("</td></tr></table>");
	document.write('</div>');
}
var PreLoadedImages = new Array();
var slideShowSpeed = 5000;
// Duration of crossfade (seconds)
var crossFadeDuration = 3;

var g_filename_string='';
var g_width_string='';
var slide_show_id = null;
var slide_show_index=0;
var slide_show_running=false;
var slide_show_name='';
function RunSlideShow(my_show_name,slide_show_index,file_name_string,width_string) 
{
	//alert( arguments.length);
	//Init:
	slide_show_name=my_show_name;
	g_filename_string=file_name_string;
	g_width_string=width_string;
	eval('slide_show_Pictures=new Array('+file_name_string+')');
	var picture_length = slide_show_Pictures.length;
	for (i = 0; i < picture_length; i++) 
	{
		PreLoadedImages[i] = new Image();
		PreLoadedImages[i].src = slide_show_Pictures[i];
	}
	//End of init.
	
	StartSlideShow();
}

function StartSlideShow()
{
	//alert("Show: "+slide_show_index);
	slide_show_running=true;
	ShowImage();
	
	if (PreLoadedImages.length>1)		slide_show_id=setTimeout(StartSlideShow, slideShowSpeed);
	
	my_div=document.getElementById('play_button_id');
	if (my_div) my_div.style.display='none';
	my_div=document.getElementById('stop_button_id');
	if (my_div) my_div.style.display='block';
}

function ShowImage(new_index)
{
	if (arguments.length>0) slide_show_index=new_index;
	
	for(i=0;i<PreLoadedImages.length;i++)
	{
		my_div=document.getElementById('image_'+i+'_id');
		if (my_div)
		{
			if (i==slide_show_index)	my_div.style.backgroundColor='#fedc7a';
			else my_div.style.backgroundColor='#CFCFCF';
		}
	}
		
		
	if (document.all) 
	{
		eval('document.images.'+slide_show_name+'.style.filter="blendTrans(duration=2)"');
		eval('document.images.'+slide_show_name+'.style.filter="blendTrans(duration=crossFadeDuration)"');
		eval('document.images.'+slide_show_name+'.filters.blendTrans.Apply()');
	}
	eval('document.images.'+slide_show_name+'.src = PreLoadedImages[slide_show_index].src');
	if (document.all) 
	{
		eval('document.images.'+slide_show_name+'.filters.blendTrans.Play()');
	}
	
	my_div=document.getElementById('image_description');
	if (my_div) my_div.innerHTML=ImageDescriptions[slide_show_index];

	NextImage();
}

function NextImage()
{
	slide_show_index = slide_show_index + 1;
	if (slide_show_index > (PreLoadedImages.length-1)) slide_show_index=0
}

function StopSlideShow()
{
	if (slide_show_running)
	{
		slide_show_running=false;
		clearTimeout(slide_show_id);
		
		my_div=document.getElementById('stop_button_id');
		if (my_div) my_div.style.display='none';
		my_div=document.getElementById('play_button_id');
		if (my_div) my_div.style.display='block';
	}
}