/* popup text block

 * widget by IonDen

 * v 1.0

 * 06.05.2010

 * depends on jQuery 1.4

 */

$(document).ready(function(){

	var master_height = $("body > div").innerHeight();

	var master_video = "";

	var mv_pop = "";

	var scr_height = 0;

	var scr_top = 0;

	var tv_width = 0;

	var tv_height = 0;

	

	$("a.show_video").click(function(event) {

		event.preventDefault();

		master_video = $(this).attr("rel");

		tv_width = master_video.slice(master_video.indexOf('width'),master_video.indexOf('height'));

		tv_height = master_video.slice(master_video.indexOf('height'),master_video.indexOf('>'));

		

		tv_width = parseInt(tv_width.slice(7));

		tv_height = parseInt(tv_height.slice(8));

		mv_pop = '<div id="big_grey"></div>';
		mv_pop += '<div id="big_video"><span><a href="#" id="bv_close">закрыть</a></span><div>';
		mv_pop += master_video;
		mv_pop += '</div></div>';
	
		$("body").append(mv_pop);
		$("#big_video > span").width(tv_width - 18).css("left", -(tv_width/2)).css("top", -(tv_height/2) - 64);
		$("#big_video > div").width(tv_width).height(tv_height).css("left", -(tv_width/2)).css("top", -(tv_height/2) - 40);
		

		if(navigator.userAgent.indexOf("MSIE 6.0") !== -1) {

			scr_height = parseInt($(window).height() / 2);

			scr_top = parseInt($(window).scrollTop());

			var z = scr_top + scr_height;

			$("#big_video").css("top", z);

		}

		

		$("#big_grey").height(master_height);

		$("#bv_close").click(function(event) {

			event.preventDefault();

			$("#big_grey").remove();

			$("#big_video").remove();

			master_video = "";

		});

	});

});
