
var ad_draging = false;
var x0 = 0; var y0 = 0;  var xstart = 0; var ystart = 0;
var clickEnable = true

function ad_getLayer(name) {
	if(document.all) return document.all[name];
	else if(document.getElementById) return document.getElementById(name);
	else if(document.layers) return document.layers[name]
}
function ad_minimize(top, right, bottom, left) {
	var ad = ad_getLayer('rozaAd');
	if(ad.style) ad.style.clip = 'rect('+top+', '+right+', '+bottom+', '+left+')';
	else { ad.clipTop = top; ad.clipRight = right; ad.clipBottom = bottom; ad.clipLeft = left; }
}
function ad_restore(top, right, bottom, left) {
	var ad = ad_getLayer('rozaAd');
	if(ad.style) ad.style.clip = 'rect('+top+', '+right+', '+bottom+', '+left+')';
	else { ad.clipTop = top; ad.clipRight = right; ad.clipBottom = bottom; ad.clipLeft = left; }
}
function ad_close() {
	var ad = ad_getLayer('rozaAd');
	if(ad.style) ad.style.visibility = 'hidden';
	else ad.visibility = 'hide';
}
function ad_click() {
	if(clickEnable) document.location.href = ad_url;
}
function ad_move(e) { 
	if(bv.ie) {
		x = event.clientX + document.body.scrollLeft;
		y = event.clientY + document.body.scrollTop;
		if(ad_draging) {
			clickEnable = false;
			dx = x-x0; dy = y-y0; x0 = x; y0 = y;
			var ad = ad_getLayer('rozaAd');
			ad_setPos(ad, ad.offsetLeft+dx, ad.offsetTop+dy);
		}
	}
}
function ad_drag(e) {
	if(bv.ie) {
		clickEnable = true;
		x = event.clientX + document.body.scrollLeft; 
		y = event.clientY + document.body.scrollTop; 
		xstart = x0 = x; ystart = y0 = y;
		ad_draging = true;
	}
}
function ad_drop(e) { 
	if(bv.ie) { 
		x = event.clientX + document.body.scrollLeft; 
		y = event.clientY + document.body.scrollTop; 
		ad_draging = false;
	}
}
function ad_setPos(obj, left, top) {
	obj.style.left = left; 
	obj.style.top = top; 
}
function ad_init(id) {
	var ad = ad_getLayer('rozaAd');
	ad.onmousedown = ad_drag; 
	ad.onmouseup = ad_drop; 
	document.onmousemove = ad_move; 
	var value = ''
	if(c.getCookie('ad_roza'))
		value = c.getCookie('ad_roza');
	value += (value == '')? ';'+id+';' : id+';';
	var today = new Date();
	var expDate = new Date(today.getFullYear(), today.getMonth(), today.getDate()+1);
	c.setCookie('ad_roza', value, expDate-today);
}

