function applySelectedTo(link) {
 var ul = document.getElementsByTagName("ul")[0];
  var allLinks = ul.getElementsByTagName("a");
  for (var i=0; i<allLinks.length; i++) { 
    allLinks[i].className = ""; 
  }
  link.className = "active"; 
return true;
}



function theRotator() {
	//Set the opacity of all images to 0
	$('div.rotator ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div.rotator ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('rotate()',2000);
	
}

function rotate() {	
	//Get the first image
	var current = ($('div.rotator ul li.show')?  $('div.rotator ul li.show') : $('div.rotator ul li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div.rotator ul li:first') :current.next()) : $('div.rotator ul li:first'));	
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
}




function Fadeout() {
	
	//Set the opacity of all images to 0
	$('div.fadeout ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div.fadeout ul li:first').css({opacity: 1.0});

	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('fader()',3000);
	
}

function fader() {	
	//Get the first image
	var current = ($('div.fadeout ul li.show_fade')?  $('div.fadeout ul li.show_fade') : $('div.fadeout ul li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show_fade')) ? $('div.fadeout ul li:first') :current.next()) : $('div.fadeout ul li:first'));	
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show_fade')
	.animate({opacity: 2.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show_fade');
	
};





$(document).ready(function(){

	$('.slideshow').cycle({
		fx: 'fade', timeout: 1000 // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});


	$('.slideshow2').cycle({
		fx: 'scrollHorz', timeout: 6000 // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});
	
	$('.slideshow3').cycle({
		fx: 'fade', timeout: 1000 // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});
	
theRotator();

Fadeout();

/*$('.templatemo_fade').innerfade({ speed: 1000, timeout: 6000, type: 'random_start', containerheight: '1.5em'});
*/

//for accordian content to glide

$('.acc_container').hide(); //Hide/close all containers
//$('.acc_trigger:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container

//On Click
$('.acc_trigger').click(function(){
	if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
		$('.acc_trigger').removeClass('active').next().slideUp(); //Remove all "active" state and slide up the immediate next container
			
		$(this).toggleClass('active').next().slideDown(); //Add "active" state to clicked trigger and slide down the immediate next container
		
	}
	
	
	else if( $(this).toggleClass('active') ){
		$('.acc_trigger').removeClass('active').next().slideUp();
		
	}
	
	return false; //Prevent the browser jump to the link anchor
});

				 


});
