var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

function navigation_open()
{
	navigation_canceltimer();
	navigation_close();
	ddmenuitem = $(this).find('ul').eq(0).show();
}

function navigation_close()
{
	if(ddmenuitem)
		ddmenuitem.hide();
}

function navigation_timer()
{
	closetimer = window.setTimeout(navigation_close, timeout);
}

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





$(document).ready(function(){

	 //loads the under tabs changer on the homepage
	if(jQuery("div.underTabs").size())
	{
	jQuery('div.underTabs').underTabs();
	}
	
	$('#navigation > li').bind('mouseover', navigation_open);
	$('#navigation > li').bind('mouseout',  navigation_timer);
	$('#navigation > li > ul').hide();
	
	
	// SHARE THIS CONTENT DEFAULT
	// hide the div witht the form
	$('#shareContent').hide();
			
	// click function that shows the form and hides the trigger button
	$("#shareWith").click( function() {
	$("#shareContent").slideDown({ easing: 'easeOutSine', duration:600 });
	});
			
	// click function that reverses the click function above
	$("#shareContent a:last").click( function() {
	$("#shareContent").slideUp({ easing: 'easeOutSine', duration: 1000 });
	});
	
	
	// SEND TO A FRIEND FORM
	$(function () {
    
    $('#sendToFriend').hide();
    if (window['showSendToFriend']) {
        $('#sendToFriend').show();
    }

    // click function that shows the form and hides the trigger button
    $("#sendTo").click(function() {
        $("#sendToFriend").slideDown({ easing: 'easeOutSine', duration:600 });
        $('#sendToFriend #id_name').focus();
    });

    // click function that reverses the click function above
    $("#sendToFriend a:last").click( function() {
        $("#sendToFriend").slideUp({ easing: 'easeOutSine', duration: 1000 });
    });
	});
	
	
	if($("div.scrollable").size())
{
 	// Image galleries
	$(function() {		
		// initialize scrollable 
		$("div.scrollable").scrollable({
			size: 1,
			items: '.thumbs',
			//interval: 4000,  
			hoverClass: 'hover',
			loop: true, 
			speed: 1000,
			easing: 'easeOutQuad'
		
		});	
	});
}



});

document.onclick = navigation_close;

$(function () {
    $('.backlink').click(function () {
        window.history.back();
        return false;
    });
});
