window.onerror = handle_error;

var hideHdl = null;
var hideMnu = null;

function showMenu(cid, pid, osx, osy)
{

	if (!osx) {
		osx=0;
		osy=0;
		hideall(cid);
	} else {
		hideallsub(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+7+osy;
		o.style.left=dim.x+osx;
		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(5);
	menuitems[0]='mnuAbout';
	menuitems[1]='mnuBusiness';
	menuitems[2]='mnuNews';
	menuitems[3]='mnuInvestors';
	menuitems[4]='mnuSustain';


	for (var i=0 ; i < 5; i++ ) {
		if (cid != menuitems[i]) {
			hideMenu2(menuitems[i]);
		}
	}
}
function hideallsub(cid) {
	var menuitems= new Array(2);
	menuitems[0]='mnuUIsub1';
	menuitems[1]='mnuUIsub2';


	for (var i=0 ; i < 2; i++ ) {
		if (cid != menuitems[i]) {
			hideMenu2(menuitems[i]);
		}
	}
}

function hideMenu(cid)
{
	hideall(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)
	{
		if (cid=='mnuBusiness') hideallsub('');
		o.style.display='none';
	}
}

function ddmenuLight(d,s) {
	var cname='ddMenuItem';
	if (s) cname='ddMenuItem_over';
	document.getElementById(d).className=cname;
}



 function printme(t) {
	newwindow=window.open('','printframe','height=500,width=600,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
	newwindow.document.write('<html><head><title>'+t+'</title><style>body {font-family:Arial;line-height:1.5em;}.purplehead {font-weight:bold;}li{padding-bottom:20px;line-height:1.5em;}.faq{font-weight:bold;margin-top:20px;}.clearbar{clear:both;}</style></head><body>'+document.getElementById('textpanel').innerHTML+'</body></html>');
	newwindow.document.close();
	newwindow.print();
 }


function validate() {
	if (document.forms[0].firstname.value.length==0 
		|| document.forms[0].surname.value.length==0
		|| document.forms[0].title.value.length==0
		|| ! document.forms[0].email.value.match(/[\w\-\.]+@[\w\-\.]+/)
	   )
	{
		alert('Please fill in the mandatory fields');
		return false;
	}
	return true;
}


function handle_error() { return true; }
