// JavaScript Document
/*
	latest update:13/05/2009
	Author:Paul
*/
function showmask(contentid,h,w,videopath,videocover,title){	
	var bg = $("#mask");

	
	bg.css({top:"0px",left:"0px",width:$(window).width()+"px",height:$(document).height()+"px",position:"absolute",zIndex :10});
	
	bg[0].ondblclick = function(){		
		close_div();
	}
	$('.popupHeader .txt').text(title);
	


	var box = document.getElementById(contentid);
	box.style.top = $(window).height()/2-h/2+$(window).scrollTop()+"px" || $(window).height()/2-$(box).height()/2+$(window).scrollTop()+"px";
	box.style.left = $(window).width()/2-w/2+"px" || $(window).width()/2-$(box).width()/2+"px";
	box.style.zIndex = 11;
	box.style.position = "absolute";
	box.style.display = "block";

	var flashvars = {
		'videopath':videopath,
		'converpic':videocover,
		'autoplay':"1"
		};
	var params = {
	allowFullScreen: "true",
	allowScriptAccess: "always",
	wmode: "opaque"
	};
	var attr = {
	id: "myvideo",
	name: "myvideo"
	};	
	swfobject.embedSWF("flash/player.swf?rnd="+Math.random(), "myvideo", "348", "291", "9.0.0", "flash/expressInstall.swf", flashvars, params, attr);
	
	

	
	$(box).find(".btnclose").click(function(){close_div();})
	$(window).resize(function(){
		resize();	
	})
	resize = function()
	{
		bg.css({width:$(window).width()+"px",height:$(document).height()+"px"});


		box.style.top = ($(window).height()/2-$(box).height()/2+$(window).scrollTop())+"px";
		box.style.left = $(window).width()/2-$(box).width()/2+"px";	
		
	}
	$(window).scroll( function() {
		box.style.top = ($(window).height()/2-$(box).height()/2+$(window).scrollTop())+"px";
		box.style.left = $(window).width()/2-$(box).width()/2+"px";						   
	});
	
	
	
}
function getSWF(movieName)
{
		if (navigator.appName.indexOf("Microsoft") != -1)
		{
			return window[movieName];
		}
		else
		{
			return document[movieName];
		}
}
function close_div()
{    $('select').show();
	$("#mask").hide();
	getSWF("myvideo").jsclose();
	$("#popupBox").css({"display":"none",width:"350px",height:"330px"});
	

}
function doCallIMG(url,img,title){
	
	$("#mask").show().fadeTo("fast", 0.5, function(){
	 $('select').hide();								   
   	showmask('popupBox',348,291,url,img,title);
 }); 
	
}

