// JavaScript Document
function searchsite(form){
	if($(form)){
		new Ajax.Request('search_site.php', {
  			parameters: $(form).serialize(true),
			onSuccess: function(transport){
			  var response = transport.responseText;
			  if($("right_contents")){
				  $("right_contents").innerHTML = transport.responseText;
			  }
			  
			}
  		});

	}
}

var currentSlide;
var numberOfSlides = 4;
var currentSlideshow;
function initSlideshow(){
	if($('adaptit_info_inner')){
		currentSlideshow = setInterval(getNextSlide, 10000);	
	}
}

function controlSlideShow(){
	if(currentSlideshow != null){
		clearInterval(currentSlideshow);
		currentSlideshow = null;	
		if($('slideshowController')){
			$('slideshowController').innerHTML = "<img src=\"graphics/start_slideshow.png\" style=\"border:0;\" />";	
		}
	} else {
		initSlideshow();
		if($('slideshowController')){
			$('slideshowController').innerHTML = "<img src=\"graphics/stop_slideshow.png\" style=\"border:0;\" />";	
		}
	}
}

function stopSlideShow(){
	if(currentSlideshow != null){
		clearInterval(currentSlideshow);
		currentSlideshow = null;	
		if($('slideshowController')){
			$('slideshowController').innerHTML = "<img src=\"graphics/start_slideshow.png\" style=\"border:0;\" />";	
		}
	}
}

function getNextSlide(){
	
	if(currentSlide == null){
		currentSlide = 0;	
	}
	
	if(currentSlide+1 >= numberOfSlides){
		currentSlide = 0;	
	} else {
		currentSlide++;	
	}
	
	loadSlide(currentSlide);	
}

function getPrevSlide(){
	
	if(currentSlide == null){
		currentSlide = 0;	
	}
	
	if(currentSlide == 0){
		currentSlide = numberOfSlides -1;	
	} else {
		currentSlide--;	
	}
	
	loadSlide(currentSlide);	
}

function loadSlide(slidenumber){
	//new Effect.Fade('adaptit_info_inner', 
      // { duration:1});
	//new Effect.Fade('adaptit_info_inner');
	new Effect.Fade('adaptit_info_inner', {
					duration: 1,
					fps: 50,
					afterFinish: function(){
					new Ajax.Updater('adaptit_info_inner', 'slideshow.php?slide=' + slidenumber,{
					 asynchronous:true,
					 onSuccess: function(){
						new Effect.Appear('adaptit_info_inner', {
										  duration: 1,
										  fps:50,
										  queue: 'end'
										  }) 
					 }
					 });
					}
					});
	//new Effect.Appear('adaptit_info_inner', 
      // {duration:1, from:1.0, to:1.0});


	
}

function submitLogin(formid){
	var theForm = document.getElementById(formid);
	theForm.submit();	

}

