////////////////////////////////////////
// 3 Deep CMS public global javascript file
////////////////////////////////////////
// global popup window vars //

var theWidth = 411;
var theHeight = 329;
var theTop=(screen.height/2)-(theHeight/2);
var theLeft=(screen.width/2)-(theWidth/2);
var maillistfeatures = "height=329,width=411,status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,top=" + theTop + ",left=" + theLeft;

var theWidth = 400;
var theHeight = 461;
var theTop=(screen.height/2)-(theHeight/2);
var theLeft=(screen.width/2)-(theWidth/2);
var videofeatures = "height=461,width=400,status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,top=" + theTop + ",left=" + theLeft;

var theWidth = 700;
var theHeight = 461;
var theTop=(screen.height/2)-(theHeight/2);
var theLeft=(screen.width/2)-(theWidth/2);
var biosfeatures = "height=461,width=700,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,top=" + theTop + ",left=" + theLeft;

var theWidth = 800;
var theHeight = 485;
var theTop=(screen.height/2)-(theHeight/2);
var theLeft=(screen.width/2)-(theWidth/2);
var galleryfeatures = "height=485,width=800,status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,top=" + theTop + ",left=" + theLeft;

// menu synchronisation function //
function doSynch()
{
	// get page location from root directory
	var s = self.location.pathname;
	// get and put into mainString just the path of the location
	mainmenuString = s.substring(s.indexOf('\/')-1, s.lastIndexOf('\/') + 1);
	// get and put into submenuString the path and filename of the location making sure that there is at least the default file name for the directory
	if(s.indexOf(".") != -1)
	{
		submenuString = s;
	}
	else
	{
		submenuString = s + "default.htm";
	}
	// if the mainmenuString does not evaluate to the root directory cycle through menumenu links and highlight active main menu item
	if(mainmenuString != "/")
	{
		for(i=0;i<document.links.length;i++)
		{
			//alert(document.links[i].href);
			if(document.links[i].href.indexOf(mainmenuString) != -1 && document.links[i].className == "mainmenu")
			{
				document.links[i].className = "mainmenuselected";
			}
		}
	}
	else // just make the home link highlighted
	{
		for(i=0;i<document.links.length;i++)
		{
			if(document.links[i].name == "home")
			{
				document.links[i].className = "mainmenuselected";
			}
		}
	}
	// now cycle again to hightlight the submenu item
	for(i=0;i<document.links.length;i++)
	{
		if(document.links[i].href.indexOf(submenuString) != -1 && document.links[i].className == "submenu")
		{
			document.links[i].className = "submenuselected";
		}
	}
}

function checkEmail(emailAddress) {

	var foundAtSymbol = 0;
	var foundDot = 0;
	var md;

	// Go through each character in the email address.
	for (var x=0; x<emailAddress.length - 1; x++) {
		md = emailAddress.substr(x, 1);
	
		// Is the character an @ symbol?
		if (md == '@') foundAtSymbol++;
	
		// Count how many dots there are after the @ symbol.
		if (md == '.' && foundAtSymbol == 1) foundDot++;
	}

	// Is there only one @ symbol, and are there more than one dots?
	if (foundDot > 0 && foundAtSymbol == 1) {
		return true;
	} else {
		return false;
	}
}

// onload initialisation function //

function init()
{
	doSynch();
}

window.onload = init;