

$(document).ready(function() {
    $("#topLinks").formfocus({
        focus : false,
        blur : false,
        keyup : false,
        label : false
    });
	$('#inline').fancybox();

	//Anchor Scroll
	$('a[href*=#]').click(function() {
    	if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
    	&& location.hostname == this.hostname) {
      		var $target = $(this.hash);
      		$target = $target.length && $target
      		|| $('[name=' + this.hash.slice(1) +']');
      		if ($target.length) {
        		var targetOffset = $target.offset().top - 30;
        		$('html,body')
        		.animate({scrollTop: targetOffset}, 750);
       			return false;
      		}
    	}
	});
	//End Anchor Scroll

	//Dropdown Menu
	$('ul.topnav li').hoverIntent(
		function() {
			$(this).find("div.subnav").show().stop().animate({"opacity": 1}, 100);
		},
		function() {
			$(this).find("div.subnav").stop().animate({"opacity": 0}, "fast",
				function(){
					$(this).hide();
				}
			);
		}
	);
	
	$('ul.topnav li').click(function(){
		$(this).find('div.subnav').hide();
	});
	
	$('div.arrow').show();
	//End Dropdown Menu
	
	$('#newsletterShow').fancybox({
		'width'		: 420,
		'height'	: 470,
        'autoScale' : false,
		'type': 'iframe'
	});
	
	//login box
    $(".loginTrigger").fancybox({
		'width'				: 340,
		'height'			: 250,
        'autoScale'     	: false,
		'type'				: 'iframe'
	});

	//convert richtext popup full size images to fancybox images
	$(".intContentRight img").each(function(){
		if(!$(this).parent().is("a"))
			$(this).wrap("<a class='single_image' href='" + $(this).attr("src") + "'></a>");
	});
	//end convert richtext popup full size images to fancybox images
	
	//convert richtext popup thumb images to fancybox images
	$("#main_content_1 a").each(function(){
		var href = $(this).attr("href");
		if(href != undefined){
			var index = href.indexOf("viewImage");
			if(index > -1){
				href = href.replace("javascript:viewImage('", "");
				href = href.replace("')","");
				$(this).attr("href", href);
				$(this).addClass("single_image"); 
			}
		}
	});
	$("#getDirections").formfocus({
            focus : true,
            blur : true,
            keyup : true,
            label : false
        });
	$("a.single_image").fancybox();
	//end convert richtext popup images to fancybox images

	//Events Agenda View Page
	  	//ACCORDION
	$('.eventButton').click(function() {
		$('.eventButton').removeClass('on');
	 	$('.eventContent').slideUp('fast');
	 	$(".print").hide();
		if($(this).next().is(':hidden') == true) {
			$(this).addClass('on');
			$(this).next().slideDown('fast');
			$(this).children(".print").show();
			SetRSVP();
		 } 
	 });
	 
	 $('.print').click(function(e){
	    e.stopPropagation();
	    $(this).parent().slideDown();
	 });
	  
	$('.eventButton').mouseover(function() {
		$(this).addClass('eOver');
	}).mouseout(function() {
		$(this).removeClass('eOver');										
	});
	$('.eventContent').hide();
	
	$("#wrapper .eventButton:last").css('border-bottom', 'none');
	
	$('#featureDate').hover(function(){
		$("#featureDate ul").css('display','block');
		$("#featureDate li").addClass('listHover');
	},function(){
		$("#featureDate ul").css('display','none');
		$("#featureDate li").removeClass('listHover');
	});
	
	//print popup
	/*
	$(".printTrigger").fancybox({
		'width'				: 700,
		'height'			: 400,
        'autoScale'     	: false,
        'transitionIn'		: 'elastic',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	*/
	$(".printTrigger").printHelper();
	
	//search field
	$('label.searchLabel').click(function(){$('input.search').focus();});
	$('input.search').focusin(function(){$('label.searchLabel').fadeOut('fast');});
	$('input.search').focusout(function(){
		var searchText = $('input.search').val()
		if(searchText == "") {
			$('label.searchLabel').text('Site Search...');
			$('label.searchLabel').fadeIn('fast');
		}
	});
	
	//Top Photo Quick Text
	$('.slideshow').cycle({
		prev:		'#cyclePrev',
		next:		'#cycleNext',
		timeout:	6000,
		speed:		1000,
	});
	$('div.close').click(function() {
		$('div#topQuickTextElements').fadeOut(500);
		$('div#topQuickText').animate({
			width: '28px'
		}, 500 );
		$('div.close').fadeOut(500);
		$('div.open').fadeIn(500);
	});
	
	$('div.open').click(function() {
		$('div#topQuickTextElements').fadeIn(500);
		$('div#topQuickText').animate({
			width: '370px'
		}, 500 );
		$('div.close').fadeIn(500);
		$('div.open').fadeOut(500);
	});
	
	//Quick Links
	$('a.quickLink').hover(
		function() {
			$(this).children('div').animate({
				opacity: '1'
			}, 250 );
		},
		function() {
			$(this).children('div').animate({
				opacity: '.6'
			}, 250 );
		}
	);

});
