$('.ppt li:gt(0)').hide();
$('.ppt li:last').addClass('last');
$('.ppt li:first').addClass('first');
$('#play').hide();

var cur = $('.ppt li:first');
var interval;
var stopped = '0';


$('#fwd').click( function() {
	goFwd();
	showPause();
} );

$('#back').click( function() {
	goBack();
	showPause();
} );

$('#stop').click( function() {
	stop();
	showPlay();
	stopped = '1';
} );

$('#play').click( function() {
	start();
	showPause();
	stopped = '0';
} );

function pause() {
	stop();
	showPlay();
	stopped = '1';
}

function play() {
	start();
	showPause();
	stopped = '0';
}

function go_to(img) {
	stop();
	go_to_img(img);
	
	if (stopped=='0')
	start();
}

function goFwd() {
	stop();
	forward();
	start();
}

function goBack() {
	stop();
	back();
	start();
}

function go_to_img(img) {
	cur.fadeOut( 1000 );
	var new_cur = $('.ppt li:first');
	for (i=1; i<img; i++)
	{
		new_cur = new_cur.next();
	}
	cur = new_cur;
	cur.fadeIn( 1000 );
}

function back() {
	cur.fadeOut( 1000 );
	if ( cur.attr('class') == 'first' )
		cur = $('.ppt li:last');
	else
		cur = cur.prev();
	cur.fadeIn( 1000 );
}

var mydiv = 1;
var lastdiv = 8;

document.getElementById('text_'+lastdiv).style.display='none';
//setTimeout("document.getElementById('text_'+mydiv).style.display='block';",1200);
//setTimeout('$("#text_"+lastdiv).fadeOut( 1000 )',1200);
setTimeout('$("#text_"+mydiv).fadeIn( 1000 )',1200);

function forward() {
	
	cur.fadeOut( 1000 );
	if ( cur.attr('class') == 'last' )
	{
		cur = $('.ppt li:first');
		mydiv = 1;
		lastdiv = 8;
	}
	else
	{
		cur = cur.next();
		lastdiv = mydiv;
		mydiv ++;
	}
	cur.fadeIn( 1000 );
	
	document.getElementById('text_'+lastdiv).style.display='none';
	//setTimeout("document.getElementById('text_'+mydiv).style.display='block';",1200);
	//setTimeout('$("#text_"+lastdiv).fadeOut( 1000 )',1200);
	setTimeout('$("#text_"+mydiv).fadeIn( 1000 )',1200);
	
	//alert(cur.size())
	//alert(mydiv);
}

function showPause() {
	$('#play').hide();
	$('#stop').show();
}

function showPlay() {
	$('#stop').hide();
	$('#play').show();
}

function start() {
	interval = setInterval( "forward()", 5000 );
}

function stop() {
	clearInterval( interval );
}

$(function() {
	start();
} );

/*
function fnDepress() {
var bState = oFilterDIV.filters.item('DXImageTransform.Microsoft.dropshadow').enabled;

oFilterDIV.filters.item('DXImageTransform.Microsoft.dropshadow').enabled = !bState;
}
*/
function show_custom_img(img_name, img_width)
{
	$("#my_custom_img").replaceWith('<div id=\"my_custom_img\" style=\"position:fixed; top:0px; left:0px; z-index:99999990;\"><img src=\"images/pages/'+img_name+'.jpg\" width=\"'+img_width+'\" style=\"border:1px solid #606060;\" /></div>');
}

function hide_custom_img(img_name, img_width)
{
	$("#my_custom_img").replaceWith('<div id=\"my_custom_img\" style=\"display:none; z-index:0;\"></div>');
}
