if (typeof window.addEventListener != 'undefined') window.addEventListener('load', initbox, false);
else if (typeof window.attachEvent != 'undefined') window.attachEvent('onload', initbox);

var ie = typeof(document.all)!='undefined';
var calunits = "px";

var bouncelimit = 32; //(must be divisible by 8)
var direction = "up";
var newBanner = null;

//function initbox(){
////	if(GetCookie('is_banner')!==null) return;
////	SetCookie('is_banner', 'yes');
//	if(window.location.pathname!='/' && window.location.pathname!='/ru/main/') return;
//	
//	newBanner = document.createElement("DIV");
//	var img = document.createElement("IMG");
//	with(img) {src = '/img/bun_lys.jpg'; width = 400; height = 250; useMap = '#banMap'; }
//	newBanner.appendChild(img);
//	crossobj = newBanner.style;
//	var s = documentSize();
//	with(crossobj){ position='absolute'; width='400px'; left=((s[0]-400)/2)+'px'; zIndex=99; }
//	truebody().appendChild(newBanner);
//	scroll_top = (ie)? truebody().scrollTop : window.pageYOffset;
//	crossobj.top=scroll_top-150+calunits;
//	crossobj.visibility = "visible";
//	dropstart=setInterval("dropin()",50);
//}

function dropin(){
	scroll_top=(ie)? truebody().scrollTop : window.pageYOffset;
	if (parseInt(crossobj.top)<150+scroll_top)
		crossobj.top=parseInt(crossobj.top)+40+calunits;
	else{
		clearInterval(dropstart);
//		bouncestart=setInterval("bouncein()", 100);
	}
}

function bouncein(){
	crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits;
	if (bouncelimit<0) bouncelimit+=8;
	bouncelimit=bouncelimit*-1;
	if (bouncelimit==0) clearInterval(bouncestart);
}

function dismissbox(){
	if (window.bouncestart) clearInterval(bouncestart);
	crossobj.display="none";
}

function truebody(){
	return document.body;
}

function documentSize(){
	var w = document.body.scrollWidth > document.body.offsetWidth ? document.body.scrollWidth : document.body.offsetWidth;
	var h = document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight;
	return [w, h];
}

function GetCookie(name){
	var prefix = name+"=";
	var start = document.cookie.indexOf(prefix);
	if (start == -1) return null;
	var end = document.cookie.indexOf(";", start+prefix.length);
	if (end == -1) end = document.cookie.length;
	var value = document.cookie.substring(start+prefix.length, end);
	return unescape(value);
}
function SetCookie(name, value, expires, path, domain, secure){
	if (!expires){
		expires= new Date();
		expires.setYear(expires.getYear()+1);
	}
	var newCookie = name+"="+escape(value) +((expires)?";expires="+expires.toGMTString():"")+
	((path)?";path="+path:"")+((domain)?";domain="+domain:"")+((secure)?";secure":"");
	document.cookie = newCookie;
}

