function toggleHosting(){
	var h=xGetElementById('diskografija-project');
	var bOpen=(h.bOpen!=null);
	if(bOpen)hideHosting(h);else showHosting(h);
}
function showHosting(h){
	xTop(h,-(xHeight(h)+10));
	xVisibility(h,true);
	xSlideTo(h,0,0,500);
	h.bOpen=true;
}
function hideHosting(h){
	xTop(h,0);
	xSlideTo(h,0,-(xHeight(h)+10),500);
	h.bOpen=null;
}
function logAdSense(){
//	if(window.status.indexOf('go to')==0){
		urchinTracker('/adsense.aspx');
		var img=new Image();
		img.src='/adsense.aspx?Page='+document.location+'&Target='+window.status;//.substring(6);
//	}
}
function addOnloadListener(fn){
	if(typeof window.addEventListener!='undefined')
		window.addEventListener('load',fn,false);
	else if(typeof document.addEventListener!='undefined')
		document.addEventListener('load',fn,false);
	else if(typeof window.attachEvent!='undefined')
		window.attachEvent('onload',fn);
	else{
		if(typeof window.onload=='function'){
			var existing=window.onload;
			window.onload=function(){
				existing();
				fn();
			};
		}else
			window.onload=fn;
	}
}
function init(){
	var he=xGetElementById('diskografija-project');
	var hb=xGetElementById('project-button');
	if(he!=null&&hb!=null){
		xTop(he,-xHeight(he));
		xLeft(hb,xClientWidth()-xWidth(hb));
		xAddEventListener(hb,'click',toggleHosting);
	}

	if(document.all){
		var ifs=[];
		if(document.getElementsByTagName)
			ifs=document.body.getElementsByTagName("IFRAME");
		else if(document.body.all)
			ifs=document.body.all.tags("IFRAME");
	
		for(var i=0;i<ifs.length;i++){
			if(ifs[i].src.indexOf('googlesyndication.com')>-1)
				ifs[i].onfocus=logAdSense;
		}
	}else{
		window.addEventListener('beforeunload',doPageExit,false);
		window.addEventListener('mousemove',getMouse,true);
	}
}
//for firefox
var px;var py;
function getMouse(e){
	px=e.pageX;
	py=e.clientY;
}
function findY(obj){
	var y=0;
	while(obj){
		y+=obj.offsetTop;
		obj=obj.offsetParent;
	}
	return y;
}
function findX(obj){
	var x=0;
	while(obj){
		x+=obj.offsetLeft;
		obj=obj.offsetParent;
	}
	return x;
}
function doPageExit(e){
	ad=document.getElementsByTagName("iframe");
	for (i=0;i<ad.length;i++){
		var adLeft=findX(ad[i]);
		var adTop=findY(ad[i]);
		var inFrameX=(px>(adLeft-10) && px<(parseInt(adLeft)+parseInt(ad[i].width)+15));
		var inFrameY=(py>(adTop-10) && py<(parseInt(adTop)+parseInt(ad[i].Height)+10));
		if(inFrameY&&inFrameX){
			urchinTracker('/adsense.aspx');
			var img=new Image();
			img.src='/adsense.aspx?Page='+document.location+'&Target='+window.status.substring(6);
		}
	}
}
//end for firefox

addOnloadListener(init);

var iCurrentCover=-1;
function cycleCovers(iCoverCount){
	if(iCurrentCover!=-1){
		xGetElementById('oCover'+iCurrentCover).style.display='none';
		iCurrentCover=(iCurrentCover+1)%iCoverCount;
	}else
		iCurrentCover=new Date().getSeconds()%iCoverCount;
	xGetElementById('oCover'+iCurrentCover).style.display='';
	window.setTimeout('cycleCovers('+iCoverCount+')',4000);
}