// scripts for entire site
$(document).ready(function() {
	
	/*$('#mainContent').prepend('<div id="toolbar"><a href="javascript:" id="toolbar_print" class="imageReplace">Print</a><a class="a2a_dd floatright imageReplace" href="http://www.addtoany.com/share_save"></a><script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script></div>');
	// print page function
	$('#toolbar_print').click(function(){
		window.print();
		return false;
	});*/
	
	//main navigation dropdown animation
	$('#nav li.hover').removeClass('hover');
	$('#nav > li').hoverIntent(function(){
		$(this).children('ul.submenu').slideDown('slow');	
	}, function() {
		$(this).children('ul.submenu').slideUp('fast');	
	});
	
	// homepage rss feed
	$('#newsfeed').rssfeed('http://fringewilmingtonde.com/blog/feed/', {
		limit : 3,
		header : false,
		titletag : 'h3',
		content : false
	});
	
	// scroll down 
	$('#scrollDown').click(function(){
		$.scrollTo( $('#mainContent'), 1500, {easing:'easeInOutQuad'} )
	});
	
	// schedule lightbox, normal lightbox
	$(".titleAbbr,.fancy,.a_tooltip").fancybox({
		'titleShow'		: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'autoDimensions': 'true',
		'overlayColor': '#000'
	});
	// youtube video lightbox
	$(".youtube").click(function() {
		$.fancybox({
				'padding'		: 0,
				'autoScale'		: false,
				'transitionIn'	: 'none',
				'transitionOut'	: 'none',
				'title'			: this.title,
				'width'		: 680,
				'height'		: 495,
				'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
				'type'			: 'swf',
				'swf'			: {
					 'wmode'		: 'transparent',
					'allowfullscreen'	: 'true'
				}
			});
		return false;
	});
	// iframe lightbox
	$(".iframe").fancybox({
		'width'				: '75%',
		'height'			: '75%',
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	
});//doc ready functions


$(window).load(function() {
	
	$('#sign').delay(2000).animate({'top': '0'}, 3000, 'easeInOutElastic');
	
	$('#subjects').delay(4000).animate({'left': '45%'}, 3000, 'easeInOutElastic').delay(2000).animate({'left': '0%'}, 3000, 'easeInOutElastic');
	
	setTimeout(characterSlider, 12000);
	
});

// get current scroll position to show details
function getCurrentScrollPosition() {
		
	var currentScrollPosition = $("#subjects").data("scrollable").getIndex();
	//$("#subjectList img").removeClass('currentScrollItem').next('.scrollDetail').fadeOut('fast');
	//$("#subjectList img:eq(" + currentScrollPosition + ")").addClass('currentScrollItem').next('.scrollDetail').fadeIn('slow');
	//alert('the current scroll item is ' + currentScrollPosition);
}

function characterSlider() {
	// homepage character slider
	$("#subjects").scrollable({ 
		speed : 2000, 
		mousewheel: false, 
		circular: true,
		easing: 'easeInOutElastic',
		//onSeek: getCurrentScrollPosition
	}).autoscroll({ 
		autoplay: true, 
		interval: 5000 
	});
}
