//Check for browser vendor
var IE = false;
var NS = false;

IE = (document.all) ? true : false;
NS = (document.layers) ? true : false;
if(navigator.appName == "Microsoft Internet Explorer") { IE = true; }
if(navigator.appName == "Netscape") { NS = true; }

<!--
isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
NS4 = (document.layers) ? true : false;
IEmac = ((document.all)&&(isMac)) ? true : false;
IE4plus = (document.all) ? true : false;
IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
IE6 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 6.")!=-1)) ? true : false;
ver4 = (NS4 || IE4plus) ? true : false;
NS6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;

IE5plus = IE5 || IE6;
IEMajor = 0;

if (IE4plus)
{
	var start = navigator.appVersion.indexOf("MSIE");
	var end = navigator.appVersion.indexOf(".",start);
	IEMajor = parseInt(navigator.appVersion.substring(start+5,end));
	IE5plus = (IEMajor>=5) ? true : false;
}


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}


 //  End -->



function checkkeyword(which) {
var pass=true;
if (document.images) {
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name.substring(0,13)=="phrase_search") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
break;
         }
      }
   }
}
if (!pass) {
alert("Please enter a keyword before searching.");
return false;
}
else
return true;
}

function openWindow(url,width,height) { 
x = (640 - width)/2, y = (480 - height)/2; 

if (screen) { 
y = (screen.availHeight - height)/2; 
x = (screen.availWidth - width)/2; 
} 

window.open(url,'newWin','width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x+',scrollbars=1,resizable=1,status=1'); 
} 



function markSelection ( txtObj ) {
 if ( txtObj.createTextRange ) {
   txtObj.caretPos = document.selection.createRange().duplicate();
   isSelected = true;
 }
}

function insertTag ( txtName, tag ) {
 
 if ( isSelected ) {
   var txtObj = eval ( "document.addnews." + txtName );
   if (txtObj.createTextRange && txtObj.caretPos) {
     var caretPos = txtObj.caretPos;
     caretPos.text = ( tag + caretPos.text );
     markSelection ( txtObj );
     if ( txtObj.caretPos.text=='' ) {
       isSelected=false;
       txtObj.focus();
	   markSelection(document.addnews.pm_copy);
     }
   }
 } else {
   alert ('please click where in the text box you would like to add the formatting.\n\n');
 }
}

function escapeVal(textarea,replaceWith){
textarea.value=escape(textarea.value)
for(i=0; i<textarea.value.length; i++){
 	if(textarea.value.indexOf("%0D%0A") > -1){
	textarea.value=textarea.value.replace("%0D%0A",replaceWith)
	}
	else if(textarea.value.indexOf("%0A") > -1){
	textarea.value=textarea.value.replace("%0A",replaceWith)
	}
	else if(textarea.value.indexOf("%0D") > -1){
	textarea.value=textarea.value.replace("%0D",replaceWith)
	}
}
textarea.value=unescape(textarea.value)
}

function linkCreate() {
      
	  writehtml = document.main.HREF.value + document.main.http.value + document.main.linkURL.value +
document.main.linkTarget.value + document.main.linkText.value +
document.main.closeA.value
insertTag ( 'pm_copy', writehtml ); 
document.main.linkText.value = ""; 
document.main.linkURL.value = "http://"; 
 
}
	
	
function linkCreateWithoutText() {
      writehtml = document.main.HREF.value + document.main.http.value + document.main.linkURL.value +
document.main.linkTarget.value + document.main.linkURL.value +
document.main.closeA.value
insertTag ( 'pm_copy', writehtml ); 
document.main.linkText.value = ""; 
 document.main.linkURL.value = "http://"; 
}

function linkINCreate() {
      
	  writehtml = document.internal.inlink.value + document.internal.inlinkText.value +
document.internal.closeA.value  
insertTag ( 'pm_copy', writehtml ); 

}



function makeLink() {
	if (main.linkURL.value == "http://")
	    {
		alert ('Add the address URL for your link.\n\n');
	    }  
	else if (main.linkText.value == "")
	    {
		linkCreateWithoutText(main.linkURL.value, 'http:\/\/')
	    } 
	else 
	    {
		linkCreate(main.linkURL.value, 'http:\/\/');
	    }
}



function makeINLink() {
	if (internal.inlinkText.value == "")
	    {
		alert ('Add the text you would like to appear for this link.\n\n');
	    } 
	else if (internal.inlink.value == "")
	    {
		alert ('Please select the internal page you would like to link to.\n\n');
		} 
	else 
	    {
		linkINCreate();
	    }
}


function create_window() { 
  
 document.addnewspre.pm_copy_new.value = document.addnews.pm_copy.value;
  escapeVal(document.addnewspre.pm_copy_new,'<br>\n');


 storywin = window.open();
  with (storywin.document)
  { 



writeln ("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
writeln ("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">");
writeln ("<head>");
writeln ("<title>Hotcourses Foundation</title>");
writeln ("<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/affiliates/300905/styles.css\">");
writeln ("<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/affiliates/300905/cms.css\">");
writeln ("</head>");
writeln ("<body>");
writeln ("<div id=\"top\">");
writeln ("	<div class=\"logo\"><a href=\"index.html\"><img src=\"/img/affiliates/300905/logo.gif\" width=\"299\" height=\"77\" alt=\"\" border=\"0\" /></a></div>");
writeln ("	<div class=\"date\">");
writeln ("	date");
writeln ("	</div>");
writeln ("</div>");
writeln ("<div id=\"branding\">");
writeln ("	<div class=\"strap\"></div>");
writeln ("	<div class=\"pic\"><img src=\"/img/affiliates/300905/rt_top_2.jpg\" width=\"499\" height=\"120\" border=\"0\" alt=\"\" id=\"brandpic\" name=\"brandpic\" /></div>");
writeln ("</div>");
writeln ("<div class=\"clear\"></div>");
writeln ("<div id=\"holder\">");
writeln ("	<div id=\"menu\">");
writeln ("		<a href=\"#\">Home</a>");
writeln ("		<a href=\"#\">Aims</a>");
writeln ("		<a href=\"#\">Achievements to date</a>");
writeln ("		<a href=\"#\">Kibera project</a>");
writeln ("		<a href=\"#\">Kitui school project</a>");
writeln ("		<a href=\"#\">Sri Lanka school project</a>");
writeln ("		<a href=\"#\">2006 objectives Trustees</a>");
writeln ("		<a href=\"#\">Support the Foundation</a>");
writeln ("		<a href=\"#\">Hotcourses Ltd.</a>");
writeln ("		<a href=\"#\">Contact us</a>");
writeln ("	</div>");
writeln ("	<div id=\"content\">");
writeln ("	<div class=\"newshead\">");
writeln (	document.addnews.pm_newsheadline.value);
writeln ("	</div>");
writeln ("	<p><strong>");
writeln (	document.addnews.pm_summary.value);
writeln ("	</strong></p>");
writeln ("	<p>");
writeln (	document.addnewspre.pm_copy_new.value);
writeln ("	</p>");
writeln ("	</div>");
writeln ("</div>");
writeln ("<div id=\"footer\">");
writeln ("	<div class=\"logo\"><a href=\"#\"><img src=\"/img/affiliates/300905/nyumbani.gif\" width=\"120\" height=\"100\" alt=\"\" border=\"0\" /></a></div>");
writeln ("	<div class=\"basemenu\">");
writeln ("		<span class=\"charity\">Registered Charity Number 1104396</span>");
writeln ("		<a href=\"#\">Home</a>");
writeln ("		|");
writeln ("		<a href=\"#\">Contact Us</a>");
writeln ("	</div>");
writeln ("</div>");
writeln ("</body>");
writeln ("</html>");

 }


}




function content_preview() { 
  
 document.addnewspre.pm_copy_new.value = document.addnews.pm_copy.value;
  escapeVal(document.addnewspre.pm_copy_new,'<br>\n');


 storywin = window.open();
  with (storywin.document)
  { 


writeln ("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
writeln ("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">");
writeln ("<head>");
writeln ("<title>Hotcourses Foundation</title>");
writeln ("<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/affiliates/300905/styles.css\">");
writeln ("<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/affiliates/300905/cms.css\">");
writeln ("</head>");
writeln ("<body>");
writeln ("<div id=\"top\">");
writeln ("	<div class=\"logo\"><a href=\"index.html\"><img src=\"/img/affiliates/300905/logo.gif\" width=\"299\" height=\"77\" alt=\"\" border=\"0\" /></a></div>");
writeln ("	<div class=\"date\">");
writeln ("	date");
writeln ("	</div>");
writeln ("</div>");
writeln ("<div id=\"branding\">");
writeln ("	<div class=\"strap\"></div>");
writeln ("	<div class=\"pic\"><img src=\"/img/affiliates/300905/rt_top_2.jpg\" width=\"499\" height=\"120\" border=\"0\" alt=\"\" id=\"brandpic\" name=\"brandpic\" /></div>");
writeln ("</div>");
writeln ("<div class=\"clear\"></div>");
writeln ("<div id=\"holder\">");
writeln ("	<div id=\"menu\">");
writeln ("		<a href=\"#\">Home</a>");
writeln ("		<a href=\"#\">Aims</a>");
writeln ("		<a href=\"#\">Achievements to date</a>");
writeln ("		<a href=\"#\">Kibera project</a>");
writeln ("		<a href=\"#\">Kitui school project</a>");
writeln ("		<a href=\"#\">Sri Lanka school project</a>");
writeln ("		<a href=\"#\">2006 objectives Trustees</a>");
writeln ("		<a href=\"#\">Support the Foundation</a>");
writeln ("		<a href=\"#\">Hotcourses Ltd.</a>");
writeln ("		<a href=\"#\">Contact us</a>");
writeln ("	</div>");
writeln ("	<div id=\"content\">");
writeln ("	<div class=\"sectionhead\">");
writeln (	document.addnews.pm_title.value);
writeln ("	</div>");
writeln (	document.addnewspre.pm_copy_new.value);
writeln ("	</div>");
writeln ("</div>");
writeln ("<div id=\"footer\">");
writeln ("	<div class=\"logo\"><a href=\"#\"><img src=\"/img/affiliates/300905/nyumbani.gif\" width=\"120\" height=\"100\" alt=\"\" border=\"0\" /></a></div>");
writeln ("	<div class=\"basemenu\">");
writeln ("		<span class=\"charity\">Registered Charity Number 1104396</span>");
writeln ("		<a href=\"#\">Home</a>");
writeln ("		|");
writeln ("		<a href=\"#\">Contact Us</a>");
writeln ("	</div>");
writeln ("</div>");
writeln ("</body>");
writeln ("</html>");
 }


}

/*var originalcolour='#fff';
	var highlightcolour='#fcc';*/
	/*function init()
	{
	  	if(document.getElementById && document.createTextNode)
		{
			var mn=document.getElementById('nav');
			var lis=mn.getElementsByTagName('li');
			for (var i=0;i<lis.length;i++)
			{
				if(lis[i].getElementsByTagName('ul').length>0)
				{
					lis[i].getElementsByTagName('a')[0].onclick=function(){expand(this);return false}
					lis[i].getElementsByTagName('a')[0].onkeypress=function(){expand(this);return false}
				}
			}		
			
		}
		expand(null);
	}
	function expand(origin){
	  	if(document.getElementById && document.createTextNode)
		{
			var mn=document.getElementById('nav');
			var lis=mn.getElementsByTagName('li');
			for (var i=0;i<lis.length;i++)
			{
				if(lis[i].getElementsByTagName('ul').length>0)
				{
					if (origin!=lis[i].getElementsByTagName('a')[0])
					{
						lis[i].getElementsByTagName('a')[0].style.display='block';
						lis[i].getElementsByTagName('ul')[0].style.display='none';						
					}
				}
			}		
			if(origin){
				var daughternode=origin.parentNode.getElementsByTagName('ul')[0];
				if(daughternode.style.display=='none')
				{
					daughternode.style.display='block';*/
					/*origin.style.background=highlightcolour;*/
				/*}else{
					daughternode.style.display='none';*/
					/*origin.style.background=originalcolour;*/
				/*}						
			}	
		}
	}		

	window.onload=init;*/
	
	
function imgmakeLink() {
	  writehtml = document.image.SRC.value + document.image.image_list.value + document.image.alt_quote.value + document.image.altText.value + document.image.align_quote.value + document.image.align.value +
document.image.padding_quote.value + document.image.padding.value + document.image.closeSRC.value
insertTag ( 'pm_copy', writehtml ); 
}

function cmsimgmakeLink() {
	  writehtml = document.image.SRC.value + document.image.image_list.value + document.image.alt_quote.value + document.image.altText.value + document.image.align_quote.value + document.image.align.value +
document.image.padding_quote.value + document.image.padding.value + document.image.closeSRC.value
insertTag ( 'pm_copy', writehtml ); 
}

function cmsmakeELink() {      
	  writehtml = document.email.mailto.value + document.email.emailAddress.value + document.email.mail_quote.value + 
document.email.emailText.value + document.email.close_mail_a.value
insertTag ( 'pm_copy', writehtml );  
}

function bold() {
	twrite = prompt("Please type the text you'd like to appear in bold below:",'');
	if (twrite != null && twrite != ""){
	document.addnews.pm_copy.value = document.addnews.pm_copy.value + "<strong>" + twrite + "</strong>";
	}
}

function underline(){
	twrite = prompt("Please type the text you'd like to be underlined below:",'');
	if (twrite != null && twrite != ""){
	document.addnews.pm_copy.value = document.addnews.pm_copy.value + "<u>" + twrite + "</u>";
	}
}

function italic() {
	twrite = prompt("Please type the text you'd like to appear in italics below:",'');
	if (twrite != null && twrite != ""){
	document.addnews.pm_copy.value = document.addnews.pm_copy.value + "<em>" + twrite + "</em>";
	}
}

function bullet() {
	  document.addnews.pm_copy.value = document.addnews.pm_copy.value + "\n&#149;";
}

function hr() {
	  document.addnews.pm_copy.value = document.addnews.pm_copy.value + "<hr />";
}

	function checkFields() {
		missinginfo = "";
		if (document.addnews.pm_name.value == "") {
			missinginfo += "\n  - Name";
		}
		if (document.addnews.image_list.value == "") {
			missinginfo += "\n  - Image";
		}
		if (document.addnews.pm_summary.value == "") {
			missinginfo += "\n  - Summary";
		}
		if (document.addnews.pm_biog.value == "") {
			missinginfo += "\n  - Biography";
		}
		if (document.addnews.pm_aspirations.value == "") {
			missinginfo += "\n  - Aspirations";
		}
		if (document.addnews.pm_sponsorship.value == "") {
			missinginfo += "\n  - Sponsorship";
		}
		if (missinginfo != "") {
			missinginfo = "Before you can save this biography the following fields must be completed:\n" +
			missinginfo + "\n\nPlease check your information and submit the form again.";
			alert (missinginfo);
			return false;
		}
		else return true;			
	}