$(function()
{
	//highlights the curret menu item
	//this is a fix for those who don't load via ajax
	$('div.menuBlock.current img, div.menuBlock.section img').attr('src',$('div.menuBlock.current img, div.menuBlock.section img').siblings('img.preload').attr('src'));


	$('#mainMenu a').bind('click', function()
	{
		$(this).parent('li').addClass('current').siblings().removeClass('current section').addClass('link');
	}).bind('mouseover',function()
	{
		var menu = "#"+$(this).data('pop').toString();
		if($(menu).find('a').length)
		{
			//$('#hearts').fadeOut(100);
		}
		else
		{
			//$('#hearts').fadeIn(500);
		}
		$('#topMenus ul').stop(true,true).fadeOut(250);
		$(menu).stop(true,true).fadeIn(250);
	});

	$('#header').mouseleave(function(){ echo('leaving header'); $('#topMenus ul').stop(true,true).fadeOut(250); /*$('#hearts').fadeIn(500);*/ });

	$('div.menuBlock').find('img').hover(
	function()
	{
		var $this = $(this);
		$this.attr('src',$this.siblings('img.preload').attr('src'));
	},
	function()
	{
		var $this = $(this);
		if(!$this.parents('div.menuBlock').hasClass('current') && !$this.parents('div.menuBlock').hasClass('section'))
		{
			$this.attr('src',$this.siblings('img.preload').data('normal-state'));
		}
	});

	$('#social img').hover(
	function()
	{
		$(this).attr('src',$(this).attr('src').replace('on','off'));
	},
	function()
	{
		$(this).attr('src',$(this).attr('src').replace('off','on'));
	});
	//smooth scrolling marquee replacement


	$('img.easyHover').live('mouseover',function()
	{
		if($(this).data('hover'))
		{
			$(this).attr('src',$(this).data('hover'));
		}
		else
		{
			$(this).attr('src',$(this).attr('src').replace('off','on'));
		}

	}).live('mouseout',function()
	{
		if($(this).data('normal'))
		{
			$(this).attr('src',$(this).data('normal'));
		}
		else
		{
			$(this).attr('src',$(this).attr('src').replace('on','off'));
		}
	});

	$('.scrollTo').live('click',function()
	{ 
		SoftScroll.go($(this).attr('data-scrollTo'));
	});

});// end on ready

function onBlur() {
	window.$marquee.fadeTo(500,0.5,function(){$(this).trigger('stop')});
	window.hasFocus = false;
};
function onFocus(){
	window.$marquee.trigger('start').fadeTo(500,1);
	window.hasFocus = true;
};

$(window).load(function()
{
	//setTimeout('$("#shade").fadeOut(2000);',1000);
	window.$ticker = $('.ticker').SetScroller({
		velocity: 80,
		direction: 'horizontal',
		startfrom: 'right',
		loop: 'infinite',
		movetype: 'linear',
		onmouseover: 'pause',
		onmouseout: 'play',
		onstartup: 'play'
	});

});

function onBlur() {
	window.$ticker.fadeTo(500,0.5,function(){$(this).trigger('stop')});
	window.hasFocus = false;
};
function onFocus(){
	window.$ticker.trigger('start').fadeTo(500,1);
	window.hasFocus = true;
};

window.SoftScroll = {go:function(id) {
		if(id == 'header')
		{
			$('body').scrollTo({top:0,left:0}, 500);
			return;
		}
		//$('#content').scrollTo($('#'+id),500);
		$('body').scrollTo($('#'+id),500, {offset: {top:-70} });
	}
	/*, scrollTo: function(x,y)
	{ 
		$('#content').scrollTo({top:y+'px',left:x+'px'},500);
	}*/
};

