/**
* File manager banner. 
* Type:		JavaScript<br>
* Name:		library.js <br>
* Date:		July 1, 2007<br>
* @author	Truong Vinh Khoa <khoatruong@von-inc.com, seameo2002@yahoo.com>
* @version  1.1
* @copyright CopyrightŪ &copy; 2007, TimNhanh.com - Vietnam Online Network Company (VON)
*/

var globalBanner;
var theDivObjectName;
var g_arrTNBox = new Array();
/**
* Type:		function
* Name:		OpenWindow
* Func:		Mo cua so moi khi click vao banner
* Param:	url: link mo cua so moi
			name: ten cua cua so moi
*/

var OpenWindow = function (url, name) 
{
	newwindow=window.open(url, name);
	/* 
	 * Open Popup
	 */
	if (window.focus) 
	{
		newwindow.focus();
	}
	return true;
}

/**
* OOP Banner
*/
var TNBanner = function(){}
TNBanner.prototype={
	m_id:null,
	m_randomBannerIndex:0,
	m_arrBanner:null,
	m_theDivObjectName:'',
	m_tableAttributes:'',
	m_tdAttributes:'',
	m_interval:null,
	m_height:0,
	m_width:0,
	m_wmode:false,
	m_url:'',
	m_target:'',
	m_position:'',
	m_slide:null,
	m_rand:false,
	m_expand:'',
	m_t:null,
	m_parent:null,
	/*
	* Type:	function
	* Name: setName
	* Func:	Tao ten cho banner
	* Param:	name: ten dua vao
	*/
	setName:function(name)
	{
		name = name||null;
		if( name ) {
			if( name.constructor.toString().indexOf("String") )
			{	return name; }
		}
		else if(name==null || name.constructor.toString().indexOf("Array") || name.constructor.toString().indexOf("Object"))
		{
			date = new Date();
			name = date.getHours()+''+date.getMinutes()+''+date.getSeconds();
			return("slide"+Math.round(Math.random()*Math.pow(10,Math.round(Math.random()*10)))+name+Math.round(Math.random()*Math.pow(10,Math.round(Math.random()*10))));
		}		
	},
	/*
	* Type:	function
	* Name: makeADivObject
	* Func:	Tao doi tuong banner
	* Param:	divName: ID cua banner
	*/	
	makeADivObject:function(divName)
	{
		if(! this.getObjBanner(divName) )
			document.write('<div id="' + divName + '"></div>');
	},
	/*
	* Type:	function
	* Name: showBanner
	* Func:	Show html cho banner share
	* Param:	bannerArr: mang banner
				theDiv: doi tuong banner
				randomIndex: vi tri hien banner show trong mang
				wmode: thuong tinh cua flash
	*/	
	showBanner:function(bannerArr, theDiv, randomIndex, wmode)
	{
		var theOutputString = "";
		tableAttributes=this.m_tableAttributes;
		tdAttributes=this.m_tdAttributes;
		expand=this.m_expand||'';
		bannerArr[randomIndex][0]=parseInt(bannerArr[randomIndex][0]);
		switch (bannerArr[randomIndex][0])
		{
			case 99:
				if (bannerArr[randomIndex][4] != "") {
					if(bannerArr[randomIndex][5]!="_blank") {
						theOutputString += "<a href='"+bannerArr[randomIndex][4]+"'>"
						theOutputString += "<img src='"+bannerArr[randomIndex][3]+"' border='0' alt='"+bannerArr[randomIndex][6]+"' >"
						theOutputString += "</a>";
					} else {
						theOutputString += "<a href='"+bannerArr[randomIndex][4]+"' target='"+bannerArr[randomIndex][5]+"'>"
						theOutputString += "<img src='"+bannerArr[randomIndex][3]+"' border='0' alt='"+bannerArr[randomIndex][6]+"' >"
						theOutputString += "</a>";	
					}
				}
				else {
					theOutputString += "<img src='"+bannerArr[randomIndex][3]+"' border='0' alt='"+bannerArr[randomIndex][6]+"'>";
				}
				break;
			case 103:
				if(wmode){
					theOutputString += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+bannerArr[randomIndex][1]+'" height="'+bannerArr[randomIndex][2]+'">'
					theOutputString += '<param name="movie" value="'+bannerArr[randomIndex][3]+'?clicktag='+bannerArr[randomIndex][4]+'&clickTag='+bannerArr[randomIndex][4]+'&clickTAG='+bannerArr[randomIndex][4]+'&mDiv='+theDiv+'&expandType='+expand+'">'
					theOutputString += '<param name="wmode" value="transparent">'
					theOutputString += '<param name="allowScriptAccess" value="always">'
					theOutputString += '<embed allowScriptAccess="always" wmode="transparent" src="'+bannerArr[randomIndex][3]+'?'
					theOutputString += 'clicktag='+bannerArr[randomIndex][4]+'&clickTag='+bannerArr[randomIndex][4]+'&clickTAG='+bannerArr[randomIndex][4]
					theOutputString += '&mDiv='+theDiv
					theOutputString += '&expandType='+expand+'" '
					theOutputString += 'quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" '
					theOutputString += 'type="application/x-shockwave-flash" '
					theOutputString += 'width="'+bannerArr[randomIndex][1]+'" '
					theOutputString += 'height="'+bannerArr[randomIndex][2]+'">'
					theOutputString += '</embed>'
					theOutputString += '</object>';
					
				}else{
					theOutputString += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+bannerArr[randomIndex][1]+'" height="'+bannerArr[randomIndex][2]+'">'
					theOutputString += '<param name="allowScriptAccess" value="always">'
					theOutputString += '<param name="movie" value="'+bannerArr[randomIndex][3]+'?clicktag='+bannerArr[randomIndex][4]+'&clickTag='+bannerArr[randomIndex][4]+'&clickTAG='+bannerArr[randomIndex][4]+'&mDiv='+theDiv+'">'
					theOutputString += '<embed allowScriptAccess="always" src="' + bannerArr[randomIndex][3] + '?'
					theOutputString += 'clicktag='+bannerArr[randomIndex][4]+'&clickTag='+bannerArr[randomIndex][4]+'&clickTAG='+bannerArr[randomIndex][4]+'&mDiv='+theDiv + '" '
					theOutputString += 'quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" '
					theOutputString += 'type="application/x-shockwave-flash" '
					theOutputString += 'width="'+bannerArr[randomIndex][1] + '" '
					theOutputString += 'height="'+bannerArr[randomIndex][2] + '">'
					theOutputString += '</embed>'
					theOutputString += '</object>';
				}
				break;
		}
		
		var theDivObject = this.getObjBanner(this.m_id);
		if( this.m_parent )
		{
			bParent = this.getObjBanner(this.m_parent);
			bParent.appendChild(theDivObject);
		}
		if(theDivObject!=null && typeof theDivObject == 'object')
		{
			theDivObject.innerHTML = theOutputString;
			theDivObject = document.getElementById(this.m_id);
			theDivObject.outerHTML = theDivObject.outerHTML;
		}
		if( this.m_expand )
		{
			return theOutputString;
		}
		return ;
	},
	/*
	* Type:	function
	* Name: slideShow
	* Func:	Set time cho slide show
	* Param:	_id: id banner
	*/
	slideShow:function(_id)
	{
		b=g_arrTNBox[_id];
		if(b.interval != 'undefined' ||  b.interval != null)
		{	b.stop(b.interval); }
		
		randomIndex = b.m_randomBannerIndex;
		b.m_randomBannerIndex = (b.m_randomBannerIndex == b.m_arrBanner.length-1?0:b.m_randomBannerIndex+1);
		
		if( b.m_arrBanner.constructor.toString().indexOf('Array') && b.m_arrBanner.length >1) {
			b.wmode = false;
		}
		else {
			b.wmode = true; //
		}
		time=b.setTimer(b.m_arrBanner[randomIndex][3]);			
		//showBanner(b.m_arrBanner,b.m_id,randomIndex,b.wmode,b.m_tableAttributes,b.m_tdAttributes,b.m_expand);
		b.showBanner(b.m_arrBanner,b.m_id,randomIndex,b.wmode);
		
		if(!b.wmode && !b.m_expand)
			b.interval=b.start('g_arrTNBox["'+_id+'"].slideShow("'+_id+'")',time);
	},
	/*
	* Type:	function
	* Name: htmls
	* Func:	Set banner slide show
	* Param:	bannerArr: mang banner
				times: thoi gian display
				t: thuoc tinh cho cho banner( share/random )
	*/
	htmls:function(bannerArr, times,t)
	{
		try
		{
			if(bannerArr.length > 0)
			{
				g_arrTNBox[this.m_id] = this;
				this.m_interval=null;
				this.theDivObjectName=this.theDivObjectName||theDivObjectName;
				if(!this.m_expand)
					this.m_randomBannerIndex = this.random(bannerArr.length);
				if(t==108) {
					this.slideShow(this.m_id);
				} else if(t==182) {
					if( this.m_arrBanner.length >1 ) wmode=false;
					else wmode=true;
					this.showBanner(this.m_arrBanner,this.m_id,this.m_randomBannerIndex,wmode);
				}
			}
			return null;
		}
		catch(e){}
	},
	/*
	* Type:	function
	* Name: htmlr
	* Func:	Set banner random
	* Param:	bannerArr: mang banner
				t: thuoc tinh cho cho banner
	*/	
	htmlr:function(bannerArr,t)
	{
		theOutputString=''
		tableAttributes = this.m_tableAttributes
		tdAttributes = this.m_tdAttributes
		r=this.m_arrBanner;
		for(var i=0; i<r.length; i++)
		{
			bannerArr[r[i]][0] = parseInt(bannerArr[r[i]][0]);
			switch (bannerArr[r[i]][0])
			{
				case 99: //gif
					if (bannerArr[r[i]][4] != "")
					{
						if (bannerArr[r[i]][5] != "" && bannerArr[r[i]][5] != "_blank")
						{							
							theOutputString += "<tr>"
							theOutputString += "<td class='"+tdAttributes+"'>"
							theOutputString += "<a href='"+bannerArr[r[i]][4]+"' target='"+bannerArr[r[i]][5]+"' onclick='return OpenWindow(\""+bannerArr[r[i]][4]+"\",\""+bannerArr[r[i]][5]+"\")' >"
							theOutputString += "<img src='"+bannerArr[r[i]][3]+"' border='0' alt='"+bannerArr[r[i]][6]+"'>"
							theOutputString += "</a>"
							theOutputString += "</td>"
							theOutputString += "</tr>";
						} else {
							theOutputString += "<tr>"
							theOutputString += "<td class='"+tdAttributes + "'>"
							theOutputString += "<a href='"+bannerArr[r[i]][4]+"' target='"+bannerArr[r[i]][5]+"'>"
							theOutputString += "<img src='"+bannerArr[r[i]][3]+"' border='0' alt='"+bannerArr[r[i]][6]+"'>"
							theOutputString += "</a>"
							theOutputString += "</td>"
							theOutputString += "</tr>";
						}
					} else {
						theOutputString += "<tr>"
						theOutputString += "<td class='"+tdAttributes+"'>"
						theOutputString += "<img src='"+bannerArr[r[i]][3]+"' border='0' alt='"+bannerArr[r[i]][6]+"'>"
						theOutputString += "</td>"
						theOutputString += "</tr>";	
					}
					break;
				case 103: //flash
					theOutputString += '<tr>'
					theOutputString += '<td class="'+tdAttributes+'">'
					theOutputString += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+bannerArr[r[i]][1]+'" height="'+bannerArr[r[i]][2]+'">'
					theOutputString += '<param name="movie" value="'+bannerArr[r[i]][3]+'?clicktag='+bannerArr[r[i]][4]+'&clickTag='+bannerArr[r[i]][4]+'&clickTAG='+bannerArr[r[i]][4]+'">'
					theOutputString += '<param name="allowScriptAccess" value="always">'
					if(this.m_wmode)
					theOutputString += '<param name="wmode" value="transparent">'
					theOutputString += '<param name="quality" value="high">'
					theOutputString += '<embed allowScriptAccess="always" '
					if(this.m_wmode)
					theOutputString += 'wmode="transparent" '
					theOutputString += 'src="'+bannerArr[r[i]][3]+'?'
					theOutputString += 'clicktag='+bannerArr[r[i]][4]+'&clickTag='+bannerArr[r[i]][4]+'&clickTAG='+bannerArr[r[i]][4]+'" '
					theOutputString += 'quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" '
					theOutputString += 'type="application/x-shockwave-flash" '
					theOutputString += 'width="'+bannerArr[r[i]][1]+'" '
					theOutputString += 'height="'+bannerArr[r[i]][2]+'" >'
					theOutputString += '</embed>'
					theOutputString += '</object>'
					theOutputString += '</td>'
					theOutputString += '</tr>';
					break;
			}
		}
		
		var theDivObject = this.getObjBanner(this.m_id);
		if( this.m_parent )
		{
			bParent = this.getObjBanner(this.m_parent);
			bParent.appendChild(theDivObject);
		}
		if(theDivObject!=null && typeof theDivObject == 'object')
		{
			theDivObject.innerHTML = theOutputString||'';
			return null;
		}
		else return theOutputString;
	},
	/*
	* Type:	function
	* Name: htmln
	* Func:	Set banner normal
	* Param:	bannerArr: mang banner
	*/
	htmln:function(bannerArr)
	{
		tableAttributes=this.m_tableAttributes
		tdAttributes=this.m_tdAttributes
		theOutputString=''; var bannerArrLength = bannerArr.length-1;
		for(var i=0; i<=bannerArrLength; i++)
		{
			bannerArr[i][0]=parseInt(bannerArr[i][0]);
			switch (bannerArr[i][0])
			{
				case 99:
					// gif
					if (bannerArr[i][4] != "")
					{
						if (bannerArr[i][5] != "" && bannerArr[i][5] != "_blank")
						{						
							theOutputString += "<tr>"
							theOutputString += "<td class='" + tdAttributes + "'>"
							theOutputString += "<a href='" + bannerArr[i][4] + "' target='" + bannerArr[i][5] + "' onclick='return OpenWindow(\"" + bannerArr[i][4] + "\",\"" + bannerArr[i][5] + "\")' >"
							theOutputString += "<img src='" + bannerArr[i][3] + "' border='0' alt='" + bannerArr[i][6] + "'>"
							theOutputString += "</a>"
							theOutputString += "</td>"
							theOutputString += "</tr>";
						}
						else
						{
							theOutputString += "<tr>"
							theOutputString += "<td class='"+tdAttributes+"'>"
							theOutputString += "<a href='"+bannerArr[i][4]+"' target='"+bannerArr[i][5]+"'>"
							theOutputString += "<img src='"+bannerArr[i][3]+"' border='0' alt='"+bannerArr[i][6]+"'>"
							theOutputString += "</a>"
							theOutputString += "</td>"
							theOutputString += "</tr>";		
						}
					}
					else
					{
						theOutputString += "<tr>"
						theOutputString += "<td class='"+tdAttributes+"'>"
						theOutputString += "<img src='"+bannerArr[i][3]+"' border='0' alt='"+bannerArr[i][6]+"'>"
						theOutputString += "</td>"
						theOutputString += "</tr>";	
					}
					
					break;
				case 103:
					// flash
					theOutputString += '<tr>'
					theOutputString += '<td class="'+tdAttributes+'">'
					theOutputString += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+bannerArr[i][1]+'" height="'+bannerArr[i][2] + '">'
					theOutputString += '<param name="movie" value="' + bannerArr[i][3]+'?clicktag='+bannerArr[i][4]+'&clickTag='+bannerArr[i][4]+'&clickTAG='+bannerArr[i][4]+'&expandType='+this.m_expand+'&mDiv='+this.m_id+'">'
					theOutputString += '<param name="quality" value="high">'
					theOutputString += '<param name="allowScriptAccess" value="always">'
					if(this.m_wmode)
					theOutputString += '<param name="wmode" value="transparent">'
					theOutputString += '<embed allowScriptAccess="always" '
					if(this.m_wmode)
					theOutputString += 'wmode="transparent" '
					theOutputString += 'src="'+bannerArr[i][3]+'?'
					theOutputString += 'clicktag='+bannerArr[i][4]+'&clickTag='+bannerArr[i][4]+'&clickTAG='+bannerArr[i][4]+'&expandType='+this.m_expand+'&mDiv='+this.m_id+'" '
					theOutputString += 'quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+bannerArr[i][1]+'" height="'+bannerArr[i][2]+'" >'
					theOutputString += '</embed>'
					theOutputString += '</object>'
					theOutputString += '</td>'
					theOutputString += '</tr>';
					break;
			}
		}
		var theDivObject = this.getObjBanner(this.m_id);
		if( this.m_parent )
		{
			bParent = this.getObjBanner(this.m_parent);
			bParent.appendChild(theObjects);
		}
		if(theDivObject!=null && typeof theDivObject == 'object')
		{
			theDivObject.innerHTML = theOutputString||'';
			return null;
		}
		else return theOutputString;
	},
	/*
	* Type:	function
	* Name: setTimer
	* Func:	Khoi tao thoi gian cho slide show
	* Param:	file: loai file
	*/
	setTimer:function(file)
	{
		ext = file.substr(file.lastIndexOf('.')+1).toLowerCase();
		switch( ext )
		{
			case 'gif': case 'swf': case 'flv': time = this.times+1500; break;
			case 'jpg': case 'jpeg': case 'png': time = this.times; break;
			default: time = this.times;
		}
		return time||this.times;
	},
	/*
	* Type:	function
	* Name: stop
	* Func:	Ket thuc slide show
	* Param:	file: loai file
	*/
	stop:function(_id)
	{
		if(_id)
		{ window.clearInterval(_id) };
	},
	/*
	* Type:	function
	* Name: start
	* Func:	Khoi tao slide show
	* Param:	isfunction: ham thuc thi cho
				times: thoi gian cho
	*/	
	start:function(isfunction,times)
	{
		return window.setInterval(isfunction,times);
	},
	/*
	* Type:	function
	* Name: set
	* Func:	Thiet lap loai banner
	* Param:	bannerArr: mang banner
				times: thoi gian cho
	*/		
	set:function(bannerArr, times)
	{
		var o;
		try{
			this.m_t=parseInt(bannerArr[0][7])
			switch(this.m_t)
			{
				case 100: // 100: Random nhieu vi tri
					this.m_arrBanner=new Array();
					this.m_arrBanner=this.deal(bannerArr.length);
					o=this.htmlr(bannerArr, this.m_t); break;
				case 104: // 104 : Normal
					o=this.htmln(bannerArr); break;
				case 108: // 108 : Share
					o=this.htmls(bannerArr, times, this.m_t); break;
				case 129: // 129 : Right
					break;
				case 131: // 131 : Left
					break;
				case 182: // 182 : Random 1 vi tri
					o=this.htmls(bannerArr, times, this.m_t); break;
				default:
					o=this.htmln(bannerArr); break;
			}
			return o;
		}catch(e){}
	},
	/*
	* Type:	function
	* Name: random
	* Func:	Tao so ngau nhien trong N so
	* Param:	N: tap hop tao ngau nhien
	*/	
	random:function (N) { return Math.floor(N*(Math.random()%1)) },
	/*
	* Type:	function
	* Name: deal
	* Func:	Tao mang so ngau nhien trong N so
	* Param:	N: tap hop tao ngau nhien
	*/	
	deal:function (N) {
		var J, K, Q = new Array(N);
		for (J=0; J<N; J++) { K = this.random(J+1) ; Q[J] = Q[K] ; Q[K] = J }
		return Q ;
	},
	/*
	* Type:	function
	* Name: writed
	* Func:	In ra noi dung
	* Param:	content: noi dung
	*/
	writed:function(content)
	{
		content=content||'';
		document.write(content);
	},
	/*
	* Type:	function
	* Name: exit
	* Func:	Thoat chuong trinh
	*/
	exit:function(){ return; },
	/*
	* Type:	function
	* Name: getObjBanner
	* Func:	Get banner
	*/	
	getObjBanner:function(banner){
		var obj = (document.getElementById(banner));
		obj = obj || null;
		return obj;
	}
};

/**
*	function doSlideBanner(bannerArr, time_slide, divname, tableAttributes, tdAttributes)
*/
function doSlideBanner(bannerArr, times, divname, tableAttributes, tdAttributes)
{
	if(bannerArr.length > 0)
	{
		b=new TNBanner();
		b.m_arrBanner = new Array();
		for(i=0; i < bannerArr.length; i++)
		{
			b.m_arrBanner[i] = bannerArr[i];
		}
		b.m_id=b.m_theDivObjectName=b.setName(divname);
		b.m_tableAttributes=tableAttributes||'';
		b.m_tdAttributes=tdAttributes||'';
		if(!times)
			b.times = 10000;
		else if(isNaN(times))
			b.times = 10000;
		else
			b.times = times;
		b.makeADivObject(b.m_theDivObjectName);
		if(typeof(document.getElementById(b.m_theDivObjectName)=='object'))
		{
			document.getElementById(b.m_theDivObjectName).style.height=bannerArr[0][2]+"px";
		}
		b.set(b.m_arrBanner, b.times);
	}
}

/**
* function TNdoSlideBanner(bannerArr, times)
*/
function TNdoSlideBanner(banners, times, divname)
{
	if(banners.length > 0)
	{
		b=new TNBanner();
		b.m_arrBanner = new Array();
		for(i=0; i < banners.length; i++)
		{
			b.m_arrBanner[i] = banners[i];
		}
		b.m_id=b.m_theDivObjectName=b.setName(null);
		b.m_parent = divname||null;
		if(!times)
			b.times = 10000;
		else if(isNaN(times))
			b.times = 10000;
		else
			b.times = times;
		b.makeADivObject(b.m_theDivObjectName);
		if(typeof(document.getElementById(b.theDivObjectName)=='object'))
		{
			document.getElementById(b.m_theDivObjectName).style.height=banners[0][2]+"px";
		}
		b.set(b.m_arrBanner, b.times);
	}
}

	
/*
lr - rl - ud - udi
*/
function TNdoExpandBanner(banners, expand, wmode, divname)
{
	if(banners.length > 0)
	{
		b=new TNBanner();
		b.m_arrBanner = new Array();
		for(i=0; i < banners.length; i++)
		{
			b.m_arrBanner[i] = banners[i];
		}
		b.m_id=b.m_theDivObjectName=b.setName(null);
		b.m_parent = divname || null;
		b.m_expand=expand||'lr';
		b.m_expand=b.m_expand.toLowerCase();
		b.m_wmode=wmode||false;
		name = name || null;
		if(!name)
			b.makeADivObject(b.m_theDivObjectName);
		html = b.set(b.m_arrBanner);
		theObjects = document.getElementById(b.m_id);
		theObjects.innerHTML = theObjects.innerHTML;
		return html;
	}
}

/**
* function BannerAD(bannerArr,tableAttributes, tdAttributes)
**/
function BannerAD(banners,tableAttributes, tdAttributes, divname)
{
	if(banners.length>0)
	{
		c = new TNBanner();
		var bannerArrLength = banners.length-1;
		c.m_id=c.m_theDivObjectName = c.setName(null);
		b.m_parent = divname || null;
		c.m_tableAttributes=tableAttributes;
		c.m_tdAttributes=tdAttributes;
		c.makeADivObject(c.m_theDivObjectName);
		out = c.set(banners);
		if(out)
			document.write(out);
	}
}

function BannerADDIV(banners)
{
	if(banners && banners.constructor.toString().indexOf("Array") && banners.length>0)
	{
		c = new TNBanner();
		var l = banners.length-1;
		var theOutputString = '';
		
		if(banners[0][7]==100)
		{
			c.m_arrBanner=new Array();
			c.m_arrBanner=c.deal(banners.length);
			r=c.m_arrBanner;
			for(var i=0; i<=l; i++)
			{
				theOutputString += "<p>";
				switch (parseInt(banners[r[i]][0]))
				{
					case 99:
						//gif
						if (banners[r[i]][4] != "")
						{
							theOutputString += "<a href='" + banners[r[i]][4] + "' target='" + banners[r[i]][5] + "'>"
							theOutputString += "<img src='" + banners[r[i]][3] + "' border='0' alt='" + banners[r[i]][6] + "'>"
							theOutputString += "</a>";		
						}
						else
						{
							theOutputString += "<img src='" + banners[r[i]][3] + "' border='0' alt='" + banners[r[i]][6] + "'>";	
						}
						
						break;
					case 103:
						//flash
						theOutputString += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + banners[r[i]][1] + '" height="' + banners[r[i]][2] + '">'
						theOutputString += '<param name="movie" value="' + banners[r[i]][3] + '?clicktag=' + banners[r[i]][3] + '&clickTag='+banners[r[i]][3]+'&clickTAG='+banners[r[i]][3]+'">'
						theOutputString += '<param name="quality" value="high">'
						theOutputString += '<embed src="' + banners[r[i]][3] + '?clicktag=' + banners[r[i]][4] + '&clickTag='+banners[r[i]][4]+'&clickTAG='+banners[r[i]][4]+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + banners[r[i]][1] + '" height="' + banners[r[i]][2] + '">'
						theOutputString += '</embed>'
						theOutputString += '</object>';
						break;
				}
				theOutputString += "</p>";
			}
		}
		else if(parseInt(banners[0][7])!=100)
		{
			for(var i=0; i<=l; i++)
			{
				theOutputString += "<p>";
				switch (parseInt(banners[i][0]))
				{
					case 99:
						//gif
						if (banners[i][4] != "")
						{
							theOutputString += "<a href='" + banners[i][4] + "' target='" + banners[i][5] + "'>"
							theOutputString += "<img src='" + banners[i][3] + "' border='0' alt='" + banners[i][6] + "'>"
							theOutputString += "</a>";
						}
						else
						{
							theOutputString += "<img src='" + banners[i][3] + "' border='0' alt='" + banners[i][6] + "'>";	
						}
						
						break;
					case 103:
						//flash
						theOutputString += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + banners[i][1] + '" height="' + banners[i][2] + '">'
						theOutputString += '<param name="movie" value="' + banners[i][3] + '?clicktag=' + banners[i][4] + '&clickTag='+banners[i][4]+'&clickTAG='+banners[i][4]+'">'
						theOutputString += '<param name="quality" value="high">'
						theOutputString += '<embed src="' + banners[i][3] + '?clicktag=' + banners[i][4] + '&clickTag='+banners[i][4]+'&clickTAG='+banners[i][4]+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + banners[i][1] + '" height="' + banners[i][2] + '">'
						theOutputString += '</embed>'
						theOutputString += '</object>';
						break;
				}
				theOutputString += "</p>";
			}	
		}
		c.writed(theOutputString);
	}
}

function BannerADLOGO5(bannerArr,tableAttributes, imgAttributes)
{
	var bannerArrLength = bannerArr.length-1;
	if(bannerArr && bannerArr.constructor.toString().indexOf("Array") && bannerArr.length>0)
	{
		c = new TNBanner();
		var l = bannerArr.length-1;
		c.m_arrBanner=new Array();
		c.m_arrBanner=c.deal(bannerArr.length);
		ranIn = c.m_arrBanner;
		
		var theOutputString = '';
		theOutputString += "<ul " + tableAttributes + ">";		
		if(parseInt(bannerArr[0][7])==100)
		{
			for(var i=0; i<=bannerArrLength; i++)
			{
				switch (parseInt(bannerArr[ranIn[i]][0]))
				{
					case 99:
						//gif
						if (bannerArr[ranIn[i]][4] != "")
						{
							theOutputString += "<li>"
							theOutputString += "<a href='" + bannerArr[ranIn[i]][4] + "' target='" + bannerArr[ranIn[i]][5] + "'>"
							theOutputString += "<img src='" + bannerArr[ranIn[i]][3] + "' border='0' alt='" + bannerArr[ranIn[i]][6] + "' class='"+ imgAttributes +"'>"
							theOutputString += "</a>"
							theOutputString += "</li>";		
						} else {
							theOutputString += "<li>"
							theOutputString += "<img src='" + bannerArr[ranIn[i]][3] + "' border='0' alt='" + bannerArr[ranIn[i]][6] + "' class='"+ imgAttributes +"'>"
							theOutputString += "</li>";	
						}
						break;
					case 103:
						//flash
						theOutputString += '<li>'
						theOutputString += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + bannerArr[ranIn[i]][1] + '" height="' + bannerArr[ranIn[i]][2] + '">'
						theOutputString += '<param name="movie" value="' + bannerArr[ranIn[i]][3] + '?clicktag=' + bannerArr[ranIn[i]][4] + '&clickTag='+bannerArr[ranIn[i]][4]+'&clickTAG='+bannerArr[ranIn[i]][4]+'">'
						theOutputString += '<param name="quality" value="high">'
						theOutputString += '<embed src="' + bannerArr[ranIn[i]][3] + '?clicktag=' + bannerArr[ranIn[i]][4] + '&clickTag='+bannerArr[ranIn[i]][4]+'&clickTAG='+bannerArr[ranIn[i]][4]+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + bannerArr[ranIn[i]][1] + '" height="' + bannerArr[ranIn[i]][2] + '">'
						theOutputString += '</embed>'
						theOutputString += '</object>'
						theOutputString += '</li>';
						break;
				}
			}
		}
		theOutputString += "</ul>";
		c.writed(theOutputString);
	}
}

/**
	Banner Silde LR
 */
var TNBannerSlide=function(){}
TNBannerSlide.prototype=new TNBanner();
TNBannerSlide.prototype.htmlroll=function(){
	str = '';
	if(this.m_arrBanner.length>0)
	{
		fBarr=this.m_arrBanner;
		switch (this.m_position)
		{
			case "left":
				_id=this.m_id||"divAdLeft";
				str += '<div id="'+_id+'" style="left: -110px; width: 108px; position: absolute; top: 103px" align="right">';
				for (keyIndex in fBarr)
				{
					if (fBarr[keyIndex][4] != "")
					{
						str += "<a href='" + fBarr[keyIndex][4] + "' target='" + fBarr[keyIndex][5] + "'><img src='" + fBarr[keyIndex][3] + "' border='0' alt='" + fBarr[keyIndex][6] + "'></a><br>";
					}
					else
					{
						str += "<img src='" + fBarr[keyIndex][3] + "' border='0' alt='" + fBarr[keyIndex][6] + "'><br>";
					}
				}
				str += "</div>";
				break;
			case "right":
				_id=this.m_id||"divAdRight";
				str += '<div id="'+_id+'" style="right: -110px; width: 96px; position: absolute; top: 103px; padding-left: 3px;">';
				for (keyIndex in fBarr)
				{
					if (fBarr[keyIndex][4] != "")
					{
						str += "<a href='" + fBarr[keyIndex][4] + "' target='" + fBarr[keyIndex][5] + "'><img src='" + fBarr[keyIndex][3] + "' border='0' alt='" + fBarr[keyIndex][6] + "'></a><br>";
					}
					else
					{
						str += "<img src='" + fBarr[keyIndex][3] + "' border='0' alt='" + fBarr[keyIndex][6] + "'><br>";
					}
				}
				str += "</div>";
				break;
		}
	}
	return str;
}
TNBannerSlide.prototype.setposition=function(_id,pos,t,w){
	var theBannerDivObject = document.getElementById(_id);
	if (document.body.clientWidth < 980)
	{
		theBannerDivObject.style.left = -110;
	}
	else
	{
		switch (pos)
		{
			case "left":
				theBannerDivObject.style.left = 0;
				FloatTopDiv2(_id);
				break;
			case "right":
				theBannerDivObject.style.left = document.body.clientWidth - 110;
				FloatTopDiv(_id);
				break;
		}
	}}
TNBannerSlide.prototype.setslidel=function(_id){
	startX2 = document.body.clientWidth - 1004, startY2 = 131;
	var ns2 = (navigator.appName.indexOf("Netscape") != -1);
	var d2 = document;
	if (document.body.clientWidth < 980) startX2 = -110;
	function ml2(id)
	{
		var el2=d2.getElementById?d2.getElementById(id):d2.all?d2.all[id]:d2.layers[id];
		if(d2.layers)el2.style=el2;
		el2.sP = function(x,y)
		{
			this.style.left=x;
			this.style.top=y;
		};
		el2.x = startX2;
		el2.y = startY2;
		return el2;
	}
	window.stayTopLeft2=function()
	{
		if (document.body.clientWidth < 980)
		{
			ftlObj2.x = - 115;ftlObj2.y = 0;	ftlObj2.sP(ftlObj2.x, ftlObj2.y);
		}
		else
		{
			if (document.documentElement && document.documentElement.scrollTop)
				var pY2 = ns2 ? pageYOffset : document.documentElement.scrollTop;
			else if (document.body)
				var pY2 = ns2 ? pageYOffset : document.body.scrollTop;

			if (document.body.scrollTop > 131){startY2 = 3} else {startY2 = 131};
			if (document.body.clientWidth >= 1024)
			{
				ftlObj2.x =  0;ftlObj2.y += (pY2 + startY2 - ftlObj2.y)/32;	ftlObj2.sP(ftlObj2.x, ftlObj2.y);
			}
			else
			{
				ftlObj2.x  = startX2;
				ftlObj2.y += (pY2 + startY2 - ftlObj2.y)/32;
				ftlObj2.sP(ftlObj2.x, ftlObj2.y);
			}
		}
		setTimeout("stayTopLeft2()", 1);
	}
	ftlObj2 = ml2(_id);
	stayTopLeft2();}
TNBannerSlide.prototype.setslider=function(_id){
	startX = document.body.clientWidth - 110, startY = 103;
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var d = document;
	if (document.body.clientWidth < 980)
	{
		startX = -110;
	}
	function ml(id)
	{
		var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
		if (d.layers)
		{
			el.style=el;
		}
		el.sP = function(x,y)
		{
			this.style.left=x;
			this.style.top=y;
		};
		el.x = startX;
		el.y = startY;
		return el;
	}
	window.stayTopLeft=function()
	{		
		if (document.body.clientWidth < 980)
		{
			ftlObj.x = - 115;ftlObj.y = 0;	ftlObj.sP(ftlObj.x, ftlObj.y);
		}			
		else
		{
			if (document.documentElement && document.documentElement.scrollTop)
				var pY = ns ? pageYOffset : document.documentElement.scrollTop;
			else if (document.body)
				var pY = ns ? pageYOffset : document.body.scrollTop;
			if (document.body.scrollTop > 103){startY = 17} else {startY = 103};
			if (document.body.clientWidth >= 1024)
			{
				ftlObj.x = document.body.clientWidth - 110;ftlObj.y += (pY + startY - ftlObj.y)/32;ftlObj.sP(ftlObj.x, ftlObj.y);
			}
			else
			{			
				ftlObj.x  = startX;
				ftlObj.y += (pY + startY - ftlObj.y)/32;
				ftlObj.sP(ftlObj.x, ftlObj.y);
			}
		}
		setTimeout("stayTopLeft()", 1);
	}
	ftlObj = ml(_id);
	stayTopLeft();}

function displayFloatBanner(bannerArr, handSide)
{
	s=new TNBannerSlide();
	for(i=0; i < bannerArr.length; i++)
	{
		s.m_arrBanner[i] = bannerArr[i];
	}
	s.m_position=handSide
	s.m_id=s.m_theDivObjectName=s.setName(null)
	s.htmlroll();
	switch (s.m_position)
	{
		case "left":
			s.setposition(s.m_id||"divAdLeft", handSide);
			break;
		case "right":
			s.setposition(s.m_id||"divAdRight", handSide);
			break;
	}
}

/**
*/
function FloatTopDiv2(leftFloatBanner)
{
	startX2 = document.body.clientWidth - 1004, startY2 = 131;
	var ns2 = (navigator.appName.indexOf("Netscape") != -1);
	var d2 = document;
	if (document.body.clientWidth < 980) startX2 = -110;
	function ml2(id)
	{
		var el2=d2.getElementById?d2.getElementById(id):d2.all?d2.all[id]:d2.layers[id];
		if(d2.layers)el2.style=el2;
		el2.sP = function(x,y)
		{
			this.style.left=x;
			this.style.top=y;
		};
		el2.x = startX2;
		el2.y = startY2;
		return el2;
	}
	window.stayTopLeft2=function()
	{
		if (document.body.clientWidth < 980)
		{
			ftlObj2.x = - 115;ftlObj2.y = 0;	ftlObj2.sP(ftlObj2.x, ftlObj2.y);
		}
		else
		{
			if (document.documentElement && document.documentElement.scrollTop)
				var pY2 = ns2 ? pageYOffset : document.documentElement.scrollTop;
			else if (document.body)
				var pY2 = ns2 ? pageYOffset : document.body.scrollTop;

			if (document.body.scrollTop > 131){startY2 = 3} else {startY2 = 131};
			if (document.body.clientWidth >= 1024)
			{
				ftlObj2.x =  0;ftlObj2.y += (pY2 + startY2 - ftlObj2.y)/32;	ftlObj2.sP(ftlObj2.x, ftlObj2.y);
			}
			else
			{
				ftlObj2.x  = startX2;
				ftlObj2.y += (pY2 + startY2 - ftlObj2.y)/32;
				ftlObj2.sP(ftlObj2.x, ftlObj2.y);
			}
		}
		setTimeout("stayTopLeft2()", 1);
	}
	ftlObj2 = ml2(leftFloatBanner);
	stayTopLeft2();		
}

/**

 */
function FloatTopDiv(rightFloatBanner)
{
	startX = document.body.clientWidth - 110, startY = 103;
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var d = document;
	if (document.body.clientWidth < 980)
	{
		startX = -110;
	}
	function ml(id)
	{
		var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
		if (d.layers)
		{
			el.style=el;
		}
		el.sP = function(x,y)
		{
			this.style.left=x;
			this.style.top=y;
		};
		el.x = startX;
		el.y = startY;
		return el;
	}
	window.stayTopLeft=function()
	{		
		if (document.body.clientWidth < 980)
		{
			ftlObj.x = - 115;ftlObj.y = 0;	ftlObj.sP(ftlObj.x, ftlObj.y);
		}			
		else
		{
			if (document.documentElement && document.documentElement.scrollTop)
				var pY = ns ? pageYOffset : document.documentElement.scrollTop;
			else if (document.body)
				var pY = ns ? pageYOffset : document.body.scrollTop;
			if (document.body.scrollTop > 103){startY = 17} else {startY = 103};
			if (document.body.clientWidth >= 1024)
			{
				ftlObj.x = document.body.clientWidth - 110;ftlObj.y += (pY + startY - ftlObj.y)/32;ftlObj.sP(ftlObj.x, ftlObj.y);
			}
			else
			{			
				ftlObj.x  = startX;
				ftlObj.y += (pY + startY - ftlObj.y)/32;
				ftlObj.sP(ftlObj.x, ftlObj.y);
			}
		}
		setTimeout("stayTopLeft()", 1);
	}
	ftlObj = ml(rightFloatBanner);
	stayTopLeft();
}

