// Created on Jul 24, 2011 10:57:50 AM
var crossing=false;
var crossid;
function slideSwitch() {
  var active = $('#slideshow ul li.active');
  if (active.length == 0) active = $('#slideshow ul li:last');
  var next = active.next().length ? active.next(): $('#slideshow ul li:first');
  if (!crossing) {
	  crossing = true;
  	if (active == next) {
  		active.css({ opacity: 0.0 }) .show() .animate({ opacity: 1.0 }, 800, function () {
  			if (jQuery.browser.msie) { this.style.removeAttribute('filter'); }  
	  		crossing = false;  
  		});
  		return; 
	  }
	  active.addClass('last-active').animate({ opacity: 0.0 }, 800);
  	next.css({ opacity: 0.0 }).show().addClass('active').animate({ opacity: 1.0 }, 800, function () {
  		if (jQuery.browser.msie) { this.style.removeAttribute('filter'); }  
	  	active.removeClass('active last-active');  
  		crossing = false;  
	  });
	}
}
function slideBack() {
	var active = $('#slideshow ul li.active');
	if (active.length == 0) $active = $('#slideshow ul li:last');
	var next = active.prev().length ? active.prev(): $('#slideshow ul li:last');
	if (!crossing) {
  	crossing = true;
  	active.addClass('last-active').animate({ opacity: 0.0 }, 800);
  	next.css({ opacity: 0.0 }).show().addClass('active').animate({ opacity: 1.0 },800, function () {
  		if (jQuery.browser.msie) { this.style.removeAttribute('filter'); }  
  		active.removeClass('active last-active'); 
  		crossing = false; 
  	}); 
  }
}

$(document).ready(function() {
  $("#accordion").accordion({autoHeight:false});  
  slideSwitch();
  crossid=setInterval('slideSwitch()', 6500);  
  $('#pplay, #back, #next').mouseover(function() {
  	$(this).css({'opacity':1.0});
  });
  $('#pplay, #back, #next').mouseout(function() {
  	$(this).css({'opacity':0.4});
  });
  $('#pplay').click(function() {
  	if ($(this).attr('src')=='play4.png') {
  		$(this).attr('src','pause4.png');
		  slideSwitch();
		  crossid=setInterval('slideSwitch()', 6500);	
  	}
  	else {
  		clearInterval(crossid);
  		$(this).attr('src','play4.png');
  	}
  });
  $('#next').click(function() {
		if (!crossing) {
			slideSwitch(); 
		}
  });
  $('#back').click(function() {
		if (!crossing) {
			slideBack(); 
		}
  });
  
});

