
var iFromEM = 0;
var strEMLogout = '';

function writeSB() {
document.write('<table border="0" cellpadding="0" cellspacing="0" width="145" bgcolor="#CCFFFF"><form name="surfboardSearch" method=POST action="javascript:performSearch();"><tr><td bgcolor="#6600FF"><img src="/images/lapages/common/spacer.gif" width="15" height="1" border="0"></td><td bgcolor="#6600FF"><img src="/images/lapages/common/spacer.gif" width="119" height="1" border="0"></td><td bgcolor="#6600FF"><img src="/images/lapages/common/spacer.gif" width="11" height="1" border="0"></td></tr><tr><td colspan="3" height="45" width="145"><img name="surf_ban" src="/images/lapages/common/surf_ban.gif" width="145" height="45" border="0"></td></tr><tr><td colspan="3" height="19" width="145"><a href="/admin" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage(\'surf_ad\',\'\',\'/images/lapages/common/surf_ad_f2.gif\',1)" onClick="openSB()"><img name="surf_ad" src="/images/lapages/common/surf_ad.gif" alt="Administration tools for LearningAlive services" width="145" height="19" border="0"></a></td></tr><tr><td colspan="3" width="145" height="17"><a href="http://www.mathsalive.co.uk/?Surfboard" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage(\'surf_ma\',\'\',\'/images/lapages/common/surf_ma_f2.gif\',1)" onClick="openSB()"><img name="surf_ma" src="/images/lapages/common/surf_ma.gif" alt="MathsAlive Framework Edition - interactive content and teaching tools for KS3 Maths" width="145" height="17" border="0"></a></td></tr><tr><td colspan="3" width="145" height="17"><a href="/icta.html" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage(\'surf_ic\',\'\',\'/images/lapages/common/surf_ic_f2.gif\',1)"><img name="surf_ic" src="/images/lapages/common/surf_ic.gif" width="145" height="17" border="0" alt="ICT Alive"></a></td></tr><tr><td colspan="3" width="145" height="17"><a href="http://www.easiteach.com/" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage(\'surf_et\',\'\',\'/images/lapages/common/surf_et_f2.gif\',1)" onClick="openSB()"><img name="surf_et" src="/images/lapages/common/surf_et.gif" width="145" height="17" border="0" alt="Easiteach - whole-class teaching service with online bank of Maths activities"></a></td></tr><tr><td colspan="3" width="145" height="17"><a href="http://www.livinglibrary.co.uk" onClick="openSB()"><img name="surf_ll" src="/images/lapages/common/surf_ll.gif" width="145" height="17" border="0" alt="Living Library - resource bank of educational articles, pictures and multimedia" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'surf_ll\',\'\',\'/images/lapages/common/surf_ll_f2.gif\',1)"></a></td></tr><tr><td colspan="3" width="145" height="17"><a href="javascript:openEMWin();" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage(\'surf_em\',\'\',\'/images/lapages/common/surf_em_f2.gif\',1)" onClick="openSB()"><img name="surf_em" src="/images/lapages/common/surf_em.gif" width="145" height="17" border="0" alt="EasyMail Plus and EasyMail systems designed for schools"></a></td></tr><tr><td colspan="3" width="145" height="17"><a href="http://www.wbol.co.uk/" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage(\'surf_wb\',\'\',\'/images/lapages/common/surf_wb_f2.gif\',1)" onClick="openSB()"><img name="surf_wb" src="/images/lapages/common/surf_wb.gif" width="145" height="17" border="0" alt="Window Box OnLine - lesson ideas and resources for Window Box computers"></a></td></tr><tr><td colspan="3" width="145" height="17"><a href="/pathways/pw_map.asp" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage(\'surf_pw\',\'\',\'/images/lapages/common/surf_pw_f2.gif\',1)" onClick="openSB()"><img name="surf_pw" src="/images/lapages/common/surf_pw.gif" width="145" height="17" border="0" alt="Pathways - thousands of selected educational weblinks"></a></td></tr><tr><td colspan="3" width="145" height="17"><a href="/AtSchool/index.asp" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage(\'surf_as\',\'\',\'/images/lapages/common/surf_as_f2.gif\',1)" onClick="openSB()"><img name="surf_as" src="/images/lapages/common/surf_as.gif" width="145" height="17" border="0" alt="At School - website publishing service and directory of websites"></a></td></tr><tr><td colspan="3" width="145" height="17"><a href="/la_staffroom/staff.htm" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage(\'surf_sr\',\'\',\'/images/lapages/common/surf_sr_f2.gif\',1)" onClick="openSB()"><img name="surf_sr" src="/images/lapages/common/surf_sr.gif" width="145" height="17" border="0" alt="Staffroom - useful links for teachers"></a></td></tr><tr><td colspan="3" width="145" height="17"><a href="/la_ednews/edlink.htm" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage(\'surf_en\',\'\',\'/images/lapages/common/surf_en_f2.gif\',1)" onClick="openSB()"><img name="surf_en" src="/images/lapages/common/surf_en.gif" width="145" height="17" border="0" alt="Education News"></a></td></tr><tr><td colspan="3" width="145" height="17"><a href="/search/pathways-search.html" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage(\'surf_wst\',\'\',\'/images/lapages/common/surf_wst_f2.gif\',1)" onClick="openSB()"><img name="surf_wst" src="/images/lapages/common/surf_wst.gif" alt="Tools and advice for searching the Web" width="145" height="17" border="0"></a></td></tr><tr><td colspan="3"><img name="surf_srch" src="/images/lapages/common/surf_srch.gif" width="145" height="51" border="0" alt="Quick Web Search"></td></tr><tr><td><img name="surf_lft1" src="/images/lapages/common/surf_lft1.gif" width="15" height="21" border="0"></td><td bgcolor="#ffffff" align="center"> <font face="Verdana, Arial, Helvetica, sans-serif" size="-2"><input type=hidden name=safe value=strict><input type=hidden name=sa value="Google Search"><input type=hidden name=q value=""><input type="text" name="searchText" size="10" class="searchbox"></font></td><td><img name="surf_rit1" src="/images/lapages/common/surf_rit1.gif" width="11" height="21" border="0"></td></tr><tr><td colspan="3"><a href="javascript:performSearch();" onMouseOut="MM_swapImgRestore();"  onMouseOver="MM_swapImage(\'surf_go\',\'\',\'/images/lapages/common/surf_go_f2.gif\',1);" ><img name="surf_go" src="/images/lapages/common/surf_go.gif" width="145" height="21" border="0" alt="Go"></a></td></tr><tr><td colspan="3"><img name="surf_btm" src="/images/lapages/common/surf_btm.gif" width="145" height="10" border="0"></td></tr></form></table>')
}

function showSBWin(strURL) {
	if (navigator.appName == "Microsoft Internet Explorer"){
		if (navigator.platform.indexOf('Win') > -1) {
			var newWindow=window.open(strURL,'Surfboard','width=145,height=400,top=' + (screen.height-screen.availheight) + ',left=' + (screen.availwidth-155));
		}
		else {
			var newWindow=window.open(strURL,'Surfboard','width=145,height=400,top=0,left=' + (screen.width-155));
		}
	}
	else {
		var newWindow=window.open(strURL,'Surfboard','width=160,height=415,top=0,left=' + (screen.width-165));
	}
}

function openSB() {
	window.name = 'Main';
	showSBWin('/surfboard.htm');
}

function openEMSB(strPrefix,strDomain,strUser) {
	showSBWin('/surfboard.htm?' + strPrefix + strDomain + '/MBX/' + strUser + '@' + strDomain + '/LOGOUT' );
}

function openEMWin() {
	if (window.name != 'Surfboard') {
		window.name = 'Main';
	}
	var newWindow=window.open('/EasymailForm.html','Easymail','width=500,height=430,scrollbars=yes' );
}

function getFocus() {
	setTimeout("self.focus()", 2000);
	if (location.search) {
		iFromEM = 1;
		strEMLogout = 'http://' + location.search.substr(1);
	}
}

function jump(newURL) {
	if (iFromEM) {
		var window_page = window.open(strEMLogout,'Main');
		iFromEM = 0;
		setTimeout("jump('" + newURL + "')",3000);
	}
	else {
		if (window.name == 'Surfboard') {
			var window_page = window.open(newURL,'Main');
			setTimeout("self.focus()", 2000);
		} 
		else if (window.name == 'Easymail') {
			var window_page = window.open(newURL,'Main');
			openSB();
			setTimeout("window.close()",1000);
		}
		else {
			openSB();
			location.href=newURL;
		}
	}
}


function home(newURL){
	if (iFromEM) {
		var window_page = window.open(strEMLogout,'Main');
		iFromEM = 0;
		setTimeout("home('" + newURL + "')",3000);
	}
	else {
		var newPage = window.open(newURL,'Main')
		setTimeout("window.close()",2000);
	}
}

function performSearch(){
	var searchType;
	var x=0;
	var strOrig = document.surfboardSearch.searchText.value;
	var strNew = "";
	if(thereIsText(strOrig)) {
			//try google via querystring
			strNew = strOrig.replace(/[^A-Za-z0-9 \"\'+&-]/g,"");
			strNew = escape(strNew).replace(/%20/g,"+");
			strGoogle = '/redctgg.htm';
			strGoogle = strGoogle + '?q=' + strNew + '&safe=strict';
			jump(strGoogle)
	}
}
function thereIsText(blah){
	if(blah.length == 0) {
		alert("Sorry but you did not enter any words on which to search, please try again.");
		return false;
	} else {
		return true;
	}
}
