// JavaScript Document
var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function navcenter_open()
{  navcenter_canceltimer();
   navcenter_close();
   ddmenuitem = $(this).find('ul').css('display', 'block');}

function navcenter_close()
{  if(ddmenuitem) ddmenuitem.css('display', 'none');}

function navcenter_timer()
{  closetimer = window.setTimeout(navcenter_close, timeout);}

function navcenter_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
      closetimer = null;}}

function slideShow() {
	$('#mainpix span').css({opacity: 0.0});
	$('#mainpix span:first').css({opacity: 1.0});
	setInterval('mainpix()',3000);
	
}

function mainpix() {
	//if no IMGs have the show class, grab the first image
	var current = ($('#mainpix span.show')?  $('#mainpix span.show') : $('#mainpix span:first'));
	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#mainpix span:first') :current.next()) : $('#mainpix span:first'));	
	//Get next image caption
	var caption = next.find('img').attr('rel');	
	//Set the fade in effect for the next image, 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');
	
	//Set the opacity to 0 and height to 1px
	//$('#gallery .caption').animate({opacity: 0.0}, { queue:false, duration:50 }).animate({height: '1px'}, { queue:true, duration:300 });	
	
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
	//$('#gallery .caption').animate({opacity: 0.7},100 ).animate({height: '100px'},500 );
	
	//Display the content
	//$('#mainpix .content').html(caption);
	
	
}	  
$(document).ready(function()
{  $('.navcenter > ul > li').bind('mouseover', navcenter_open)

   $('.navcenter > ul > li').bind('mouseout',  navcenter_timer)
   slideShow();
});

   document.onclick = navcenter_close;


