// lib functions
function getElem(eid)
{
	if(document.getElementById(eid))
	{
		return document.getElementById(eid);
	}
	else
	{
		return null;
	}
}

function showElem(elem)
{
	if(elem)
	{
		elem.style.visibility = 'visible';
	}
}

function hideElem(elem)
{
	if(elem)
	{
		elem.style.visibility = 'hidden';
	}
}

function OpenWindow(url, w, h) 
{
	window.open(url, '', 'toolbar=0,menubar=0,location=0,status=0,scrollbars=0,resizable=0,height='+h+',width='+w+',left=50,top=50');
}

function flip(item)
{
	if (item.style.display == 'none')
	{
		item.style.display = 'inline';
	}
	else
	{
		item.style.display = 'none';
	}
}

function scrolled()
{
	parent.leftFrame.document.body.scrollTop=document.body.scrollTop;
	parent.rightFrame.document.body.scrollTop=document.body.scrollTop;
}

 
function isOpera()
{
	if(navigator.userAgent.toLowerCase().indexOf('opera')  > -1) {
		return true;
	} else {
		return false;
	}
}

function isIE()
{
	if(navigator.userAgent.toLowerCase().indexOf('msie')  > -1) {
		return true;
	} else {
		return false;
	}
} 

function oldIE()
{
	var ua = navigator.userAgent.toLowerCase();
	var i = ua.indexOf('msie');
	if(i<0) {
		return false;
	}
	var uatrimmed = ua.substr(i);
	var j = uatrimmed.indexOf(';');
	var vers = uatrimmed.substring(5,j);
	vers = parseFloat(vers);
	if(vers < 7)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function getDocumentHeight() 
{
	var h1 = document.compatMode != 'CSS1Compat' ? document.body.scrollHeight : document.documentElement.scrollHeight;
	var h2 = getViewportHeight();
	return Math.max(h1, h2);
}
 
function getViewportHeight() {
  return ((document.compatMode || isIE()) && !isOpera()) ? (document.compatMode == 'CSS1Compat') ? document.documentElement.clientHeight : document.body.clientHeight : (document.parentWindow || document.defaultView).innerHeight;
}
