var _fw = {};
_fw.rand = "xmd0kf4ghe846jqo9pd";
_fw.url = "http://newaccounts.freewebs.com/?referer=advbar&cm_mmc=Freewebs-_-Free%20Website-_-AdvBar-_-Free%20Website";
_fw.imagesprefix = "http://images.freewebs.com/Images/Freebar/";
_fw.set = function(o,v) {for(var i in v) o[i] = v[i]};
_fw.event = function(o,e,f) {
if (o.addEventListener) o.addEventListener(e, f, 1);
else if (o.attachEvent) o.attachEvent("on"+e,f);
};
_fw.loadFreebar = function(ll) {
	var now=new Date();
	now=Math.floor(now.getTime()/86400000);
	var days=now-ll;
	var h=document.location.href;
	var showbar=true; //(h.indexOf('forcebar=1')>0);
	var showad=(days>30||h.indexOf('forcead=1')>0);
	if (h.indexOf('freebarinfo=1')>0) {
		alert('show freebar = '+showbar+
	'\nshow ad = '+showad+
	'\nlast login = '+ll+
	'\ntoday = '+now+
	'\ndays since last login = '+days+' days');
	}
	
	var a=navigator.userAgent;
	_fw.cssfixed=(a.indexOf('Firefox')>0);
	
	if (showad) {
		_fw.adv = document.createElement("div");
		_fw.set(_fw.adv.style, {position:'absolute',width:'100%',height:'90px',left:'0px',top:'0px',textAlign:'center',zIndex:10001,backgroundColor:document.bgColor});
		_fw.adv.style.position = (_fw.cssfixed)? 'fixed':'absolute';
		var fr = document.createElement("iframe");
		_fw.set(fr.style,{margin:0,width:'728px',height:'90px'});
		_fw.set(fr,{marginwidth:0,marginheight:0,hspace:0,vspace:0,scrolling:'no',frameBorder:0,border:0});
		fr.src = 'http://ad.doubleclick.net/adi/fw.user.sites;sz=728x90;cat=00;cat=19;ord='+(Math.random()*10000000000000000)+'?';
		_fw.adv.appendChild(fr);
	}
	if (showbar) {
		var f = _fw.freebar = document.createElement("div");
		_fw.set(f.style, {visibility:'hidden',overflow:'hidden',zIndex:10000,textAlign:'center',whiteSpace:'nowrap',left:'0px',top:'0px'});
		f.style.position = (_fw.cssfixed)? 'fixed':'absolute';
	}
	
	var fn = window['_load_random_'+_fw.rand];
	if (typeof(fn)=='function') fn();
	else if (typeof(fn)=='string' && fn == 'Freewebs') {
		_fw.onlyad = showad;
		_fw.freebar = 0;
	} else if (showbar) {
		_fw.fullheight = 32;
		f.onclick = function() {document.location.href=_fw.url}
		_fw.set(f.style, {width:'100%',height:_fw.fullheight+'px',cursor:'pointer',textAlign:'right',background:"#66CCFF url('"+_fw.imagesprefix+"bar_stretchblue-bg.gif') repeat-x"});
		f.innerHTML = '<div style="position:absolute; left:0px; top:0px; width:260px; height:32px;"><a href="http://newaccounts.freewebs.com/?referer=advbar&cm_mmc=Freewebs-_-Free%20Website-_-AdvBar-_-Free%20Website"><img src="'+_fw.imagesprefix+'bar_stretchblue-web.gif" width=260 height=32 border=0 align=middle></a></div>'+
		'<a href="'+_fw.url+'" target="_top"><img src="'+_fw.imagesprefix+'bar_stretchblue-logo.gif" width=168 height=32 border=0 align=middle title="Get your free website today!"></a>';
	}
	if (!_fw.fullheight) _fw.fullheight = 0;
	
	if (showad) {
		if (!showbar) document.body.style.marginBottom += 90 + 10;
		document.body.appendChild(_fw.adv);
	}
	if (showbar) {
		document.body.style.marginBottom += _fw.fullheight + 10 + ((showad)?90:0);
		document.body.appendChild(f);
		_fw.contentbar = document.getElementById('fw_content');
	}

	if (!showad && !showbar) return;
	
	_fw.resetBar();
	if (_fw.freebar) _fw.freebar.style.visibility = 'visible';
	_fw.event(window,'scroll',_fw.resetBar);
	_fw.event(window,'resize',_fw.resetBar);
}

_fw.resetBar = function(r) {
	var fn = window['_set_random_'+_fw.rand];
	if (typeof(fn)=='function') fn();
	else {
		var f = _fw.freebar;
		if (f && document.all) f.style.width = document.body.clientWidth + document.body.scrollLeft+'px';
		
		var wh = document.body.clientHeight;
		var dh = document.body.scrollHeight;
		
		var st = (_fw.cssfixed)? 0:parseInt(document.body.scrollTop);
		var y = st + wh - _fw.fullheight;
		var h = dh - y;
		if (h<_fw.fullheight) h = _fw.fullheight;
		
		if (f) {
			f.style.top = y+'px';
			f.style.height = h;
		}
		if (_fw.adv) _fw.adv.style.top = y-90+'px';
	}
}

var now = new Date();
_fw.loadFreebar(now.getTime());
