// Plugin : Watch Now
// File : JS
// Author : Fawaz Tahir
// Version : 1.0


// Function used insert the div in which player will load
// @element : Which tag to which will be appened
function insert_ajax_div(element) {
	$('<div id="lightbox" />').appendTo(element)
}

// Function used to close the lightbox
function close_watch_now() {
	$(".watch_vdo").remove();	
	$("#lightbox").hide();
}

// Function used to update top and left value of lightbox div
// @player_width : Width of your ClipBucket Player
// @player_height : Height of your Clipbucket Player

function update_position(player_width,player_height) {
		var Conheight =	$(window).height();
		var ConWidth = $(window).width();
		
		$("#lightbox").css({
			"position" : "fixed",
			"left" : ConWidth / 2 - player_width / 2,
			"top" : Conheight / 2 - player_height / 2
		});	
}

// Function used to center the lightbox div in your visible window
// @player_width : Width of your ClipBucket Player
// @player_height : Height of your Clipbucket Player
function centerDiv(player_width,player_height) {
	$(window).bind("load",function() {
		update_position(player_width,player_height);
	});
	
	$(window).bind("resize",function() {
		update_position(player_width,player_height);									 
	});
}

// Function used to make an ajax call and get values of video
// @vid : ID of video you want to watch
// @div : the Div in which ajax result will be displayed

function watch_now(vid,div) {
	var page = baseurl+"/plugins/watch_now/functions/watch_now_ajax.php";
	
		$(div).css("display","block");
		$(div).html(loading);
		$.post(page, 
		{
			vid : vid,
		},
		function(data)
		{
			$(div).html(data);
		},'text');
}
