function FloatTopRight(divid)

{

	startX = document.body.clientWidth - adRWidth, startY = top;

	var ns = (navigator.appName.indexOf("Netscape") != -1);

	if (document.body.clientWidth < 980) startX = -adRWidth;

	function moveDiv(id)

	{

		var el=document.getElementById(id);

		el.sP=function(x,y){this.style.left=x+'px';this.style.top=y+'px';};

		el.x = startX; el.y = startY;

		return el;

	}

	window.stayTopRight=function()

	{

		var pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;

		if (document.body.scrollTop > top){startY = 3} else {startY = top};

		ftlObj.y += (pY + startY - ftlObj.y)/50;

		ftlObj.sP(ftlObj.x, ftlObj.y);

		setTimeout("stayTopRight()", 5);

	}

	ftlObj = moveDiv(divid);

	stayTopRight();

}

function FloatTopLeft(divid)

{

	startX2 = document.body.clientWidth - adLWidth, startY2 = top;

	var ns = (navigator.appName.indexOf("Netscape") != -1);

	if (document.body.clientWidth < 980) startX2 = -adLWidth;

	function moveDiv(id)

	{

		var el=document.getElementById(id);

		el.sP=function(x,y){this.style.left=x+'px';this.style.top=y+'px';};

		el.x = startX2; el.y = startY2;

		return el;

	}

	window.stayTopLeft=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 = ns ? pageYOffset : document.documentElement.scrollTop;

			else if (document.body)

				var pY2 = ns ? pageYOffset : document.body.scrollTop;



			if (document.body.scrollTop > top){startY2 = 3} else {startY2 = top};



			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)/50;

				ftlObj2.sP(ftlObj2.x, ftlObj2.y);

			}

		}

		setTimeout("stayTopLeft()", 5);

	}

	ftlObj2 = moveDiv(divid);

	stayTopLeft();

}

var face = 0;

var delaytime = 10000;

function ShowRotatorBanner(obj, myid, width, height){

	document.write('<div id="' + myid + '" style="width;'+width);

	if(height > 0) document.write(';height='+height);

	document.write('">');

	document.write(buildhtml(obj[0],width,height));

	if (obj.length>1){

		setTimeout(function(){ChangeBanner(obj,0,myid,delaytime,width,height)}, delaytime);

	}

	document.write('</div>');

}



function ChangeBanner(obj,index,bannerid,delaytime,width,height){

	if (index==obj.length-1) {index=0;} else {index++;}

	document.getElementById(bannerid).innerHTML=buildhtml(obj[index],width,height);

	setTimeout(function(){ChangeBanner(obj,index,bannerid,delaytime,width,height)},delaytime);

}

function ShowRotatorList(obj, myid, width, height, limit){

	if(typeof(obj) != 'undefined'){

		document.write('<div id="'+myid+'" style="width:'+width+'">');

		document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0">');

		var obj_length = obj.length;

		var i = 0;

		if (obj_length <= limit){

			for(i; i < obj_length; i++){

				document.write("<tr><td align='center'>" + buildhtml(obj[i], width, height) + "</td></tr>");

				document.write('<tr><td height=2><img src="' + skin_path + '/images/transparent.gif" height="2" width="1" /></td></tr>');

			}

		}else{

			for(i ;i < limit; i++){

				document.write("<tr><td align='center'>" + buildhtml(obj[i], width, height) + "</td></tr>");

				document.write('<tr><td height=2><img src="' + skin_path + '/images/transparent.gif" height="2" width="1" /></td></tr>');

			}

		}

		document.write('</table>');

		document.write('</div>');

		

		if (obj_length > limit){

			setTimeout(function(){ChangeBannerList(obj,i,myid,delaytime,limit, width, height)}, delaytime);

		}

	}

}

function randOrd(){ return (Math.random()*10000)-5000; } 

function ChangeBannerList(obj,i,bannerid,delaytime,limit, width, height){

	var obj_length = obj.length - 1;

	var html = '<table width="100%" border="0" cellspacing="0" cellpadding="0">';

	var limit1 = i + limit;

	for(var j = i ;j < limit1; j++){

		html += "<tr><td align='center'>" + buildhtml(obj[i], width, height) + "</td></tr>";

		if(i == obj_length) i = 0; else i++;

	}

	html += '</table>';

	document.getElementById(bannerid).innerHTML=html;

	setTimeout(function(){ChangeBannerList(obj,i,bannerid,delaytime,limit, width, height)},delaytime);

}

function buildhtml(obj, maxWidth, maxHeight){

	if (!obj) {return ''}

	var sTemp = '';

	var width, height;

	if(obj[5] > 0 && obj[5] < maxWidth) width = obj[4];

	else width = maxWidth;

	if(obj[5] > 0 && obj[5] < maxHeight) height = obj[5];

	else if(maxHeight != null) height = maxHeight;

	if( obj[3] == 0){

		sTemp += '<a href="' + domain + '/ads.php?id=' + obj[6] + '&url=' + obj[1] + '" target="_blank"><img src="' + domain + '/' + obj[0] + '" alt="' + obj[2];

		sTemp += '" width="' + width + '"';

		if(height > 0) sTemp += '" height="' + height + '"';

		sTemp = sTemp += ' border="0" /></a>';

	}else if( obj[3] == 1){

		sTemp += '<a href="' + domain + '/ads.php?id=' + obj[6] + '&url=' + obj[1] + '" target="_blank"><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="' + width + '" height="' + obj[5] + '"><param name="movie" value="' + domain + '/' + obj[0] + '" /><param name="quality" value="high" /><param name="wmode" value="transparent"><embed src="' + domain + '/' + obj[0] + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + obj[5] + '" wmode="transparent"></embed></object></a>';

	}

	return sTemp;

}

Array.prototype.indexOf = function(value){

   var i = this.length;

   while(i){

      if(this[--i] == value) return i;

   }

   return -1;

};

Array.prototype.merge = function(value, cap){

   var i = value.length;

   while(i){

      if(this.indexOf(value[--i]) == -1) this.push(value[i]);

   }

   return (cap)? this.join(cap) : this;

};

