
//window.onerror = handle_error;

var hideHdl = null;
var hideMnu = null;
var yfact = 0;

function showMenu(cid, pid, who)
{
	if (who != null) { yfact = who; }
	hideall(cid);
	var o = document.getElementById(cid);
	var op = document.getElementById(pid);

	if(o&&op)
	{
		if(hideMnu)
		{
			var o = document.getElementById(cid);
			if(o)
			{
				o.style.display='none';
				clearTimeout(hideHdl);
			}			
		}
		var dim = getDim(op);
		o.style.top=dim.y+op.clientHeight-parseInt(o.style.height) + 20 - yfact;
		o.style.left=dim.x;
		o.style.display='';
//		if (! who) {
//			document.getElementById('blurb'+pid).style.display='';
//		}
	}
}

function getDim(el){
	for (var lx=0,ly=0;el!=null;lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent);
	return {x:lx,y:ly}
}

function hideall(cid) {
	var menuitems= new Array(7);
	menuitems[0]='info';
	menuitems[1]='personnel';
	menuitems[2]='dev';
	menuitems[3]='projects';
	menuitems[4]='markets';
	menuitems[5]='mining';
	menuitems[6]='geology';

	for (var i=0 ; i < 7; i++ ) {
		if (cid != 'mnu'+menuitems[i]) {
//			hideMenu2('blurb'+menuitems[i]);
			hideMenu2('mnu'+menuitems[i]);
		}
	}
}

function hideMenu(cid)
{
	var o = document.getElementById(cid);
	if(o)
	{
		hideHdl = setTimeout('hideMenu2("' + cid + '")', 500);
		hideMnu = cid;
	}
}

function hideMenu2(cid)
{
	var o = document.getElementById(cid);
	if(o)
	{
		o.style.display='none';
	}
}


var curSel;
var oldClass;
function doHover(o)
{
	if(curSel!=o.id)
	{
		oldClass = o.className;
		o.className = "mnuSelItem";
		curSel = o;
	}
}
function doUnHover(o)
{
	if(o!=null)
	{
		o.className = oldClass;
		curSel = null;
		oldClass = "";
	}
}

var curSel2;
var oldClass2;
function doHover2(o)
{
	if(curSel!=o.id)
	{
		oldClass2 = o.className;
		o.className = "mnuSelItem2";
		curSel2 = o;
	}
}
function doUnHover2(o)
{
	if(o!=null)
	{
		o.className = oldClass2;
		curSel2 = null;
		oldClass2 = "";
	}
}

function doClick(url)
{
	location.href=url;
}

function handle_error() { return true; }

function showpopup(u,w,h) {
	people = window.open(u,'people','width='+w+',height='+h);
	people.focus();
}

function validate() {
	if (! document.forms[0].name.value.match(/[a-z]+/i)) {
		alert('Please enter your name!');
		return false;
	}
	if (! document.forms[0].email.value.match(/[a-z]+/i)) {
		alert('Please enter your email address!');
		return false;
	}
	if (! document.forms[0].profession[document.forms[0].profession.selectedIndex].value.match(/[a-z]+/i)) {
		alert('Please select your profession!');
		return false;
	}
	return true;	
}

function validateme() {
	if (! document.forms[0].name.value.match(/[a-z]+/i)) {
		alert('Please enter your name!');
		return false;
	}
	if (! document.forms[0].email.value.match(/[a-z]+/i)) {
		alert('Please enter your email address!');
		return false;
	}

	if (! document.forms[0].enquiry.value.match(/[a-z]+/i)) {
		alert('Please enter your enquiry!');
		return false;
	}
	return true;	
}