//you can modify these vars
var bSrc = 'http://goodbody.ru/banner/rm/goodbody7.swf'; //movie address
//var bWidth = 300; //movie width
//var bHeight = 218; //movie height
//var bPartnerID = '111'; //partner id
//var bShowDay = 1; //show banner once a day
//do not modify below
var intBMove = null;
var bStartPosTop = document.body.scrollTop;
var bStartPosLeft = document.body.scrollLeft;
var bStartWidth = document.body.clientWidth;
var bStartHeight = document.body.clientHeight;
var bVisible = false;
var bStep = 25;
var rmObj = '<div id="richmedia" style="position:absolute; width:400px; height:290px; z-index:98; left: 100px; top: 100px; visibility: hidden;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="100%" height="100%" id="goodbody" align="middle"><param name="allowScriptAccess" value="always" /><param name="movie" value="'+bSrc+'?partnerid='+bPartnerID+'" /><param name="play" value="true" /><param name="quality" value="high" /><param name="scale" value="noborder" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /><embed src="'+bSrc+'?partnerid='+bPartnerID+'" quality="high" scale="noborder" wmode="transparent" bgcolor="#ffffff" width="100%" height="100%" name="goodbody" align="middle"  allowScriptAccess="always" swLiveConnect="true" type="application/x-shockwave-flash"  pluginspage="http://www.macromedia.com/go/getflashplayer" /></object></div>';

function setCookie(name, value, days)
{
	var today = new Date();
	var expires = new Date(today.getTime() + days*86400000);
	document.cookie = name + "=" + escape(value) +"; path=/; expires=" + expires.toGMTString();
}

function getCookie(name)
{
	var rmCookie = document.cookie.split("; ");
	for (var i=0; i<rmCookie.length; i++) {
		var value = rmCookie[i].split("=");
		if (name == value[0]) return unescape(value[1]);
	}

	return null;
}

function rmClose()
{
	bVisible = false;
	clearInterval(intBMove);
	document.getElementById('richmedia').style.display = 'none';
}

function rmInit()
{
	if (getCookie("rmGoodbody") != null) {return null;}
	setCookie("rmGoodbody", 1, bShowDay); 

	if (navigator.appName == "Microsoft Internet Explorer" && !window.opera) { 		
		document.write('<div id="richmedia" style="position:absolute; width:400px; height:290px; z-index:98; left: 100px; top: 100px; visibility: hidden;"></div>');
		var so = new SWFObject(bSrc+"?partnerid="+bPartnerID, "goodbody", "100%", "100%", "6", "#ffffff");
		so.addParam("wmode", "transparent");
		so.write("richmedia");
	} else {
		document.write(rmObj);
	}
	rmStart();
	intBMove = setInterval("rmMove()",50);  
}

function rmStart()
{
	var fDiv = document.getElementById('richmedia');
	fDiv.style.width = bWidth;
	fDiv.style.height = bHeight;
	fDiv.style.left = (Math.round((bStartWidth-bWidth)/2)+bStartPosLeft-bStep)+'px';
	fDiv.style.top = (Math.round((bStartHeight-bWidth)/2)+bStartPosTop-bStep)+'px';
	fDiv.style.visibility = 'visible';
	fDiv.style.display = 'inline';
	bVisible = true;
}

function rmChange(iStart, iCurrent, iStep)
{
	var res = iStart;
	
	if(iCurrent != iStart) {
		res += (Math.abs(iCurrent - iStart) < iStep ) ? (iCurrent - iStart) : ((iCurrent < iStart) ? -1*iStep : iStep);
	}

	return res;
}

function rmMove()
{
	if (bVisible) {
		if ((bStartPosTop != document.body.scrollTop || bStartPosLeft != document.body.scrollLeft || bStartWidth != document.body.clientWidth || bStartHeight != document.body.clientHeight) && bVisible) {
			bStartPosTop = rmChange(bStartPosTop, document.body.scrollTop, bStep);
			bStartPosLeft = rmChange(bStartPosLeft, document.body.scrollLeft, bStep);
			bStartHeight = rmChange(bStartHeight, document.body.clientHeight, bStep);
			bStartWidth = rmChange(bStartWidth, document.body.clientWidth, bStep);
			rmStart();
		}
	}
	
}