// functions for slides

function ftdc_next_inPlaylist()
{
	var params = nextSlide.split('?');
	var queries = params[1].split('&');
	for(i=0; i<queries.length; i++)
	{
		var pair = queries[i].split('=');
		if ( (pair[0] != null) && (pair[0].indexOf('partner') > -1) && (pair[1] != null))
		{
			inPlaylist=true;
			nextSlide=params[0];
		}
	}
}


// var thisspeed is declared in slide.jsp
function ftdc_slideshow_initialize()
{
	var speed = defaultSpeed;
	var params = window.location.search.split('?');
	var queries = "";
	var advertise = false;
	if(params[1] !=null)
	{
		queries=params[1].split('&');
	}

	for (i = 0; i < queries.length; i++)
	{
		var pair = queries[i].split('=');
		if ( (pair[0] != null) && (pair[0].indexOf('thisSpeed') > -1) && (pair[1] != null))
		{
			var tmp = parseInt(pair[1]);
			if (! isNaN(tmp))
			{
				speed=tmp;
			}
			else
			{
				speed=defaultSpeed;
			}

		}
		if ( (pair[0] != null) && (pair[0].indexOf('advertise') > -1) && (pair[1] != null))
                {
                        //alert('this is an advertisement video2');
			window.clearTimeout(myCancel);
			advertise = true;
			//ftdc_slideshow_stopThis();
                }

		if ( (pair[0] != null) && (pair[0].indexOf('debug') > -1) && (pair[1] != null))
		{
			debug = true;
		}
		if ( (pair[0] != null) && (pair[0].indexOf('partner') > -1) && (pair[1] != null))
		{
			inPlaylist = true;
		}
	}

	thisSpeed = speed;

	if(pagenum < numpages){
		if(debug==true){ alert("setting timeout:" + thisSpeed); }
		myCancel = window.setTimeout('ftdc_slideshow_moveSlides(1)',thisSpeed);
	}
	else{
		if(debug==true){ alert("last slide: no timeout2");}
		myCancel = window.setTimeout('ftdc_slideshow_moveSlides(1)',thisSpeed);
		ftdc_next_inPlaylist();
	}
	if(advertise==true)
	{
		window.clearTimeout(myCancel);
		//alert('hello');
	}

		return;


}

function ftdc_slideshow_moveSlides(direction) {

	var next;
	var pfxThisSpeed = "?";
	var next = nextSlide;
	if(direction<1)
	{
		next = prevSlide;
	}

	if(inPlaylist)
	{
		pfxThisSpeed = "&";
		next = next + "?partner=playlist";
	}
	next = next + pfxThisSpeed+"thisSpeed=" + thisSpeed;


	if(debug==true){
		next = next + "&debug=true";
		alert("next: " + next);
	}
	document.location.href = next;

}
function ftdc_slideshow_stopThis() {
	if(debug==true){ alert("clear timeout"); }
	window.clearTimeout(myCancel);
}

function ftdc_slideshow_changeSpeed(factor) {
	thisSpeed = thisSpeed * factor;
	if(debug==true){ alert("factor:" + factor + " thisSpeed:" + thisSpeed); }
}

function ftdc_map_popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=yes,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=0,width=960,height=800,left = 120,top = 120');");
}

function ftdc_slideshow_popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=yes,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=0,width=1024,height=768,left = 220,top = 192');");
}

function PopUp(ref)
{
var strFeatures="toolbar=no,status=no,menubar=no,location=no"
strFeatures=strFeatures+",scrollbars=no,resizable=yes,height=600,width=600"

newWin = window.open(ref,"TellObj",strFeatures);

newWin.opener = top;
}


//


