var isMacFirefox=(navigator.userAgent.indexOf('Firefox')!=-1&&navigator.platform.indexOf('Mac')!=-1);

function resizeBox(boxNo,h){
	var obj=document.getElementById('box'+boxNo);
	if (obj&&h!=null&&h!=''){
		obj.style.height=h+'px';
	}
}

function resetBoxes(){
	for (var i=0;i<50;i++){
		resizeBox(i,250);
	}
}

function showWin(doc_id){
	var obj=document.getElementById('event-div');
	var obj1=document.getElementById('event');
	var obj2=document.getElementById('overlay-body');
	var obj3=document.getElementById('overlay-top');


	var src="/blank.html";
	var scrollTop=(document.documentElement&&document.documentElement.scrollTop?document.documentElement.scrollTop:(document.body&&document.body.scrollTop?document.body.scrollTop:0));
	
	if (obj&&obj1&&obj2&&obj3){
		if (doc_id!=null){
			src='?id='+doc_id;
		}
		obj1.src=src;
		obj.style.top=(scrollTop+12)+'px';
		obj.style.display='block';
		obj2.style.height=getHeight()+'px';
		if(!isMacFirefox){
			obj2.style.display='block';
			obj3.style.display='block';
		}
	}
}

function hideWin(){
	var obj=document.getElementById('event-div');
	var obj1=document.getElementById('event');
	var obj2=document.getElementById('overlay-body');
	var obj3=document.getElementById('overlay-top');

	if (obj&&obj1&&obj2&&obj3){
		obj.style.display='none';		
		obj1.src='/blank.html';
		obj2.style.display='none';
		obj3.style.display='none';
	}
}

function getHeight() {
	var cHeight=0;
	var sHeight=0;
	
	if (window.document.documentElement && window.document.documentElement.scrollHeight){
		sHeight = window.document.documentElement.scrollHeight;
	} else if (window.document.body){
		sHeight = window.document.body.scrollHeight;
	}
	
	if (!!window.innerHeight){
		cHeight = document.body.scrollHeight;
	} else if (window.document.documentElement && window.document.documentElement.clientHeight){
		cHeight = window.document.documentElement.clientHeight;
	} else if (window.document.body){
		cHeight = window.document.body.clientHeight;
	}
	
	return (cHeight>=sHeight?cHeight:sHeight);
}