
jsHover = function(id, tag) {
	// run only under IE6
	if (window.attachEvent && navigator.userAgent.indexOf("Opera")==-1) {
		var hEls = document.getElementById(id).getElementsByTagName(tag);
		for (var i=0, len=hEls.length; i<len; i++) {
			hEls[i].onmouseover=function() { this.className+=" jshover"; }
			hEls[i].onmouseout=function() { this.className=this.className.replace(" jshover", ""); }
		}
	}
}

function getAbsolutePosition(el) {
	
	var r = { x: el.offsetLeft, y: el.offsetTop };
	if (el.offsetParent) {
		var tmp = getAbsolutePosition(el.offsetParent);
		r.x += tmp.x;
		r.y += tmp.y;
	}
	r.x = parseInt(r.x);
	r.y = parseInt(r.y);
	return r;
	/*
	Usage:
	document.getElementById('div2').style.left = getAbsPos(document.getElementById('div1')).x + 'px';
	document.getElementById('div2').style.top = getAbsPos(document.getElementById('div1')).y + 'px';
	*/	
}
function getDocumentSize(doc) { // getting a real size document with scrolling etc.
	var r = { width: 0, height: 0 };

	
	var width1=0, width2=0, width3=0, width4=0, maxWidth=0;
	var height1=0, height2=0, height3=0, height4=0, maxHeight=0;
	
	
	if (doc.width) maxWidth = doc.width;	

	
	if (doc.body) {		
		if (doc.body.scrollWidth) width1 = doc.body.scrollWidth;
		if (doc.body.offsetWidth) width2 = doc.body.offsetWidth;		
	}
	if (doc.documentElement) {
		width3 = doc.documentElement.scrollWidth;		
		width4 = doc.documentElement.clientWidth;
	}	
	
	maxWidth = Math.max(Math.max(Math.max(width1, width2), Math.max(width3, width4)),maxWidth);
		
	if (doc.height) maxHeight = doc.height;
	if (doc.body) {
		if (doc.body.scrollHeight) height1 = doc.body.scrollHeight;
		if (doc.body.offsetHeight) height2 = doc.body.offsetHeight;
  	}
	if (doc.documentElement) {
		height3 = doc.documentElement.scrollHeight;
		height4 = doc.documentElement.clientHeight;
	}
	maxHeight = Math.max(Math.max(Math.max(height1, height2), Math.max(height3, height4)),maxHeight);
	
	r.width = maxWidth;
	r.height = maxHeight;
	
	return r;
	/*
	Usage:
	<a href="javascript:void(0)"
	onClick="alert('width=' + getDocumentSize(document).width + ' height=' + getDocumentSize(document).height);">get document size</a>
	<br>
	<a href="javascript:void(0)" 
	onClick="alert('width=' + getDocumentSize(window.frames['iframe_name'].document).width + ' height=' + getDocumentSize(window.frames['iframe_name'].document).height);">
		get document in iframe size</a>
	
	*/
}

