//設定顯示字的大小px
var word_size = 25;
var time = 10 ;
var Bcolor = "#FFFFFF";
var Lcolor = "#FFFFFF"

var BIG_WIDTH = 480 ;
var BIG_HEIGHT = 200;
var LITTLE_WIDTH = 480 ;
var LITTLE_HEIGHT = 80;

function setTime(milsec)
{
	time= milsec;
}

function setALLSize(var_w,var_h,var_w2,var_h2)
{
	BIG_WIDTH = var_w2 ;
	BIG_HEIGHT = var_h2;
	LITTLE_WIDTH = var_w ;
	LITTLE_HEIGHT = var_h;
}

function setBigBGcolor(color)
{
	Bcolor = color ;
}



//顯示出object 大跟小
function ShowAD(flgId2,url,about)
{
var w;
var h;
if (flgId2==1)
{
	w = LITTLE_WIDTH;
	h = LITTLE_HEIGHT;
	document.write("<object id='swfLittle'  classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 codebase=http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0 width=" );
}
if (flgId2==2)
{
	w = BIG_WIDTH;
	h = BIG_HEIGHT;
	document.write("<object id='swfBIG' classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 codebase=http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0 width=" );
}
	document.write( w  );
	document.write(" height= ");
	document.write(h  );
	document.write(" id=" );
	document.write(w);
	document.write("-");
	document.write(h);
	document.write(" align=middle>");
	//window.alert("<object classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 codebase=http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0 width=" + LITTLE_WIDTH + " height=" + LITTLE_HEIGHT + " id=" + LITTLE_WIDTH + "-" + LITTLE_HEIGHT + " align=middle>");
	document.write("<param name=allowScriptAccess value=sameDomain />");
        document.write("<param name=\"wmode\" value=\"transparent\">");
	document.write("<param name=movie value=" + url + " /><param name=quality value=high /><param name=bgcolor value=#ffffff /><embed src=" + url + " quality=high bgcolor=#ffffff width=" + w + " height=" + h + " name=" + w + "-" + h + " align=middle allowScriptAccess=sameDomain type=application/x-shockwave-flash pluginspage=http://www.macromedia.com/go/getflashplayer swLiveConnect='true' wmode ='transparent'/>");
	document.write("</object>");
	document.write("<a href='"+about+"'>前往廣告</a>　");

if (!justOnlySmall)	{ //只有大廣告時才有, 開啟關閉大廣告
	if (flgId2==1)
	{

		document.write("<a href='javascript:funSWFinf(2);'>開啟廣告</a>");
		document.getElementById("little").style.width = w +"px";
		document.getElementById("little").style.height = (h + word_size) +"px";
	}

	if (flgId2==2)
	{
		document.write("<a href='javascript:funSWFinf(1);'>關閉廣告</a>");
		document.getElementById("big").style.width = w+"px";
		document.getElementById("big").style.height = (h + word_size) +"px";

	}
}

}

function setBigSWFStop()
{
var oBrowser = new detectBrowser();

	if (oBrowser.isIE)
	{
		//alert("test!");

	  //window.swfBIG.TStopPlay("stopsound");

	  document.swfBIG.gotoframe(1);
	  //window[swfBIG].TStop("end");
	  //document.swfBIG.Play();
	  document.swfBIG.StopPlay();
	  //document.swfBIG.Stop();
	  //document.swfBIG.TStop("end");

	  //document.swfBIG.play();

	}
}

function setBigSwfPlay()
{
	 var oBrowser = new detectBrowser();
	if (oBrowser.isIE)
	{
	    document.swfBIG.gotoframe(0);
		document.swfBIG.Play();
	}
}

//顯示flash
function funSWFinf(flgId )
{

if(flgId == 1){
document.getElementById("body_ad").style.background = Lcolor;

//如果是要縮小,直接縮小
document.getElementById("body_ad").style.width = LITTLE_WIDTH + "px";
document.getElementById("body_ad").style.height= (LITTLE_HEIGHT + word_size) + "px";
document.getElementById("little").style.display= "block";
document.getElementById("big").style.display= "none";
setBigSWFStop();


}
//如果要放大,設定timeout 時間,慢慢放大
if(flgId == 2){
	document.getElementById("body_ad").style.background = Bcolor;
	reSize();//原始大小,要變到的大小

//alert(document.getElementById("body_ad").style.bgcolor);
}
}

var i ;
function reSize()
{
	i = LITTLE_HEIGHT + word_size;
	chg_h = BIG_HEIGHT + word_size;

	document.getElementById("body_ad").style.height= document.getElementById("little").style.height;
	document.getElementById("body_ad").style.width= document.getElementById("little").style.width;
	document.getElementById("little").style.display= "none";
    //document.getElementById("body_ad").style.width = "250px";
    setTimeout("size(" + chg_h + ");",time);
    //document.getElementById("body_ad").style.height= i+"px";//'"'+i+'px"';
    //window.alert(i);


}

function size(s)
{

  if(i < s)
  {
    document.getElementById("body_ad").style.height= i+"px";

    i =i + 4 ;
    setTimeout("size(" + s + ");",time);
  }
  else
  {
	document.getElementById("body_ad").style.background = Lcolor;
    i=LITTLE_HEIGHT;//回覆成初始值
    document.getElementById("big").style.display= "block";
	setBigSwfPlay();


  }
}


function detectBrowser()//判斷是否用IE瀏覽器
 {

  var sAgent = navigator.userAgent.toLowerCase();
  this.isIE = (sAgent.indexOf('msie')!=-1); //IE6.0-7
  this.isFF = (sAgent.indexOf('firefox')!=-1);//firefox
  this.isSa = (sAgent.indexOf('safari')!=-1);//safari
  this.isOp = (sAgent.indexOf('opera')!=-1);//opera
  this.isNN = (sAgent.indexOf('netscape')!=-1);//netscape
  this.isMa = this.isIE;//marthon
  this.isOther = (!this.isIE && !this.isFF && !this.isSa && !this.isOp && !this.isNN && !this.isSa);//unknown Browser
 }





