$(function(){	
	$.easy.navigation();
	$.easy.tooltip();
	$.easy.popup();
	$.easy.external();
	$.easy.rotate();
	$.easy.cycle();
	$.easy.forms();
	$.easy.showhide();
	$.easy.jump();
	$.easy.tabs();
	$.easy.accordion();
	
	//$('#calendarForm input').simpleDatepicker();
	
	//new homepage featured
	(function(){
		$('#slideshow').each(function(){
	
				var pause = 5000;
				var initPause = 0;
			
				var obj = $(this);	
				var children = $('p', obj);
				var length = $(children).length;
				var temp = 0;
				var prev = -1;
				var z = 1;
				var timeout;
				var play = true;
				
				var numeric = $('<ol class="numeric"></ol>').appendTo(obj);

				function change(){						
					temp = (temp == length) ? 1 : temp+1; 
					prev = (temp == 1) ? length : temp-1; 
					show();
				};
				
				function show(){
					$('p',obj).css('z-index',1);	
					$('p:nth-child(' + temp + ')',obj).css('z-index',2).fadeIn('fast',function(){
						$('p:nth-child(' + prev + ')',obj).fadeOut('fast');	
					});
					$('.numeric li',obj).removeClass('current');
					$('.numeric li:nth-child(' + temp + ')',obj).addClass('current');
					z++;
					timeout = setTimeout(change,pause);	
				};
				
				function playpause(){
					if(play){
						play = false;
						$('.numeric li.play',obj).addClass('pause');
					} else {
						play = true;
						$('.numeric li.play',obj).removeClass('pause');
						timeout = setTimeout(change,0);						
					};
				};
								
				function init(){
					change(); 	
				};
				
				$(children).each(function(i){
					var title = $(this).attr('title');
					if(title=='') title=i+1;
					$(this)
						.hide()
						.css({
							'position':'absolute',
							'top':'0',
							'left':'0'
							});
					$('<li class="numeric'+ (i+1) +'"></li>')
						.css('cursor','pointer')
						.appendTo(numeric)
						.html(title)						
						.click(function(){		
							var index = $('.numeric li',obj).index(this) + 1;	
							if(index != temp){
								clearTimeout(timeout);
								prev = temp;
								temp = index;
								show();
							};							
						});
				});	
				/*$('<li class="play">Play</li>')
					.appendTo(numeric)
					.click(function(){
						clearTimeout(timeout);
						playpause();
					})
				*/
				if (length > 1) setTimeout(init,initPause);		
			
		});
	})();

	
});
