//------------------------- Image Rollover Effects ----------------------------//

var cache = new Object;

function preload( name,image )
{
    if (document.images)
	{
		cache[name] = new Image();
		cache[name].src = image;
	}
}

function rollover( name )
{

    if (document.images)
	{
	  	var x;
	  	eval("x = document['" + name + "']" );
	  	cache.image = x;
	  	cache.src   = x.src;
		if( typeof(cache[name]) == "object" )
	  		x.src = cache[name].src;
	}
}

function restore()
{
	if (document.images)
	  cache.image.src = cache.src;
}


//---------------------- Menu Rollover Effects -----------------------------------//


function menu_on( Cell )
{
	Cell.style.backgroundColor = "#FFFFFF"; //"#B6B6C2";
}

function menu_off( Cell )
{
	Cell.style.backgroundColor = "transparent";
}



function ShowDate()
{
var d   = new Date();
var Day = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var Month = new Array("January","February","March","April","May","June","July","August",
			"September","October","November","December");
document.write( d.getDate()+ " " + Month[d.getMonth()]+ " "+ d.getUTCFullYear() );
}


//--------------------- Carriage Return Handling in Forms ------------------------//

function onReturn( Handler )
{
	if (event.keyCode == 13)
	{
		eval( Handler + "();" );
	}
}


//---------------------------- Popup Window Functions ----------------------------//


function help( Topic )
{
	location.href = '/help/default.asp?topic=' + Topic;
}

function messagePopup( msgName )
{
	openWin('/help/popup.asp?message=' + msgName,'message',480,180,"center");
}

function openWin( sSource, sName, iWidth, iHeight, sPosition )
{
	var xOffset = 0, yOffset = 0;
	var sFeatures = "";
	var noFrame   = false;
	var newWindow;

	// Check to see if 'noFrame' is specified in the position

	if( sPosition.slice(0,7) == "noFrame" )
	{
		noFrame = true;
		sPosition = sPosition.slice(8);
	}

	// Work out how big the screen is

	if (document.all)
	    var xMax = screen.width, yMax = screen.height;
	else if (document.layers)
	    var xMax = window.outerWidth, yMax = window.outerHeight;
    	else
	    var xMax = 800, yMax=600;

	// Work out the window positioning

	if (sPosition == "bottomLeft")
	{
		xOffset = 0;
		yOffset = (yMax - iHeight) - 60;
	}
	else if (sPosition == "topRight")
	{
		xOffset = (xMax - iWidth) - 8;
		yOffset = 0;
	}
	else if ( sPosition.match("[0123456789*]+:[0123456789*]+") )
	{
		xOffset = sPosition.substring( 0, sPosition.indexOf(":",0))
		yOffset = sPosition.substring( xOffset.length+1,sPosition.length );

		if( xOffset == "*" ) xOffset = (xMax - iWidth)/2;
		if( yOffset == "*" ) yOffset = (yMax - iHeight)/2;
	}
	else //center
	{
		xOffset = (xMax - iWidth)/2;
		yOffset = (yMax - iHeight)/2;
	}

	// Set the features of the window

	sFeatures = "width=" + iWidth + ",height=" + iHeight + ",scrollbars=yes";

	if (xOffset > 0 || yOffset > 0)
	{
		sFeatures = sFeatures + ",left=" + xOffset + ",top=" + yOffset;
		sFeatures = sFeatures + ",screenX="+ xOffset + ",screenY=" + yOffset;
	}

	// Open the new window with the calculated attributes

	if (noFrame)
	{
		sFeatures = "fullscreen," + sFeatures;
		newWindow = window.open( sSource, sName, sFeatures);
		newWindow.blur();
		window.focus();
		newWindow.resizeTo(iWidth,iHeight);
		newWindow.moveTo(xOffset,yOffset);
	}
	else
	{
		newWindow = window.open( sSource,sName,sFeatures );

		if (newWindow.opener == null)
		{
			newWindow.opener = self;
		}
	}

	newWindow.focus();
}


//---------------------- Copyright Message for Page Protection --------------------//

function rightClickEvent(e)
{
	if (event.button >1) alert("copyright (c) 2002 Exec-Appointments Ltd");
}

function disableRightClick()
{
	document.onmousedown = rightClickEvent;
	if (document.layers) window.captureEvents(Event.MOUSEDOWN);
}


//------------------- Validate Email Address for Correct Syntax ------------------//

function validateEmail(strEmail)
{
	var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
    var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
    var reg1    = new RegExp(reg1str);
    var reg2    = new RegExp(reg2str);

    return (!reg1.test(strEmail) && reg2.test(strEmail)) ;
}


//------------------------ Miscellanious -----------------------------------------//

function printDoc()
{
   if (window.print)
   {
		if ( top.window != window )
		{
			top.frames[1].window.focus();
		}

   		window.print();
   }
   else
   {
       alert('Your browser doesn\'t support printing from this link. Use ctrl-p instead.')
   }
}

