
function popVideo(vid){
	
	$("#displayVideo").html(vid);
	showVideo();
	
}


$(document).ready(function(){
		
		
		
		
		$(window).resize(function () {
					PositionVideo();
				});
		

});
	
function getVideoWidth(){

		var sWidth = $("#displayVideo").html();
		var items = sWidth.split("=");

		
		var i=0;
		while (i < items.length)
		 {
			if(items[i].indexOf("width")>-1){
				sWidth = items[i + 1].split(" ")[0].replace("\"", "").replace("'", "").replace("\"", "").replace("'", "");
			}
	  		i++;
  		}
		
		return sWidth;

}
	
function PositionVideo(){

		
		var items = sWidth.split("=");
		
		var i=0;
		while (i < items.length)
		 {
			if(items[i].indexOf("width")>-1){
				sWidth = items[i + 1].split(" ")[0].replace("\"", "").replace("'", "").replace("\"", "").replace("'", "");
			}
	  		i++;
  		}


		
		
		var WH = $(window).height();
		var WW = $(window).width();


		
       				
		$("#max").height(WH);
        	$("#max").width(WW);
	        $("#max").css("width", $(window).width());
       		$("#max").css("height", $(window).height() + 100);
        	var vw  = ($(window).width()*.5) - ($("#displayVideo").width()*.5);
		var vh =  ($(window).height()*.5) - ($("#displayVideo").height() *.5);
		

		
        	$("#divPlayer").css("left", vw);
		$("#divPlayer").css("top", vh);
		$("#divPlayer").css("z-index","99999999");

}

	function closeVideo() {
        $("#max").hide();
     
        var playerhtml = $("#divPlayer").html();
        var player = $("#divPlayer");
        player.html(playerhtml);
        $("#divVideoPopUp").css("display", "none");
	$("#btnClose").css("display","none");

    }
    
    function showVideo() {
        //show video popup
	
	sWidth = getVideoWidth();

	$("#displayVideo").css("width", sWidth );

        var topPic = $("#divVideoPopUp").offset().top + 100;
        var topButton = $("#divVideoPopUp").offset().top + 75;
        var leftButton = $("#divPlayer").width();

        $("#max").css("width", $(window).width());
        $("#max").css("height", $(window).height());
        $("#max").css("background-color", "#303030");
        $("#max").css("filter", "alpha(opacity=80)");
        $("#max").css("opacity", "0.8");

        $("#max").css("position", "fixed");
        $("#max").css("top", "0px");
        $("#max").css("left", "0px");
        $("#max").css("z-index", "99999");
        $("#max").fadeIn(1500);
	$("#divVideoPopUp").css("z-index", "999999");
        
	

	//$("#btnClose").css("position", "relative");	
	//$("#btnClose").css("right", sWidth);
	$("#btnClose").css("display","block");
        $("#divVideoPopUp").css("display","block");
	PositionVideo();


    } 



