function onInputFocus(o, helperText) {
	o.val(jQuery.trim(o.val()));
	if(o.val() == helperText) {
		o.val('');
		o.css('color','#1e1833');
	}
	return false;
}

function onInputBlur(o, helperText) {
	o.val(jQuery.trim(o.val()));
	if(o.val() == '') {
		o.val(helperText);
		o.css('color','#777');
	}
	return false;
}
var gameClicked = false;

function simpleFlashShadowBox(swf, width, height) {
	if(!$('#shadowboxHolder').length) {
		$('body').append('<div id="shadow"><div id="shadowboxHolder" style="width:' + width + 'px;">' +
		'<div id="shadowboxHeader"><a id="shadowboxClose" href="javascript:">close</a></div>' + 
		'<div id="shadowboxFlash" href="javascript:">You need the free <a href="http://www.adobe.com">Adobe Flash Player</a> to view this content</a></div>' +
		'</div></div>');
		
		var so = new SWFObject(swf,'fl',width, height,'9','#FFFFFF');
        so.addParam('wmode','transparent');
		so.write('shadowboxFlash');
		
		$('#shadowboxClose').click(function() {
			$('#shadow').hide();
		});			
	}
	
	$('#shadow').show();
}
var closetimer = 0;

$(document).ready(function() {
	Shadowbox.init({
		skipSetup: false,
		language: 'en'
		, players:  ['img', 'html', 'iframe', 'swf', 'flv']
		, useSizzle : true
		, handleOversize: 'none',
		viewportPadding: 0  // no padding
	});
	// setting the .path in the init options doesn't work
	Shadowbox.path = '/js/shadowbox/';

	$('#headerForms input#email').focus( function() { return onInputFocus($(this),'Email'); } );
	$('#headerForms input#email').blur( function() { return onInputBlur($(this), 'Email'); } );
	$('#headerForms input#query').focus( function() { return onInputFocus($(this),'Search'); } );
	$('#headerForms input#query').blur( function() { return onInputBlur($(this), 'Search'); } );
	$('#headerForms input#passwordhelper').focus( function() {
		$(this).hide();
		$('input#password').css('color','#1e1833');
		$('input#password').show();
		$('input#password').focus();
		return false;
	});
	$('#headerForms input#password').blur( function() {
		if($(this).val() == '') {
			$(this).hide();
			$('input#passwordhelper').show();
		}
		return false;
	});

	$('#watchCaduceusTrailer').click(function(){
		Shadowbox.open({
			content: '/swf/chtTrailer.swf',
			player: 'swf',
			width: '720',
			height: '405',
			handleOversize: 'none'
		});
		$('#sb-wrapper').attr('class','mediumFrame');
		return false;
	});
	
	$('#watchRachelsMom').click(function(){
		Shadowbox.open({
			content: '/media/videos/rachels_mom.flv',
			player: 'flv',
			width: '720',
			height: '385',
			handleOversize: 'none'
		});
		$('#sb-wrapper').attr('class','mediumFrame_purple');
		return false;
	});
	
	$('#watchZebraFishTrailer').click(function(){
		Shadowbox.open({
			content: '/swf/Zfish_trailer.swf',
			player: 'swf',
			width: '576',
			height: '324',
			handleOversize: 'none'
		});
		$('#sb-wrapper').attr('class','smallFrame');
		return false;
	});	

	$(".playNow,#playNow").click(function(){
		Shadowbox.open({
			content: '/swf/caduceus3.swf',
			player: 'swf',
			width: '900',
			height: '600',
			handleOversize: 'none'
		});
		$('#sb-wrapper').attr('class','largeFrame');
		return false;
	});
	$(".sampleG4G").click(function(){
		Shadowbox.open({
			content: '/swf/moleculesDemo.swf',
			player: 'swf',
			width: '900',
			height: '600',
			handleOversize: 'none',
			viewportPadding: 0
		});
		$('#sb-wrapper').attr('class','largeFrame');
		return false;
	});	
	
	$('.menuDropDown li').hover(
			function() { $('ul', this).css('display', 'block'); },
			function() { $('ul', this).css('display', 'none'); }
	);	
});
