var hpc =
{
	init: function()
	{
		this.ready = true;
		$("a.gallery").fancybox(
		{
			cyclic: true,
			overlayOpacity: 0.6,
			overlayColor: '#000000',
			titlePosition: 'over'
		});
		
		$("a.contact").click( function(e)
		{
			e.preventDefault();
			var contactWindow = window.open(hpc.templatePath + "contact.php", "contactWindow", "width=10,height=10", "");
			setTimeout( function() { contactWindow.close(); }, 5000);
		});
	},
	ready: false,
	templatePath: "http://www.heritagepoultry.org/wp-content/themes/heritage-poultry/"
};


var video =
{
	make: function(file, container)
	{
		var so = new SWFObject('http://www.pallensmith.com/assets/videos/flvplayer.swf','video-' + Math.random(),'384','231','9');
		so.addParam('allowscriptaccess','always');
		so.addParam('allowfullscreen','true');
		so.addParam('flashvars','file=' + file);
		so.write(container);
		if($("#"+container).css("display") == "none")
		{
			$("#"+container).show();
			$("ul#vids").append('<li><a style="font-weight:bold;" href="close video player" id="close-vidplayer">hide video player</a></li>');
			$("#close-vidplayer").click( function(e)
			{
				e.preventDefault();
				$(this).parent().remove();
				$("#video-player").hide();
			});
		}
	},
	multiple: function()
	{
		$("div#videos li.video a").click( function(e)
		{
			e.preventDefault();
			video.make($(this).attr("href"), "video-player");
		});
	}
}



function load(file, where)
{
	$.ajax(
	{
		url: file,
		success: function(data) { $(where).html(data); },
		error: function(xhr) { window.alert("File could not be loaded. STATUS: " + xhr.status) }
	});
}


function wait(delayedFunction)
{
	var myint = setInterval( function()
	{
		if(hpc.ready === true)
		{
			delayedFunction();
			clearInterval(myint);
		}
	}, 500);
}
