//=======================================================================================================
//-------------------------------------------------------------------------------------------------------
//	Custom Javascript functions
//-------------------------------------------------------------------------------------------------------
//=======================================================================================================
function validateNewsletterForm()
{
	form = document.requestnewsletter;

	control = form["fields[Email]"];
	if ( !IsEmail(control.value) )
	{
		alert("Please enter a valid email address");
		control.focus();
		return false;
	}

	return true;
}

$(document).ready(function(){
    var images = $('#slideshow img');
    var active_index = 0;
    if(images.length) {
        setInterval( function(){
               active_index++;
               if(active_index == images.length) {
                   images.slice(1).hide();
                   active_index = 0;
               }
               else{
                   images.eq(active_index).show();
               }
            }
        , 3000);
    };

	$(".tab-content").css({'display':'none'});
	$(".tab-content:first").css({'display':'block'});

	$("#tab-navs a").click(
		function () {
			$('.tab-nav').removeClass('tab-active');
			$(this).addClass('tab-active');
			$('.tab-content').css({'display':'none'});
			$('#'+$(this).attr('id')+'-content').css({'display':'block'});
		}
	);

	//	Global nav Login link gets an icon 
	$("#globalnav a:contains('Login')").css("background-image","url(/site/images/bg_login.png)");

//-------------------------------------------------------------------------------------------------------
//	Submenu indicators
//-------------------------------------------------------------------------------------------------------
	$("li.i1").find("ul").parent().each(function () {
		$(this).find("a.a1").addClass("showsub");
	});

//-------------------------------------------------------------------------------------------------------
//	Pages that do not have banners, add padding to header
//-------------------------------------------------------------------------------------------------------
	$("#banner,#homebanner").each(function () {
		$("#header").css("margin-bottom","0px");
	});



});
