//window.onload = prepareLinks;

function prepareLinks()
{
	var links = document.getElementsByTagName("a");
	for (var i=0; i<links.length; i++)
	{
		if (links[i].getAttribute("className"))
		{
			if (links[i].getAttribute("classname") == "external")
			{
				if (links[i].getAttribute('title') == '')
					links[i].setAttribute("title","(opens in a new window)");
				links[i].onclick = function()
				{
					OpenNewWindow(this.getAttribute('href'));
					return false;
				}
			}
			else if (links[i].getAttribute('classname').substring(0,6) == 'popup_')
			{
				links[i].setAttribute('title','this is a popup');
				links[i].onclick = function()
				{
					popup(50,50,this.getAttribute('classname').split('_')[1],this.getAttribute('classname').split('_')[2],this.getAttribute('href'));
					return false;
				}
			}
			else
			{
	//			var linkText  = links[i].firstChild.nodeValue;
	//			links[i].setAttribute('title','this is a link to '+linkText);
			}
		}
		else if (links[i].getAttribute("class"))
		{
			if (links[i].getAttribute("class"))
			{
				if (links[i].getAttribute("class") == "external")
				{
					if (links[i].getAttribute('title') == '')
						links[i].setAttribute("title","(opens in a new window)");
					links[i].onclick = function()
					{
						OpenNewWindow(this.getAttribute('href'));
						return false;
					}
				}
				else if (links[i].getAttribute('class').substring(0,6) == 'popup_')
				{
					links[i].setAttribute('title','this is a popup');
					links[i].onclick = function()
					{
						popup(50,50,this.getAttribute('class').split('_')[1],this.getAttribute('class').split('_')[2],this.getAttribute('href'));
						return false;
					}
				}
			}
		}
  	}
}


function popup(x,y,w,h,fn)
{
	NewWindow = window.open(fn,'descr','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=0,scrollbars=1,resizable=1,copyhistory=no,width='+w+',height='+h+', top='+y+',left='+x)
}


function OpenNewWindow(fn)
{
	NewWindow = window.open(fn)
}


function showTitle(ff)
{
	ff.title = 'opens in new window';
}
function removeSubMenux()
{
	//REMOVE THE SUB NAVIGATION FOR JAVASCRIPT ENABLED BROWSERS
	var javaContainer = document.getElementById('javaContainer');
	var noneJava = document.getElementById('noneJava');
	if (noneJava != null)
		javaContainer.removeChild(noneJava);
}



function helpm(no,w,h,t,l,hname)
{
	NewWindow=window.open('/help/helpDisplay.asp?fl='+no+'#'+hname,'descr','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=0,scrollbars=1,resizable=1,copyhistory=no,width='+w+',height='+h+',top='+t+',left='+l)
}


function confirmSubmit(fl)
{
	var agree = confirm('Are you sure you wish to delete '+fl+'?');
	if (agree)
		return true ;
	else
		return false ;
}

function checkFormFields()
{
	//var email2 = ''; //document.forms[0].email.value;
	var name = document.forms[0].name.value;
	var vf = false;
	var msg = '';
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(document.forms[0].email.value))
		vf = true;
	else
	{
		msg = 'Sorry it looks like you have entered an invalid email address.\n';
		vf = false;
	}

	if (name.length == 0)
	{
		msg = msg + 'You have forgotten to fill in your name.\n';
		vf = false;
	}
	else if (vf)
		vf = true;
	
	if (msg != '')
		alert(msg);
	return vf;
}

function menuLevel(mcat_id)
{
//	alert(mcat_id);
	var mtopLevel = '';
	var msection = '';
	for(i=1;i<6;i++)
	{
		mtopLevel = 'top_'+i
		msection = document.getElementById(mtopLevel);
		msection.className = '';
	}
	
	mtopLevel = 'top_'+mcat_id
//	alert(mtopLevel);
	msection = document.getElementById(mtopLevel);
	msection.className = 'section';
//	alert(mtopLevel);
	
}


