$(
	function()
	{
		$(".cssNewWin").each(
			function()
			{
				$(this).click(
					function()
					{
						$.Video.stopallswf();
					}
				);
			}
		);
		
		$(".cssVideo").each(
			function()
			{
				$(this).mouseover(
					function()
					{
						$(this).css('curosr' , 'pointer');
					}
				);
				
				$(this).click(
					function()
					{
						strTitle = $(this).attr('title');
						strTitle = ((strTitle != undefined)? strTitle : "" );
						strPath = $(this).attr('href');
						$.Video.show(strPath , strTitle );
						return false;
					}
				);
			}
		);
	}
);

$.Video = {
		"vtname"	: "vt_player",
		
		"getSwf"	: function(strName)
		{
			 if (navigator.appName.indexOf("Microsoft") != -1) 
			 {
				 return window[strName];
		     } 
			 else 
			 {
				 return document[strName];		         
		     }
		},
		
		'stopallswf': function()
		{
			$(".cssSwf").each(
				function()
				{
					strName = $(this).attr('id');
					objSwf = $.Video.getSwf(strName);
					
					try
					{
						objSwf.stopSwf();
					}
					catch (e)
					{
						
					}
					
				}
			);
		},
		
		"show" : function(strPath , strTitle , strType)
		{
			//alert(strPath);
			this.stopallswf();
			$.Main.openMask();
			$("#ui-mask").mouseover(
				function()
				{
					//$(this).css('cursor' , 'pointer');
				}
			);
			$("#ui-mask").click(
				function()
				{
					$.Video.close();
				}
			);
			
			$("#ui-swfplayerol").remove();
			objPlayer = $("<div id='ui-swfplayerol'></div>");
			$("body").append(objPlayer);
			
			objPlayer.css('position' , 'absolute');
			objPlayer.css('z-index' , '101');
			objPlayer.css('top' , '0');
			objPlayer.css('left' , '0');
			objPlayer.css('background' , '#333333');
			
			objFrame = "<div class='cssCtl' style='text-align:right' >";
			objFrame+= "<div class='cssTitle'></div><div class='cssClose'><a href='#'><img src='v2/images/close.png' /></a></div></div>";
			objFrame+= "<div class='cssVt' ></div>";
			objPlayer.html(objFrame);
			
			switch(strType)
			{
				//320x240
				default:
					obj = new Object();
					obj.wmode = "transperant";
					obj.p = strPath;
					
					objPlayer.find(".cssVt:eq(0)").html("<div id='olvt_src'></div>");
					swfobject.embedSWF("v2/images/swf/player320x240.swf", "olvt_src", "320" , "240", "9.0.0.0", "js/swfobject/expressInstall.swf", obj, obj, obj )
				
					objPlayer.find("div.cssCtl:eq(0)").css('width' , '320px');
					objPlayer.css('top' , $(window).scrollTop() + ($("#ui-mask").height() - 340 )/ 2 );
					
					objPlayer.css('left' , ($("#ui-mask").width() - 320 )/ 2 );
				break;
			}
			objPlayer.find("div.cssCtl:eq(0)").css('height' , '20px');
			objPlayer.find("div.cssTitle").css('float' , 'left');
			objPlayer.find("div.cssTitle:eq(0)").html(strTitle);
			objPlayer.find("div.cssTitle:eq(0)").css('color' , '#ffffff');
			objPlayer.find("div.cssClose").css('float' , 'right');
			objPlayer.find("div.cssClose:eq(0)").find("a").click(
				function()
				{
					$.Video.close();
					
					return false;
				}
			);
			
			
		},
		
		"close": function()
		{
			$("#ui-swfplayerol").remove();
			$.Main.closeMask();
		}
};

