/**
 * @author Administrator
 */
function ArtronFloatAdSystem()
{
	//this的上下文
	this.SizeUnit="px";
	this.Interface="";
	this.BoxDivId="ArtronFloatAd";
	this.BoxClass="ArtronFloatAdStyle";
	this.BoxHeight=null;
	this.BoxWidth=null;
	this.ClosedBoxId="ArtronFloatAdClosedBox";
	this.ClosedBoxClass="ArtronFloatAdClosedBoxStyle";
	this.Space="left";
	
	this.MagrinTop=70;
	this.ClosedBoxHeight=null;
	this.ClosedBoxWidth=null;
	this.FlashUrl="";
	this.ImageUrl="";
	this.ImageTitle="";
	this.ImgeLink="";

	/**
	 * 建立播放内容的容器
	 */
	this.CreateBoxDiv = function()
	{
		var DivObj=document.createElement("div");
		DivObj.className= this.BoxClass;
		DivObj.id= this.BoxDivId;
		DivObj.innerHTML= this.BoxContent();
		document.body.appendChild(DivObj); 
		
	}
	/**
	 * 调用程序运行
	 */
	this.Run=function()
	{
		if ( this.BoxHeight ==null || this.BoxWidth==null || this.ClosedBoxHeight==null || this.ClosedBoxWidth ==null )
		{
			alert("未初始化高度及宽度信息，请检查调用方式");
			return false;
		}
		this.CreateBoxDiv();
		this.CreateClosedBox();
	}
	this.Replay=function()
	{
		var BoxObj= document.getElementById(this.BoxDivId);
		BoxObj.innerHTML= this.BoxContent();
		BoxObj.style.display="";
		this.RemoveFloatDiv();
	}
	/**
	 * 关闭播放窗口
	 */
	this.CloseBox=function()
	{
		var BoxObj= document.getElementById(this.BoxDivId);
		if(BoxObj.style.display=="")
		{
			BoxObj.style.display="none";
			this.ShowFloatDiv();
		}
	}
	/**
	 * 清除浮动的div
	 */
	this.RemoveFloatDiv=function()
	{
		var ClosedBoxObj=document.getElementById(this.ClosedBoxId);
		ClosedBoxObj.style.display="none";
	}
	/**
	 * 显示控制框
	 */
	this.ShowFloatDiv=function()
	{
		var ClosedBoxObj=document.getElementById(this.ClosedBoxId);
		ClosedBoxObj.style.display="";
	}
	/**
	 * 创建关闭后的容器
	 */
	this.CreateClosedBox=function()
	{
		var DivObj=document.createElement("div");
		DivObj.id= this.ClosedBoxId;
		DivObj.className= this.ClosedBoxClass;
		DivObj.innerHTML= this.ClosedBoxContent();
		DivObj.style.display="none";
		document.body.appendChild(DivObj); 
	}
	/**
	 * 关闭窗口中的内容
	 */
	this.ClosedBoxContent=function()
	{
		var String='<div id="xtt_ad"><div class="xtt_ad_top"><a href="javascript:'+ this.Interface+'.Replay()"><img src="images/100325_xtt_ad_fpRback.jpg" width="27" height="27" alt="重新播放" /></a></div><div class="xtt_ad_content"><a href="'+this.ImgeLink+'" target="_blank"><img src="'+this.ImageUrl+'" width="27" height="196" alt="'+ this.ImageTitle +'" /></a></div><div class="xtt_ad_bottom"><a href="javascript:'+this.Interface+'.RemoveFloatDiv()"><img src="images/100325_xtt_ad_fpRclose.jpg" width="27" height="27" alt="关闭广告" /></a></div><div class="clearcss"></div></div>'
		return String;
	}
	/**
	 * 播放窗口中的内容
	 * 维护内容请在此处修改
	 */
	this.BoxContent=function()
	{
		var String='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="120" height="250"><param name="movie" value="' + this.FlashUrl +'" /><param name="quality" value="high" /><param name="WMODE" value="transparent"><embed src="'+ this.FlashUrl +'" quality="high" wmode="transparent" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="120" height="250"></embed></object>';
		return String;
	}
	/**
	 * 维持元素位置
	 */
	this.MaintainSpace=function()
	{
		//初始化定位信息
		var Height=$(window).height();
		var Width= $(window).width()
		var Top= this.MagrinTop;
		var Left =Width - this.BoxWidth -5 ;
		var ScrollPx ; 
		if(document.body.scrollTop)
		{
			ScrollPx = document.body.scrollTop;
		}
		else
		{
			ScrollPx = document.documentElement.scrollTop;
		}
		//定位播放窗口
		var AdPlayDiv=document.getElementById(this.BoxDivId);
		Top=Top+ScrollPx;
	
		if (!AdPlayDiv||AdPlayDiv==null)
		{
			
			return;
		}
		AdPlayDiv.style.top= this.ConvertToStyle(Top);
		if (this.Space=="right")
		{
			Left= Left-0;
			AdPlayDiv.style.left= this.ConvertToStyle(Left);	
		}
		else
		{
			AdPlayDiv.style.left= this.ConvertToStyle(5);
		}
	   //定位关闭窗口
		var AdbottonDiv=document.getElementById(this.ClosedBoxId);
		var BTop= this.MagrinTop;
		BTop=BTop+ScrollPx;
		if (!AdbottonDiv||AdbottonDiv==null)
		{
			return;
		}
		//距上
		AdbottonDiv.style.top=this.ConvertToStyle(BTop);
		if (this.Space == "right") 
		{
			             Crwidth= Width - this.ClosedBoxWidth - 5;
			AdbottonDiv.style.left=this.ConvertToStyle( Crwidth -0);	 
		}
		else
		{
			
			AdbottonDiv.style.left=this.ConvertToStyle(5); 
		}
	}
	/**
	 * 转换高度到样式
	 * @param {Object} IntVlaue
	 */
	this.ConvertToStyle=function(IntVlaue)
	{
		var String= IntVlaue +""+ this.SizeUnit;
		return String;
	}
}
