//Global variables decalred below

var height;		//window height
var width;	//window width
TOP_BANNER_HEIGHT = 126;  //the height of the banner at the top of tghe window
FOOTER_HEIGHT = 26; //the height of the footer
LEFT_PANE_WIDTH = 213;  // The width of the left hand pane containing the Logo and search form#
PATH = "/";


// Function to check whether the site is being displayed within the frameset of another site.
//Call it using the OnLoad event handler in the index page of the website
function checkNotFramed(){
	if (top != self){
		top.location.href = self.location.href;
	}
}

function validateSearchForm(searchForm){
	//alert('In validate');
	//alert(searchForm.keyword.value);
	searchForm.submit();
}

function insertSpacer(output){
	output += '\t\t<td class="menu">&nbsp;|&nbsp;</td>'
}

function createMenu(presentLocation){
	//alert(presentLocation);
	var output;
		output = '<table width="100%" cellspacing="0" cellpadding="0" border="0">\n';
		output += '<tr>';
			output += '<td class="menu">';
				output += '<table cellspacing="5" cellpadding="0" border="0">\n';
					output += '\t<tr>\n';

					//Home
					if (presentLocation == PATH + 'home.asp'){ 	
						output += '\t\t<td class="menu"><span class="selected">Home</span></td>\n';
					}
					else {
						output += '\t\t<td class="menu"><a href="home.asp" class="menu">Home</a></td>\n';
					}
					//Insert spacer
					output += '\t\t<td class="menu">&nbsp;|&nbsp;</td>'

					//Clients
					if (presentLocation ==  PATH + 'clients.asp'){ 	
						output += '\t\t<td class="menu"><span class="selected">Clients</span></td>\n';
					}
					else {
						output += '\t\t<td class="menu"><a href="clients.asp" class="menu">Clients</a></td>\n';
					}

					//Insert spacer
					output += '\t\t<td class="menu">&nbsp;|&nbsp;</td>'	

					//Candidates
					if (presentLocation ==  PATH + 'candidates.asp'){ 	
						output += '\t\t<td class="menu"><span class="selected">Candidates</span></td>\n';
					}
					else {
						output += '\t\t<td class="menu"><a href="candidates.asp" class="menu">Candidates</a></td>\n';
					}

					
					//Insert spacer
					output += '\t\t<td class="menu">&nbsp;|&nbsp;</td>'	

			
					//CV preparation
					if (presentLocation ==  PATH + 'CV.asp'){ 	
						output += '\t\t<td class="menu"><span class="selected">CV preparation</span></td>\n';
					}
					else {
						output += '\t\t<td class="menu"><a href="CV.asp" class="menu">CV preparation</a></td>\n';
					}
				
					//Insert spacer
					output += '\t\t<td class="menu">&nbsp;|&nbsp;</td>'	

					//The interview
					if (presentLocation ==  PATH + 'interview.asp'){ 	
						output += '\t\t<td class="menu"><span class="selected">The interview</span></td>\n';
					}
					else {
						output += '\t\t<td class="menu"><a href="interview.asp" class="menu">The interview</a></td>\n';
					}

					output += '\t</tr>\n';
				output += '</table>\n';
			output += '</td>';
			output += '<td class="menu" align="right">';
				output += '<table cellspacing="5" cellpadding="0" border="0">\n';
					output += '<tr>';
				//Location map
				//	if (presentLocation ==  PATH + 'location.asp'){ 	
				//		output += '\t\t<td class="menu"><span class="selected">Location Map</span></td>\n';
				//	}
				//	else {
				//		output += '\t\t<td class="menu"><a href="#" class="menu">Location Map</a></td>\n';
				//	}
				
					//About Adlam
					if (presentLocation ==  PATH + 'aboutUs.asp'){ 	
						output += '\t\t<td class="menu"><span class="selected">About Adlam</span></td>\n';
					}
					else {
						output += '\t\t<td class="menu"><a href="aboutUs.asp" class="menu">About Adlam</a></td>\n';
					}
					output += '</tr>';
					output+= '</table>';
		output += '</td>';
	output += '</tr>';
	output += '</table>';		
	//alert(output);
	document.writeln(output);
}

function getDimensions() {
	//alert('hello');
	if (document.layers) {
		height = window.innerHeight;
		width = window.innerWidth;
	} else {
		height = document.body.offsetHeight;
		width = document.body.offsetWidth;
	}
	
	if ( document.getElementById && document.all ) {
		
		//alert(document.getElementById("searchcell") );
		document.getElementById("searchcell").style.height =  (height - TOP_BANNER_HEIGHT - FOOTER_HEIGHT); 
		//document.getElementById("mainContent").style.width =  '100%'; 
	}
}

var testresults

//Function to validate email address
function checkEmail( str) {
	var filter=/^.+@.+\..{2,3}$/
	//alert(str);
	if ( filter.test(str) ) {
		return true;
	} else {
		alert("Please input a valid email address!")
		return false;
	}
	return false;
}


//Function to open up new window with the specified page displayed in it
function popUp(page){ 

	var winl = (window.screen.width - 500) / 2;
	var wint = (window.screen.height - 300) / 2;
	var winWidth = 500;
	var winHeight = 300;
	
	if (document.layers){
				winprops = 'resizable=yes,scrollbars=yes,screenX='+ winl+ ',screenY='+ wint+ ',height='+winHeight+',width='+winWidth;
	}
	else {
		winprops = 'height='+winHeight+',width='+winWidth+', toolbar=no,menubar=no,location=no, scrollbars=yes, left='+ winl+ ', top='+ wint+ ', status=no, resizable=yes';
	}
	popUpWin = window.open(page,null, winprops);
}

function closeWindow() {
	alert('In close window');
	window.Close();
}
