window.onerror = handle_error;

var hideHdl = null;
var hideMnu = null;

function showMenu(cid, pid, who)
{
	if (! who) { who = 0; }
	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)-who;
		o.style.left=dim.x;
		o.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(8);
	menuitems[0]='mnuborrow';
	menuitems[1]='mnuoriginate';
	menuitems[2]='mnusecuritise';
	menuitems[3]='mnuinvest';
	menuitems[4]='tmnuborrow';
	menuitems[5]='tmnuoriginate';
	menuitems[6]='tmnusecuritise';
	menuitems[7]='tmnuinvest';

	for (var i=0 ; i < 8; i++ ) {
		if (cid != menuitems[i]) {
			hideMenu2(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 navover(file) {
	document.getElementById(file).src = 'image/nav_'+file+'_o.gif';
}
function navout(file) {
	document.getElementById(file).src = 'image/nav_'+file+'.gif';
}

function showlarge(map,w,h) {
	limage = window.open('image/'+map+'-l.gif','limage','width='+w+',height='+h);
	limage.focus();
}

function validatecontact() {
	if (document.forms[0].First_Name.value=='') { 
		alert('Please enter your First Name');
		return false;
	}
	if (document.forms[0].Last_Name.value=='') {
		alert('Please enter your Last Name');
		return false;
	}
	if (document.forms[0].Email.value=='') {
		alert('Please enter your Email Address');
		return false;
	}
	if (document.forms[0].Enquiry_Type.value=='') {
		alert('Please make a selection for enquiry/request/feedback');
		return false;
	}
	return true;
}

function handle_error() { return true; }
