jQuery(document).ready(function()
{
	jQuery('#top-tease-ticker').marquee({yScroll:'bottom'});
	jQuery('#breaking-news').marquee({yScroll:'bottom'});

	jQuery('#hl-scoop-form').fancybox({hideOnContentClick:false, callbackOnShow: setupContact7Form});
	jQuery('#hl-brit-form').fancybox({hideOnContentClick:false, callbackOnShow: setupContact7Form});
	jQuery('#hollywood-signup-link').fancybox({hideOnContentClick:false, callbackOnShow: setupSignupForm, frameHeight: 500});


	jQuery('.contest_form').submit(function()
	{
		jQuery(this).ajaxSubmit({
			dataType: 'json',
			beforeSubmit: function(formData,jqForm,options) {
				jQuery('#contestajaxsignifier').attr("value",1);
				//alert(jQuery.param(formData));
			},
			success: function(result)
			{
				var formWrapper = jQuery('.contest_form').parent();
				if(result.success)
				{
					formWrapper.html("<p>Thank you for your submission!</p>");
				}
				else
				{
					var error_html = "";
					for ( var i in result.errors) {
						error_html = error_html+"<li>"+result.errors[i]+"</li>";
					}
					formWrapper.find('ul.errors').html(error_html);
				}
			}
		});
		return false;
	});

	jQuery('#login-popup').fancybox({
		'width':400,
		'height':500,
		'hideOnContentClick':false
	});
	jQuery('#register-popup').fancybox({
		'width':400,
		'height':500,
		'hideOnContentClick':false
	});


});

var setupSignupForm = function()
{
	jQuery('.su_form').submit(function()
	{
		jQuery(this).ajaxSubmit({
			dataType: 'json',
			success: function(result)
			{
				var formWrapper = jQuery('.su_form').parent();
				if(result.success)
				{
					formWrapper.html("<p>Thank you for signing up!</p>");
				}
				else
				{
					formWrapper.find('ul.errors').html(result.error_html);
				}
			}
		});
		return false;
	});
};

var setupContact7Form = function()
{
	try {
		jQuery('#fancy_div div.wpcf7 > form').ajaxForm({
			beforeSubmit: wpcf7BeforeSubmit,
			dataType: 'json',
			success: wpcf7ProcessJson
		})

		var tag = jQuery("#fancy_div div.wpcf7 > form input[name='_wpcf7_unit_tag']");
		jQuery("'#fancy_div div.wpcf7").attr("id", jQuery("'#fancy_div div.wpcf7").attr('id') + '-fancy');
		tag.val(tag.val() + '-fancy');
	} catch (e) {
	}

	try {
		jQuery('#fancy_div div.wpcf7 > form').each(function(i, n) {
			wpcf7ToggleSubmit(jQuery(n));
		});
	} catch (e) {
	}
};

var setupContestForm = function()
{

};
