
var exclude=true;var agt=navigator.userAgent.toLowerCase();

var ie=false;var ie4=false;var ie5=false;var op5=false;var op6=false;var kde=false;

if(document.all&&(agt.indexOf('msie')!=-1)) 
{
	ie=true; ie4=true; exclude=false;
	if(agt.indexOf('msie 4')==-1){ie5=true;ie4=false;}
	if(agt.indexOf('opera')!=-1){ie=false;ie4=false;ie5=false;op5=true;}
}

var ns6=false;var mz7=false;

if(document.getElementById&&!ie) 
{
	ns6=true;exclude=false;
	if(agt.indexOf('netscape6')==-1) {mz7=true;}
	if(window.opera) {
	mz7=false;ns6=false;op5=true;
	if((agt.indexOf("opera 6")!=-1)||(agt.indexOf("opera/6")!=-1)){op6=true;op5=false;}
}
else if (agt.indexOf('gecko')==-1) { mz7=false; exclude=true; }
}

if(agt.indexOf('opera 4')!=-1) { op5=false; mz7=false; exclude=true; }

var ns4=false;

if((agt.indexOf('mozilla')!=-1)&&(parseInt(navigator.appVersion)>=4)&&!ie&&!op5&&!op6&&!ns6&&!mz7) 
{
	ns4=true;exclude=false;
}

if(agt.indexOf('webtv')!=-1) { ie=false; ie4=false; exclude=true; }

if((agt.indexOf('opera')!=-1)&&ns6&&exclude){ns6=false;}

var win=true; var lnx=false; var mac=false;

if(agt.indexOf('inux')!=-1) { win=false; lnx=true; }
if(agt.indexOf('mac')!=-1) { win=false; mac=true; }


var ns = (document.layers)? true:false
var dom = (document.createElement)? true:false

var flyOutOverColor = "#FFCC00";
var flyOutSTDColor = "#000000";
var menuStart_YPos = 162;
var menuWidth = 203;
var pageWidth = 762;
var timeout;
var pageLoaded = false;

var ticker = new Array;
			
var activeMenuImage = "";



var menu_home = new Image();
var menu_search = new Image();
var menu_current = new Image();
var menu_latest = new Image();
var menu_jobs = new Image();
var menu_archive = new Image();
var menu_library = new Image();
var courses_conferences = new Image();
var funding_opps = new Image();
var menu_statistics = new Image();
var university_perf = new Image();
var funding_allocations = new Image();
var university_wealth = new Image();
var higher_education_trends = new Image();
var academic_pay = new Image();
var staff_trends = new Image();
var student_life = new Image();
var further_edu_performance = new Image();
var oecd_comp = new Image();
var inter_student_mob = new Image();
var menu_common = new Image();
var menu_links = new Image();
var newsletters = new Image();
var subscribe = new Image();
var bookshop = new Image();
var menu_site = new Image();
var menu_exp_about = new Image();
var menu_exp_site_map = new Image();
var menu_exp_ed_contacts = new Image();
var menu_exp_feedback = new Image();
var how_to_advertise = new Image();
var worldrankings = new Image();
var menu_exp_press = new Image();
var menu_exp_privacy = new Image();
var menu_exp_terms = new Image();


var awards = new Image();
var contactdetails = new Image();
var howtoenter = new Image();
var listofawards = new Image();
var shortlist = new Image();
var sponsors = new Image();
var sponsorship = new Image();
var tablebookings = new Image();
var awards2005 = new Image();

var judges = new Image();
var entryform = new Image();
var keydates = new Image();

var rss = new Image();


var crTHES_home = new Image();

var inter_comparisons = new Image();


var menu_home_on = new Image();
var menu_search_on = new Image();
var menu_current_on = new Image();
var menu_latest_on = new Image();
var menu_jobs_on = new Image();
var courses_conferences_on = new Image();
var menu_archive_on = new Image();
var menu_library_on = new Image();
var funding_opps_on = new Image();
var menu_statistics_on = new Image();
var university_perf_on = new Image();
var funding_allocations_on = new Image();
var university_wealth_on = new Image();
var higher_education_trends_on = new Image();
var academic_pay_on = new Image();
var staff_trends_on = new Image();
var student_life_on = new Image();
var further_edu_performance_on = new Image();
var oecd_comp_on = new Image();
var inter_student_mob_on = new Image();
var menu_common_on = new Image();
var menu_links_on = new Image();
var newsletters_on = new Image();
var subscribe_on = new Image();
var bookshop_on = new Image();
var menu_site_on = new Image();
var menu_exp_about_on = new Image();
var menu_exp_site_map_on = new Image();
var menu_exp_ed_contacts_on = new Image();
var menu_exp_feedback_on = new Image();
var how_to_advertise_on = new Image();
var worldrankings_on = new Image();
var menu_exp_press_on = new Image();
var menu_exp_privacy_on = new Image();
var menu_exp_terms_on = new Image();

var crTHES_home_on = new Image();
var inter_comparisons_on = new Image();

var awards_on = new Image();
var contactdetails_on = new Image();
var howtoenter_on = new Image();
var listofawards_on = new Image();
var shortlist_on = new Image();
var sponsors_on = new Image();
var sponsorship_on = new Image();
var tablebookings_on = new Image();
var awards2005_on = new Image();

var judges_on = new Image();
var entryform_on = new Image();
var keydates_on = new Image();

var rss_on = new Image();

var top200universitytable = new Image();
var top200universitytable_on = new Image();
var editorial = new Image();
var editorial_on = new Image();
var methodology = new Image();
var methodology_on = new Image();
var europe = new Image();
var europe_on = new Image();
var northamerica = new Image();
var northamerica_on = new Image();
var restoftheworld = new Image();
var restoftheworld_on = new Image();
var reprise = new Image();
var reprise_on = new Image();
var allleaguetables = new Image();
var allleaguetables_on = new Image();

function menu_preload()
{
	methodology.src = "/images/menu/methodology.gif";
	methodology_on.src = "/images/menu/methodology_on.gif";
	editorial.src = "/images/menu/editorial.gif";
	editorial_on.src = "/images/menu/editorial_on.gif";
	top200universitytable.src = "/images/menu/top200universitytable.gif";
	top200universitytable_on.src = "/images/menu/top200universitytable_on.gif";
	europe.src = "/images/menu/europe.gif";
	europe_on.src = "/images/menu/europe_on.gif";
	northamerica.src = "/images/menu/northamerica.gif";
	northamerica_on.src = "/images/menu/northamerica_on.gif";
	restoftheworld.src = "/images/menu/restoftheworld.gif";
	restoftheworld_on.src = "/images/menu/restoftheworld_on.gif";
	reprise.src = "/images/menu/reprise.gif";
	reprise_on.src = "/images/menu/reprise_on.gif";
	allleaguetables.src = "/images/menu/allleaguetables.gif";
	allleaguetables_on.src = "/images/menu/allleaguetables_on.gif";
	
	menu_home.src="/images/menu/menu_home.gif";
	menu_search.src="/images/menu/menu_search.gif";
	menu_current.src="/images/menu/menu_current.gif";
	menu_latest.src="/images/menu/menu_latest.gif";
	menu_jobs.src="/images/menu/menu_jobs.gif";
	courses_conferences.src="/images/menu/courses_conferences.gif";
	menu_archive.src="/images/menu/menu_archive.gif";
	menu_library.src="/images/menu/menu_library.gif";
	funding_opps.src="/images/menu/funding_opps.gif";
	menu_statistics.src="/images/menu/menu_statistics.gif";
	university_perf.src="/images/menu/university_perf.gif";
	funding_allocations.src="/images/menu/funding_allocations.gif";
	university_wealth.src="/images/menu/university_wealth.gif";
	higher_education_trends.src="/images/menu/higher_education_trends.gif";
	academic_pay.src="/images/menu/academic_pay.gif";
	staff_trends.src="/images/menu/staff_trends.gif";
	student_life.src="/images/menu/student_life.gif";
	further_edu_performance.src="/images/menu/further_edu_performance.gif";
	oecd_comp.src="/images/menu/oecd_comp.gif";
	inter_student_mob.src="/images/menu/inter_student_mob.gif";
	menu_common.src="/images/menu/menu_common.gif";
	menu_links.src="/images/menu/menu_links.gif";
	newsletters.src="/images/menu/newsletters.gif";
	subscribe.src="/images/menu/subscribe.gif";
	bookshop.src="/images/menu/bookshop.gif"
	menu_site.src="/images/menu/menu_site.gif";
	menu_exp_about.src="/images/menu/menu_exp_about.gif";
	menu_exp_site_map.src="/images/menu/menu_exp_site_map.gif";
	menu_exp_ed_contacts.src="/images/menu/menu_exp_ed_contacts.gif";
	menu_exp_feedback.src="/images/menu/menu_exp_feedback.gif";
	how_to_advertise.src="/images/menu/how_to_advertise.gif";
	worldrankings.src="/images/menu/worldrankings.gif";
	menu_exp_press.src="/images/menu/menu_exp_press.gif";
	menu_exp_privacy.src="/images/menu/menu_exp_privacy.gif";
	menu_exp_terms.src="/images/menu/menu_exp_terms.gif";
	crTHES_home.src = "/images/common_room/crTHES_home.gif";
	inter_comparisons.src = "/images/menu/inter_comparisons.gif";

	
	awards.src =  "/images/menu/awards.gif";
	contactdetails.src = "/images/menu/contactdetails.gif";
	howtoenter.src = "/images/menu/howtoenter.gif";
	listofawards.src = "/images/menu/listofawards.gif";
	shortlist.src = "/images/menu/shortlist.gif";
	sponsors.src = "/images/menu/sponsors.gif";
	sponsorship.src = "/images/menu/sponsorship.gif";
	tablebookings.src = "/images/menu/tablebookings.gif";
	awards2005.src = "/images/menu/awards2005.gif";
	
	judges.src = "/images/menu/judges.gif";
	entryform.src = "/images/menu/entryform.gif";	
	keydates.src = "/images/menu/keydates.gif";
	
	rss.src = "/images/menu/rss.gif";

	awards_on.src =  "/images/menu/awards_on.gif";
	contactdetails_on.src = "/images/menu/contactdetails_on.gif";
	howtoenter_on.src = "/images/menu/howtoenter_on.gif";
	listofawards_on.src = "/images/menu/listofawards_on.gif";
	shortlist_on.src = "/images/menu/shortlist_on.gif";
	sponsors_on.src = "/images/menu/sponsors_on.gif";
	sponsorship_on.src = "/images/menu/sponsorship_on.gif";
	tablebookings_on.src = "/images/menu/tablebookings_on.gif";
	awards2005_on.src = "/images/menu/awards2005_on.gif";

	judges_on.src = "/images/menu/judges_on.gif";
	entryform_on.src = "/images/menu/entryform_on.gif";	
	keydates_on.src = "/images/menu/keydates_on.gif";
	
	rss_on.src = "/images/menu/rss_on.gif";

	menu_home_on.src="/images/menu/menu_home_on.gif";
	menu_search_on.src="/images/menu/menu_search_on.gif";
	menu_current_on.src="/images/menu/menu_current_on.gif";
	menu_latest_on.src="/images/menu/menu_latest_on.gif";
	menu_jobs_on.src="/images/menu/menu_jobs_on.gif";	
	courses_conferences_on.src="/images/menu/courses_conferences_on.gif";
	menu_archive_on.src="/images/menu/menu_archive_on.gif";
	menu_library_on.src="/images/menu/menu_library_on.gif";
	funding_opps_on.src="/images/menu/funding_opps_on.gif";
	menu_statistics_on.src="/images/menu/menu_statistics_on.gif";
	university_perf_on.src="/images/menu/university_perf_on.gif";
	funding_allocations_on.src="/images/menu/funding_allocations_on.gif";
	university_wealth_on.src="/images/menu/university_wealth_on.gif";
	higher_education_trends_on.src="/images/menu/higher_education_trends_on.gif";
	academic_pay_on.src="/images/menu/academic_pay_on.gif";
	staff_trends_on.src="/images/menu/staff_trends_on.gif";
	student_life_on.src="/images/menu/student_life_on.gif";
	further_edu_performance_on.src="/images/menu/further_edu_performance_on.gif";
	oecd_comp_on.src="/images/menu/oecd_comp_on.gif";
	inter_student_mob_on.src="/images/menu/inter_student_mob_on.gif";
	menu_common_on.src="/images/menu/menu_common_on.gif";
	menu_links_on.src="/images/menu/menu_links_on.gif";
	newsletters_on.src="/images/menu/newsletters_on.gif";
	subscribe_on.src="/images/menu/subscribe_on.gif";
	bookshop_on.src="/images/menu/bookshop_on.gif";
	menu_site_on.src="/images/menu/menu_site_on.gif";
	menu_exp_about_on.src="/images/menu/menu_exp_about_on.gif";
	menu_exp_site_map_on.src="/images/menu/menu_exp_site_map_on.gif";
	menu_exp_ed_contacts_on.src="/images/menu/menu_exp_ed_contacts_on.gif";
	menu_exp_feedback_on.src="/images/menu/menu_exp_feedback_on.gif";
	how_to_advertise_on.src="/images/menu/how_to_advertise_on.gif";
	worldrankings_on.src="/images/menu/worldrankings_on.gif";
	menu_exp_press_on.src="/images/menu/menu_exp_press_on.gif";
	menu_exp_privacy_on.src="/images/menu/menu_exp_privacy_on.gif";
	menu_exp_terms_on.src="/images/menu/menu_exp_terms_on.gif";
	crTHES_home_on.src = "/images/common_room/crTHES_home_o.gif";
	inter_comparisons_on.src = "/images/menu/inter_comparisons_on.gif";
}

function validateAwards(){
	var count=0;
	var message="You have not completed\n\n";

	if ((document.nominate.firstname.value=="" && document.nominate.surname.value=="") && document.nominate.department.value==""){
			message+="\nA Nominator\n";
			count++;
		}
	
	if (document.nominate.institutename.value==""){
		message+="Institute name\n";
		count++;
	}
	
	if (document.nominate.address1.value==""){
		message+="Address Line 1\n";
		count++;
	}	

	if (document.nominate.telephone.value==""){
		message+="Telephone\n";
		count++;
	}
	
	if (document.nominate.outofoffice.value==""){
		message+="Out of office number\n";
		count++;
	}
	
		if (document.nominate.award.selectedIndex == 0){
		message+="\nAward\n";
		count++;
	}
	
	if (document.nominate.reason.value==""){
		message+="Reason for nominating\n";
		count++;
	}
	
	if (document.nominate.sameas.checked == false && true){
	
		if ((document.nominate.nomineefirstname.value=="" && document.nominate.nomineesurname.value=="") && document.nominate.nomineedepartment.value==""){
			message+="\nA Nominee\n";
			count++;
		}		
			
		
		if (document.nominate.nomineeinstitutename.value==""){
			message+="Nominee Institute name\n";
			count++;
		}
		
		if (document.nominate.nomineeaddress1.value==""){
			message+="Nominee Address Line 1\n";
			count++;
		}	

		if (document.nominate.nomineetelephone.value==""){
			message+="Nominee Telephone\n";
			count++;
		}
		
		if (document.nominate.nomineeoutofoffice.value==""){
			message+="Nominee Out of office number\n";
			count++;
		}


	
	}
	
				if (!document.nominate.terms.checked){
			message+="\nAccept our terms and conditions\n";
			count++;
		}	

	
	if (count > 0){
		alert(message);
		return false;
	}
	else{
		return true;	
	}

}


function showCover()
{
	getDiv("cover").style.display = "block";
}

function hideCover()
{
	getDiv("cover").style.display = "none";
}

function show(menuImage)
{
	clearTimeout(timeout);
	var layer =  getDiv(menuImage);
	layer.style.visibility = 'visible';
	layer.style.display = 'block';

}

function hide(menuImage){
	showCover();
	eval("timeout=setTimeout('hidelayer(\""+menuImage+"\" )',300);")
}

function hidelayer(menuImage){
	var layer = getDiv(menuImage);
	activeMenuImage = "";
	mouseOutSwap(menuImage);
	hideCover();
	layer.style.visibility= 'hidden';
	
}

function setColor(layer,color)
{
	layer.style.color=color;
}

function getDiv(menuImage)
{
	if (dom)
	{
		return document.getElementById(menuImage + '_div');
	}
	else
	{
		if (ie)
		{
			return document.all[menuImage + '_div'];
		}
	}
}

function getDomElement(id)
{
	if (dom)
	{
		return document.getElementById(id);
	}
	else
	{
		if (ie)
		{
			return document.all[id];
		}
	}
}


function showFullText(id)
{
	
	if (ie || (dom && !ns  && !ns6))
	{
		var fullBodyDiv = getDomElement("fullBody" + id);
		var shortBodyDiv = getDomElement("shortBody" + id);
		var showFullTextDiv = getDomElement("showFullText" + id);
		var hideFullTextDiv = getDomElement("hideFullText" + id);
		
		if (fullBodyDiv)
		{
			shortBodyDiv.style.display="none";
			fullBodyDiv.style.display="block";

			showFullTextDiv.style.display="none";
			hideFullTextDiv.style.display="block";
		}
		
	}
	else
	{
		var currentLocation = document.location.href;
		var newLocation;
		if (currentLocation.indexOf('&messageID') != -1)
		{
			newLocation = currentLocation.substring(0,currentLocation.indexOf('&messageID'));
		}
		else
		{
			newLocation = currentLocation;
		}				
		alert(newLocation);
		newLocation += "&messageID=" + id + "#message" + id;
		document.location.href = newLocation;
	}

	return false;

}

function hideFullText(id)
{
	var fullBodyDiv = getDomElement("fullBody" + id);
	var shortBodyDiv = getDomElement("shortBody" + id);
	var showFullTextDiv = getDomElement("showFullText" + id);
	var hideFullTextDiv = getDomElement("hideFullText" + id);
	
	if (fullBodyDiv)
	{
		fullBodyDiv.style.display="none";
		shortBodyDiv.style.display="block";
		
		hideFullTextDiv.style.display="none";
		showFullTextDiv.style.display="block";
	}
	return false;

}

function showRollout(menuImage,flyOutTop)
{
	var showDiv = getDiv(menuImage);
	var newYpos = parseInt(menuStart_YPos) + parseInt(flyOutTop) - 3
	
	if (ns6)
	{
		//newYpos -= 17
	}	
	
	showDiv.style.top = newYpos + "px";

	var leftPos;
	
	var offsetWidth = document.body.offsetWidth;

	if (!ns6)
	{
		offsetWidth -= 20
	}

	if (offsetWidth > pageWidth)
	{
		leftPos = parseInt((offsetWidth - pageWidth)/2) + menuWidth;
	}
	else
	{
		leftPos = menuWidth;
	}
	
	showDiv.style.left = leftPos;
	getDiv("cover").style.left = leftPos - menuWidth;
	show(menuImage);
}

function hideRollout(menuImage)
{
	
	hide(menuImage);
}

function loadPage(url)
{
	document.location.href = url;
}

function rollOn(menuImage,hasFlyOut ,flyOutTop)
{
	if (activeMenuImage == "")
	{
		mouseOverSwap(menuImage);
		if (hasFlyOut && ((ie || dom) && !mac))
		{
			activeMenuImage = menuImage;
			showRollout(menuImage,flyOutTop);
		}
	}
}

function rollOff(menuImage,hasFlyOut)
{
	if (menuImage == activeMenuImage || activeMenuImage == "")
	{
		if (hasFlyOut && ((ie || dom) && !mac))
		{
			hideRollout(menuImage);
		}
		else
		{
			mouseOutSwap(menuImage);	
		}
	}
}

function mouseOverSub(menuImage)
{
	var layer = getDiv(menuImage);
	layer.style.color = flyOutOverColor;
}

function mouseOutSub(menuImage)
{
	var layer = getDiv(menuImage);
	layer.style.color = flyOutSTDColor;
}

function rollOnSubHolding(menuImage,parentMenuImage)
{
	clearTimeout(timeout);
	show(menuImage);
}
function rollOffSubHolding(menuImage,parentMenuImage)
{
	hide(menuImage)
}

function rollOnSubItem(menuImage,parentMenuImage)
{
	clearTimeout(timeout);
	mouseOverSub(menuImage);
	show(parentMenuImage);
}
function rollOffSubItem(menuImage,parentMenuImage)
{
	mouseOutSub(menuImage);
}

function mouseOverSwap(menuImage)
{
	if (pageLoaded)
	{
		var swapImg = eval("document." + menuImage);
		swapImg.src= eval(menuImage + "_on.src");
	}
}

function mouseOutSwap(menuImage)
{
	if (pageLoaded)
	{
		var swapImg = eval("document." + menuImage);
		swapImg.src= eval(menuImage + ".src");	
	}
}

function init()
{
	menu_preload();
	pageLoaded = true;
}

function initPopup()
{
	pageLoaded = true;
}


function adminPopUp() {
	var openStr = "/login/admin.asp"
	var adminWin=window.open(openStr,'admin','width=462,height=350,location=no,toolbar=no,scrollbars=yes,status=no,menubar=no,left=100,top=100');
	adminWin.opener.name = "thes";

}

function keepPass()
{
	var ie,ns;
	ns = (document.layers)? true:false;
	ie=(document.all)? true:false;
		
	if (document.admin.keepPassword.checked == true)
	{
		document.admin.newPassword.value = "";
		document.admin.newPassword2.value = "";
	}

	document.admin.newPassword.disabled = (!document.admin.newPassword.disabled)
	document.admin.newPassword2.disabled = (!document.admin.newPassword2.disabled)
}


function adminValidate()
{
var errorStr = "";

// create regular expression object to test for any non numeric, non letter and non underscore characters
var regExpression = /\W/;

		if (document.admin.keepPassword.checked == true)
				{
					document.admin.newPassword.value = "";
					document.admin.newPassword2.value = "";
				}

	if (document.admin.newPassword.value == "" && document.admin.newPassword2.value == "" && document.admin.keepPassword.checked == false) 
		{
			errorStr += "Please enter a Password or check \'Keep existing password\'.\n\n";
		}
	if (document.admin.newUserName.value == "" ) 
		{
			errorStr += "Please enter a User Name.\n\n";
		}
	if (document.admin.newPassword.value.toUpperCase() != document.admin.newPassword2.value.toUpperCase() ) 
		{
			errorStr += "Your passwords do not match. Check they match and are typed in the correct case.\n\n";
		}
	else
		{	
			if (  (document.admin.newPassword.value.length < 8 || document.admin.newPassword.value.length > 12 ) && document.admin.keepPassword.checked == false) 
				{
					errorStr += "Your password must be between 8 and 12 characters long.\n\n";		
				}
			if(regExpression.test(document.admin.newUserName.value))
				{
					errorStr += "Your username contains a non valid character. Usernames and passwords can only contain letters, numerals or underscores.\n\n";
				}
			if(regExpression.test(document.admin.newPassword.value))
				{
					errorStr += "Your password contains a non valid character. Usernames and passwords can only contain letters, numerals or underscores.\n\n";
				}
		}

	

	var str = document.admin.newEmailAddress.value
	var isEmail = ((str.indexOf("@") != -1) && (str.indexOf(".") != -1));
	
	if (!isEmail && document.admin.newEmailAddress.value != "" ) 
		{
			errorStr += "Please enter a valid e-mail address.\n\n";
		}
	if (errorStr != "")
		{
			alert(errorStr);
			document.returnValue = false;	
		}
	else
		{
			document.returnValue = true;
		}
}


function drawTextInputTag(Name,Size,Class, defaultValue, isPassword, maxLength, isDisabled, clearOnFocus, tabindex)
{
	if (isPassword)
	{
		var typeStr = "password";
	}
	else
	{
		var typeStr = "text";
	}		

	var tabindexStr = "";
	if (tabindex)
	{
		tabindexStr = " tabindex=\"" + tabindex + "\" ";
	}

	var clearOnFocusStr = "";
	if (clearOnFocus)
	{
		clearOnFocusStr = " onFocus=\"clearField(this)\" ";
	}	

	var disabledStr = "";
	if (isDisabled)
	{
		disabledStr = " disabled ";
	}

	if (defaultValue)
	{	
		defaultValue = defaultValue.replace(/\"/g,"\'");
	}
	else
	{
		defaultValue = '';
	}

	if ((dom) && (!ie))
	{
		document.write('<input name="' + Name + '" ' + clearOnFocusStr + ' ' + disabledStr + ' maxlength="' + maxLength + '" type="' + typeStr + '" size="' + Math.round(Size*(7/9)) + '" class="' + Class + '" value="' + defaultValue + '" ' + tabindexStr + ' />');		
	}
	else
	{
		if (ie)
		{
			document.write('<input name="' + Name + '" ' + clearOnFocusStr + ' ' + disabledStr + ' maxlength="' + maxLength + '" type="' + typeStr + '" size="' + Size + '" class="' + Class + '" value="' + defaultValue + '" ' + tabindexStr + ' />');	
		}
		else
		{	
			document.write('<input name="' + Name + '" ' + clearOnFocusStr + ' ' + disabledStr + ' maxlength="' + maxLength + '" type="' + typeStr + '" size="' + Math.round(Size*(8/15)) + '" class="' + Class + '" value="' + defaultValue + '" ' + tabindexStr + ' />');					
		}
	}
}


function validateBL(){
var counter=0;
var fields=document.forms[0].elements;
var message="You have not correctly entered :\n";
	for (var i=0;i<fields.length;i++){
		if (fields[i].name=="names"){
		   if (fields[i].value==""){
		   message += "name\n";
		   counter++;
		   }
		}
	   if (fields[i].name=="email"){
		   if (fields[i].value==""){
		   message += "email\n";
		   counter++;
		   }
	   }
	   if (fields[i].name=="thesno"){
		   if (fields[i].value==""){
		   message += "Thes subscriber number\n";
		   counter++;
		   }
	   }
		   
	   if (fields[i].name=="username"){
		   if (fields[i].value==""){
		   message += "username\n";
		   counter++;
		   }
		}
		if (fields[i].name=="password"){
		   if (fields[i].value==""){
		   message += "password\n";
		   counter++;
		   }
		}
   }
		if (counter>0){
		alert (message);
		return false;
		}
		else{
		return true;
		}
	

}



function drawTextAreaTag(Name,Rows,Cols,Class, defaultValue, isDisabled, tabindex)
{

	var disabledStr = "";
	if (isDisabled)
	{
		disabledStr = " disabled ";
	}
	
	if (!defaultValue)
	{
		defaultValue = '';
	}
	
	var tabindexStr = "";
	if (tabindex)
	{
		tabindexStr = " tabindex=\"" + tabindex + "\" ";
	}	
	
	var onkeypressStr = "";
	if (Name == "staffroomBody")
	{
		onkeypressStr = " onkeypress=\"return bodyKeypress();\" onblur=\"return bodyKeypress();\" ";
	}
	
	if ((dom) && (!ie))
	{
		document.write('<textarea name="' + Name + '" ' + disabledStr + ' rows="' + Rows + '" cols="' + Math.round(Cols*(13/15)) + '" class="' + Class + '" ' + tabindexStr + onkeypressStr + ' >' + defaultValue + '</textarea>');		
	}
	else
	{
		if (ie)
		{
			document.write('<textarea name="' + Name + '" ' + disabledStr + ' rows="' + Rows + '" cols="' + Cols + '" class="' + Class + '" ' + tabindexStr + onkeypressStr + ' >' + defaultValue + '</textarea>');		
		}
		else
		{	
			document.write('<textarea name="' + Name + '" ' + disabledStr + ' rows="' + Rows + '" cols="' + Math.round(Cols*(8/13)) + '" class="' + Class + '" ' + tabindexStr + onkeypressStr + ' >' + defaultValue + '</textarea>');		
		}
	}
}

function validateLogin()
{
	if (document.login.username.value == '' || document.login.password.value == '')
	{
		alert("Please enter both your username and password.");
		return false;
	}
	else
	{
		if (document.login.saveCookie.checked)
		{
			setCookie("username",document.login.username.value,true);
		}
		else
		{
			setCookie("username","",true);
		}
		return true;
	}
}

function setCookie(nameStr,valueStr,isPermanent)
{
	var cookieStr = nameStr + "=" + escape(valueStr) + ";";

	if (isPermanent)
	{
		var expDate = new Date("December 31, 2023");
		expDate = expDate.toGMTString();
		cookieStr += "expires=" + expDate + ";";
	}
	
	cookieStr += "path=/;";
	var myLocation = document.location.href;
	cookieStr += "domain=" + myLocation.substring(7,myLocation.indexOf("/",7)) + ";";
  
	document.cookie = cookieStr;

}

function readCookie(name) {

	if (document.cookie == '') 
	{ 
		return "";
	} 
	else 
	{
		
		var firstChar, lastChar;
		var theBigCookie = document.cookie;
	
		firstChar = theBigCookie.indexOf(name);
	
		if(firstChar != -1)  
		{
			firstChar += name.length + 1;
			lastChar = theBigCookie.indexOf(';', firstChar);
		
			if(lastChar == -1)
			{
				lastChar = theBigCookie.length;
			}
	    
			return unescape(theBigCookie.substring(firstChar, lastChar));

		}
		else
		{
			return "";
		}
    }
}
function newWin(url, name, width, height){
	var myWin = window.open(url, name, "scrollbars=yes,resizable=yes,menubar=yes,width="+width+",height="+height+"\"")
	myWin.opener.name = "THES";
}

function newStandardWin(url, name, width, height){
	
	var myWin = window.open(url, name, "scrollbars=yes,resizable=yes,menubar=yes,status=yes,toolbar=yes,location=yes,width="+width+",height="+height+"\"")
	myWin.opener.name = "THES";
}

function openWin( windowURL,windowname ) {
	newwin=window.open( windowURL.replace(/.aspx/,".asp").replace(/.asp/,".aspx") + "?window_type=popup",windowname );
}


			
function printTickerMessage(tickerMsgNo,charNo)
{
	if(!mac)
	{
		var displayStr = ticker[tickerMsgNo].substring(0,charNo);
		if (charNo < ticker[tickerMsgNo].length)
		{
			 displayStr += "_";
		}
				
		if (dom)
		{
			document.getElementById("tickerDiv").innerHTML = displayStr;
		}
		else
		{
			if (ie)
			{
				document.all.tickerDiv.innerHTML = displayStr;
			}
			else
			{
				document.outertickerDiv.document.innertickerDiv.document.write('<span style="font-family:Arial;color:black;font-weight:bold;font-size:13px;" >' + displayStr + '</span>');
				document.outertickerDiv.document.innertickerDiv.document.close();
			}
		}

		charNo ++;
					
		if (charNo > ticker[tickerMsgNo].length)
		{
			tickerMsgNo ++;
			if (tickerMsgNo == ticker.length)
			{
				tickerMsgNo = 0;
			}	
						
			setTimeout("printTickerMessage(" + tickerMsgNo + ",0)",5000);
		}
		else
		{
			setTimeout("printTickerMessage(" + tickerMsgNo + "," + charNo + ")",70);
		}
	}
}


function loginAlert(url,section)
{
	var dest_path = "";
	var queryString = "";
	var urlArray;
	var qsArray
	
	
	urlArray = url.split("?",2);
	dest_path = urlArray[0];
	
	if (urlArray.length > 1)
	{
		queryString = urlArray[1];
	}
	else
	{
		queryString = "";
	}
	
	qsArray = queryString.split("&");

	queryString = "dest_path=" + escape(dest_path);
	
	for (var i=0;i<qsArray.length;i++)
	{
		if (qsArray[i] != '')
		{
			queryString += "&dest_" + qsArray[i];
		}
	}
		
	loginPopUp("/login/sorry.asp" + "?" + queryString);
	
	
}

function loginPopUp (url) {

sorry=window.open(url,'sorry','width=438,height=340,location=no,toolbar=no,scrollbars=yes,status=no,menubar=no,resize=no,left=100,top=100');
sorry.opener.name = "thes";
return sorry;
}

function validateFeedback(){

var count=0;
var message = "you have not completed\n";

if (document.feedback.fullname.value==""){
	count++;
	message+="Name \n";

}

if (document.feedback.email.value=="" || (document.feedback.email.value.indexOf("@")==-1 || document.feedback.email.value.indexOf(".")==-1)){
	count++;
	message+="Email address \n";

}
if (document.feedback.message.value==""){
	count++;
	message+="Message \n";

}
if (count>0){
	alert(message);
	return false;

}
else return true;	
}


function submitSearch(frm){
	
	

	if (frm.searchwhat[0].checked == true){
		frm.action="/search/archive_search_results.aspx";
		return true;
	}
	
	else if (frm.searchwhat[1].checked==true){
		frm.action="/search/site_search_results.aspx";
		return true;	
	}
	
	else {
		frm.action="/search/search_results.aspx";
		return true;	
	}
	
}

function submitBookSearch(f)
{
	f.searchSubject.options[f.searchSubject.selectedIndex].value = f.searchSubject.options[f.searchSubject.selectedIndex].text;
	if (f.searchSubject.options[f.searchSubject.selectedIndex].value == "All")
		f.searchSubject.options[f.searchSubject.selectedIndex].value = "";

	return true;
}



function validateFreeTrial(){
	var regExpression = /\W/;
	var message="You have not correctly entered \n";
	var count=0;
	if (document.free_online_trial.username.value=="" || (document.free_online_trial.username.value.length < 8 || document.free_online_trial.username.value.length > 12 )){
		message+="Username must be between 8 and 12 characters\n";
		count++;
	}
	if (document.free_online_trial.password.value==""){
		message+="Password\n";
		count++;
	}
	if (document.free_online_trial.password.value != document.free_online_trial.confirm_password.value){
		message+="Passwords do not match\n";
		count++;
	}			
	
	if (document.free_online_trial.fullname.value==""){
		message+="Name\n";
		count++;
	}
	if (document.free_online_trial.address1.value==""){
		message+="Address line 1\n";
		count++;
	}
	if (document.free_online_trial.country.value==""){
		message+="Country\n";
		count++;
	}
	if (document.free_online_trial.postcode.value==""){
		message+="Postcode\n";
		count++;
	}
	
	if (document.free_online_trial.email.value=="" || (document.free_online_trial.email.value.indexOf(".") ==-1 || document.free_online_trial.email.value.indexOf("@")==-1)){
		message+="Email Address\n";
		count++;
	}
	if (document.free_online_trial.email.value != document.free_online_trial.confirm_email.value){
		message+="Email addresses do not match\n";
		count++;
	}
	
	if(regExpression.test(document.free_online_trial.password.value))
	{
		alert("Your password contains a non valid character. Usernames and passwords can only contain letters, numerals or underscores.");
		return false;
	}

	if (count > 0){
		alert(message);
		return false;
	}
	else {
		return true;
	}	
}






function validateAndSubmitEmail()
{
	var objForm = document.frmFreeTrial;
	var sEmail = objForm.strEmail.value;
	var sSecondEmail = objForm.strSecondEmail.value;
	var blnIsEmail 
	
	if (sEmail == "" || sSecondEmail=="")
	{
		alert("Please enter your email address in both fields.");
		return false;
	}
	
	blnIsEmail = ((sEmail.indexOf("@") != -1) && (sEmail.indexOf(".") != -1) && (sSecondEmail.indexOf("@") != -1) && (sSecondEmail.indexOf(".") != -1));
	
	if (!blnIsEmail && document.frmFreeTrial.strEmail.value != "" ) 
	{
			alert("Please enter a valid e-mail address.");
			return false;
	}
	else if ((sEmail!=sSecondEmail)){
	
		alert ("Email addresses don't match");
		return false;
	}
	return true;
}

function validateAndSubmitAccessDetails()
{
	var objForm = document.frmFreeTrial;
	var sUserName = objForm.strUserName.value;
	var sPassword = objForm.strPassword.value;
	var sPasswordCheck = objForm.strPasswordCheck.value;
	var sEmail = objForm.strEmail.value;	
	
	// create regular expression object to test for any non numeric, non letter and non underscore characters
	var regExpression = /\W/;
	
	if (sUserName == "")
	{
		alert("Please enter a username.");
		return false;
	}
	if ((sUserName.length < 8)||(sUserName.length > 12))
	{
		alert("The username must be between 8 and 12 characters long.");
		return false;
	}
	if(regExpression.test(sUserName))
	{
		alert("Your username contains a non valid character. Usernames and passwords can only contain letters, numerals or underscores.");
		return false;
	}
	
	if (sPassword == "")
	{
		alert("Please enter a password.");
		return false;
	}
	if ((sPassword.length < 8)||(sPassword.length > 12))
	{
		alert("The password must be between 8 and 12 characters long.");
		return false;
	}
	if (sPassword != sPasswordCheck)
	{
		alert("The passwords you have entered don't match, please re-enter them.");
		return false;
	}
	if(regExpression.test(sPassword))
	{
		alert("Your password contains a non valid character. Usernames and passwords can only contain letters, numerals or underscores.");
		return false;
	}

	return true;
}


function validateFreeIssue(){
	var count=0;
	var message="You have not completed\n";

	if (document.freeIssue.profession.value==""){

		message+="Profession\n";
		count++;
	}

	if (document.freeIssue.address1.value==""){

		message+="Address Line 1\n";
		count++;
	}	

	if (document.freeIssue.address2.value==""){

		message+="Address Line 2\n";
		count++;
	}		
	
	if (document.freeIssue.country.value==""){

		message+="Country\n";
		count++;
	}
	
	if (document.freeIssue.postcode.value==""){

		message+="Postcode\n";
		count++;
	}


	if (count > 0){
		alert(message);
		return false;
	}
	else{
		return true;	
	}

}

//	validate email address. 10/11/05
function validateEmailAddress(emailAddress)
{
	if(window.RegExp) 
	{
		// browser supports RegExp
		var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)"; // not valid
		var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"; // valid
		var reg1 = new RegExp(reg1str);
		var reg2 = new RegExp(reg2str);
								
		if (!reg1.test(emailAddress))
		{
			if(reg2.test(emailAddress))
			{
				return true;
			}else{
				return false;
			}
		}else{
			return false;
		}
		
	}else 
	{
		// does not support RegExp
		if(emailAddress.indexOf("@") >= 0)
		{
			if(emailAddress.indexOf(".") >= 0)
			{
				return true;
			}
		}else
		{
    		return false;
		}
	}
}


function validateNewsletters()
{
	var isValid = false;
	isValid = validateEmailAddress(document.emailalert.email.value);
	
	if(isValid == false)
	{
		alert("Please enter a valid email address");
		document.emailalert.email.focus();
		document.emailalert.email.select();
		return false;
	}
	return true;
}


function validate_forum_search() {

	if(document.forumSearchForm.staffroomSearchStr.value == '')
		{
			alert('Please enter search criteria');
		}
	else
	{
		document.forumSearchForm.submit();
	}

}

//	updated 11/11/05
function validateRegistration()
{
	if (!document.regFormSubmitted)
	{
		document.regFormSubmitted = true;
		
		var isValid = false;
		
		if (document.fRegister.username.value == '')
		{
			alert("Please complete all the required fields to register");
			document.regFormSubmitted = false;
			document.fRegister.username.focus();
			return false;
		}
		
		if (document.fRegister.password.value == '')
		{
			alert("Please complete all the required fields to register");
			document.regFormSubmitted = false;
			document.fRegister.password.focus();
			return false;
		}
		
		if (document.fRegister.firstName.value == '')
		{
			alert("Please complete all the required fields to register");
			document.regFormSubmitted = false;
			document.fRegister.firstName.focus();
			return false;
		}
		
		if (document.fRegister.lastName.value == '')
		{
			alert("Please complete all the required fields to register");
			document.regFormSubmitted = false;
			document.fRegister.lastName.focus();
			return false;
		}
		
		if (document.fRegister.password.value != document.fRegister.password2.value)
		{
			alert("Passwords do not match");
			document.regFormSubmitted = false;
			return false;
		}
		
		isValid = validateEmailAddress(document.fRegister.email.value);
		
		if(isValid == false)
		{
			alert("Please enter a valid email address");
			document.regFormSubmitted = false;
			document.fRegister.email.focus();
			document.fRegister.email.select();
			return false
		}
		
		return true;
	}
	else
	{
		return false;
	}
}

function staffroomRegisterValidate() {

	document.staffroomRegistration.country[document.staffroomRegistration.country.selectedIndex].value = document.staffroomRegistration.country[document.staffroomRegistration.country.selectedIndex].text ;

	var errorStr = "";

	for (var i=0;i<document.staffroomRegistration.elements.length;i++)
	{
		if (eval('document.staffroomRegistration.elements[i].value') == '' && document.staffroomRegistration.elements[i].name.toLowerCase() != 'country' && document.staffroomRegistration.elements[i].type != 'hidden') 
		{
			errorStr = errorStr + document.staffroomRegistration.elements[i].name.replace(/_/g,' ') + '\n';
		}
	}
		
	if (errorStr != '')
	{
		errorStr = 'Please complete the following fields:\n\n' + errorStr; 
		alert(errorStr);
		return;
	}
	
	var emailStr = document.staffroomRegistration.Email_address.value;
	var isEmail = ((emailStr.indexOf("@") != -1) && (emailStr.indexOf(".") != -1));

	if (!isEmail) {
		alert('Please enter a valid e-mail address');	
		return;
	}

	if (document.staffroomRegistration.Password.value != document.staffroomRegistration.Password_check.value)
	{
		document.staffroomRegistration.Password.value = '';
		document.staffroomRegistration.Password_check.value = '';
		alert('Your passwords do not match.\n\nPlease complete the password fields again.');
		return;		
	}

	document.staffroomRegistration.submit();

}

function staffroomPostValidate() {
	var errorStr = "";

	if (document.staffroomMessage.staffroomLoginUsername)
	{
		if (document.staffroomMessage.staffroomLoginUsername.value == '') 
		{
			errorStr += 'Username\n';
		}
	}

	if (document.staffroomMessage.staffroomLoginPassword)
	{
		if (document.staffroomMessage.staffroomLoginPassword.value == '') 
		{
			errorStr += 'Password\n';
		}
	}

	if (document.staffroomMessage.staffroomSubject)
	{
		if (document.staffroomMessage.staffroomSubject.value == '') 
		{
			errorStr += 'Subject\n';
		}
	}

	if (document.staffroomMessage.staffroomBody.value == '')
	{
		errorStr += 'Message\n';
	}

	if (errorStr != '')
	{
		errorStr = 'Please complete the following fields:\n\n' + errorStr; 
		alert(errorStr);
		return;
	}

	document.staffroomMessage.submit();
}

function printerFriendly(url)
{
	return newWin(url,"THES_printer_friendly",605,500);
}

function validatePost(){
	var count=0;
	var message="Please enter the following required fields:\n\n";
	if (document.fPost.staffroomLoginUsername){
		if (document.fPost.staffroomLoginUsername.value==""){
			message+="Username\n"
			count++;				
		}
	
		if (document.fPost.staffroomLoginPassword.value==""){
			message+="Password\n"
			count++;				
		}
	}
	
	if (document.fPost.staffroomSubject){

		if (document.fPost.staffroomSubject.value==""){
			message+="Subject\n"
			count++;				
		}
	}
	
	if (document.fPost.staffroomBody){

		if (document.fPost.staffroomBody.value==""){
			message+="Message\n"
			count++;				
		}

	}	
	
	if (count>0){
		alert(message);
		return false;
	
	}
	else
	{ 
		return true;
 	}
}

function validateFeedback(formName)
{
	var errorStr = "";
	var doneStr = "";
	var clearCheckRadio = "";
	var fieldValue;
	var fieldName;
	var fieldType;
	var field;
	var ii;
	var elementLength;
	var elementChecked;
	var elementNameChecked;
	var exceptionStr = "";
  if (formName == 'endofyearpoll'){
	exceptionStr = ",question1_text,question2_text,question3_text,question4_text,question5_text,question6_text,question7_text,question8_text,question9_text,question10_text,";
  }
	eval("var formLength = document." + formName + ".elements.length;");
	for (var i=0;i<formLength;i++)
	{
		eval("fieldValue = document." + formName + ".elements[i].value;");
		eval("fieldName = document." + formName + ".elements[i].name;");
		
		if (exceptionStr.indexOf("," + fieldName + ",") == -1)
		{
			if ( doneStr.indexOf(fieldName + '#') == -1 && fieldName || "")
			{
				eval("elementLength = document." + formName + "." + fieldName + ".length;");
				if (!elementLength > 0 )
				{
					eval("fieldType = document." + formName + "." + fieldName + ".type;");
					if (fieldType == 'text') 
					{
						eval("field = document." + formName + "." + fieldName + ".name;");
						eval("fieldValue = document." + formName + "." + fieldName + ".value;");
						if (fieldValue == "")
						{
							errorStr += fieldName + '  \n';
						}
					}				
				}
				else
				{
					elementNameChecked = false;
					for (ii=0;ii<elementLength;ii++)
					{
						eval("fieldType = document." + formName + "." + fieldName + "[ii].type;");
						if (fieldType == 'checkbox' || fieldType == 'radio') 
						{
							eval("elementChecked = document." + formName + "." + fieldName + "[ii].checked;");
							if (elementChecked == true)
							{
								elementNameChecked = true;
							}
						}					
						if (fieldType == 'text') 
						{
							eval("fieldValue = document." + formName + "." + fieldName + "[ii].value;");
							if (fieldValue != "")
							{
								elementNameChecked = true;
							}
						}
					}
					if (elementNameChecked == false && !elementLength != 1)
					{
						if (eval("document." + formName + "." + fieldName + "_text")){
							if (eval("document." + formName + "." + fieldName + "_text.value") == "" ){
								errorStr += fieldName + '  \n';	
							}
						}
						else{
							errorStr += fieldName + '  \n';								
						}
						
					}
				}
				doneStr += fieldName + '# ';
			}
		}			
	}
	
	
		
	if (errorStr != "" )
	{
		alert('Please complete the following questions:\n\n' + errorStr.replace(/_/g," ") );
		return false;
	}		
	else
	{
		return true;
	}
}







