$(document).ready(function(){
	
	var video = "";
	var title = "";
	var keyword = "";
	$('.loader').hide();
	
	$('#search_form').ajaxForm({ 
		target: '#result', 
		success: function() { 
			$('.loader').hide();
			$('.iT').fadeIn('500');
			$('#result').fadeIn('500');
		} 
	}); 
	$("#search_form").submit(function(){
		$('.iT').hide();
		$('#result').hide();
		$('.loader').fadeIn('300');
	});
	
	$("#result li").livequery(function(){
		$(this).click(function(){
			video = $(this).attr("video");
			$('#controllers').hide();
			$('#controllers').fadeIn('500');
			title = $(this).attr("title");
			$(".active").removeClass("active");
			$(this).addClass("active");
			$("#video").fadeOut(50);
			playVideo(video);
			$("#video").fadeIn(300);
		});
	});

});

function playVideo(pStream) {
	var s1 = new SWFObject("http://blip.tv/scripts/flash/showplayer.swf","mediaplayer",500,375,"7");
	s1.addParam("allowfullscreen","true");
	s1.addVariable("width",500);
	s1.addVariable("height",375);
	s1.addVariable("file",pStream);
	s1.addVariable("shownavigation", false);
	s1.addVariable("autostart", true);
	s1.addVariable("showguidebutton", true);
	s1.addVariable("showsharebutton", true);
	s1.addVariable("brandname", "pandavideo");
	s1.addVariable("showplayerpath", "http://blip.tv/scripts/flash/showplayer.swf");
	s1.write("video");
}