
var slideShowSpeed = 7000;
var crossFadeDuration = 1;
var Pic = new Array();
var t;
var j = jj = 0;
var p = Pic.length;
var pos = j;
var preLoad = new Array();
var current_text_pos = 0;
var real_text_pos = 0;
var current_text_speed = 0;
var start_text_speed = 10;
var text_way_length = 150;
var text_interval = 0;

var xOp7=false,xOp5or6=false,xIE4Up=false,xNN4=false,xUA=navigator.userAgent.toLowerCase(); 
if(window.opera){ 
  xOp7=(xUA.indexOf('opera 7')!=-1 || xUA.indexOf('opera/7')!=-1); 
  if (!xOp7) xOp5or6=(xUA.indexOf('opera 5')!=-1 || xUA.indexOf('opera/5')!=-1 || xUA.indexOf('opera 6')!=-1 || xUA.indexOf('opera/6')!=-1); 
} 
else if(document.layers) xNN4=true; 
else {xIE4Up=document.all && xUA.indexOf('msie')!=-1 && parseInt(navigator.appVersion)>=4;}

function preLoadPic(index)
{
	p = Pic.length;
	if (Pic[index]["image"] != '')
	{
		window.status='Loading : '+Pic[index]["image"];
		preLoad[index] = new Array();
		preLoad[index]["image"] = new Image();
		preLoad[index]["image"].src = Pic[index]["image"];
		Pic[index]["image"] = '';
		preLoad[index]["txt"] = new Image();
		preLoad[index]["txt"].src = Pic[index]["txt"];
		preLoad[index]["txt_left"] = Pic[index]["txt_left"];
		preLoad[index]["txt_top"] = Pic[index]["txt_top"];
		Pic[index]["txt"] = '';
		window.status='';
	}
}

function runSlideShow()
{
	//document.images.SlideShow.src = "/img/pix.gif";

	p = Pic.length;
	preLoadPic(j);

	if (xIE4Up)
	{
		$('SlideShowTxt').style.display = "none";
		$("slideShowObj").style.filter = "blendTrans(duration=2);";
		$("slideShowObj").style.filter = "blendTrans(duration=" + crossFadeDuration + ");";
		$("slideShowObj").filters.blendTrans.Apply();
		$('SlideShow').src = preLoad[j]["image"].src;
	 	$("slideShowObj").filters.blendTrans.Play();
		$('SlideShow').src = "/img/pix.gif";
		$('SlideShow').runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + preLoad[j]["image"].src + "',sizingMethod='scale')";
	}
	else
	{

		$('SlideShow').src = preLoad[j]["image"].src;
		$('SlideShow').hide();
		//$('SlideShow').fade({ duration: 1 });
		$('SlideShow').appear({ duration: 1 });
		$('SlideShowTxt').style.marginLeft = preLoad[j]["txt_left"] + "px";
		$('SlideShowTxt').style.marginTop = preLoad[j]["txt_top"] + "px";
		$('SlideShowTxt').src = preLoad[j]["txt"].src;
		if (preLoad[j]["txt"].width > 0)
			$('SlideShowTxt').width = preLoad[j]["txt"].width;
		if (preLoad[j]["txt"].height > 0)
			$('SlideShowTxt').height = preLoad[j]["txt"].height;
	}

	jj = j;
	if (xIE4Up)
	{
		setTimeout('moveText()', 1000);
	}
	else
	{
		moveText();
	}

	pos = j;
	j = j + 1;
	if (j > (p-1)) j=0;
	t = setTimeout('runSlideShow()', slideShowSpeed);
	preLoadPic(j);
}

function moveText()
{
	if (xIE4Up)
	{
		$('SlideShowTxt').src = "/img/pix.gif";
	}

	$('SlideShowTxt').style.marginLeft = preLoad[jj]["txt_left"] - text_way_length + "px";
	$('SlideShowTxt').style.marginTop = preLoad[jj]["txt_top"] + "px";
	current_text_pos = preLoad[jj]["txt_left"] - text_way_length;
	real_text_pos = preLoad[jj]["txt_left"];
	current_text_speed = start_text_speed;

 	text_interval = setInterval('_moveText()', 5);

	if (xIE4Up)
	{
		$('SlideShowTxt').show();
		$('SlideShowTxt').style.filter = "blendTrans(duration=2);";
		$('SlideShowTxt').style.filter = "blendTrans(duration=" + crossFadeDuration + ");";
		$('SlideShowTxt').filters.blendTrans.Apply();
		$('SlideShowTxt').src = preLoad[jj]["txt"].src;
	 	$('SlideShowTxt').filters.blendTrans.Play();
	} else {
		$('SlideShowTxt').hide();
       		$('SlideShowTxt').appear({ duration: 2 });
	}
}

function _moveText()
{
	$('SlideShowTxt').style.marginLeft = current_text_pos + "px";
	current_text_pos += current_text_speed;
	current_text_speed = current_text_speed / 1.07;
	if (current_text_pos >= real_text_pos)
	{
		current_text_speed = 0;
		clearInterval(text_interval);
	}
}

