
var DOM    = (document.getElementById ? 1 : 0);
var IE4DOM = (document.all ? 1 : 0);
var NS4    = (document.layers ? 1 : 0);


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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 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 BookmarkCurrentPage() {
    if (document.all && window.external) {
		var uri = "http://www.teach-ict.com";
        var title = "Teach ICT Home Page";
        window.external.AddFavorite(uri, title);
    }
    else {
        alert( "Sorry! Your browser doesn't support this function automatically.\nTry a combination of the \"CTRL\" key and \"D\" (where applicable), or see your browser's support pages.");
    }
}




function GetStyle(id) {
    var idHandle = (DOM ? document.getElementById(id) : (IE4DOM ? document.all[id] : false));
    return (idHandle ? idHandle.style : false);
}


var setcolor = "#00ff00";
var overcolor = "#0000ff";
var insite="";
var newurl="";



function RestyleElementId(elementId,insite) {
    styleHandle = GetStyle(elementId);
	if (insite=="mini") {
	    setcolor = "#85c7ff";
		newurl = "url(images/base.gif)";
    }
	
	if (insite=="miniinset") {
	    setcolor = "#85c7ff";
		newurl = "url(images/navigationbaseinset.jpg)";
    }
		
	
        /*styleHandle.color = setcolor;
        styleHandle.backgroundColor = setcolor; */
		styleHandle.backgroundImage = newurl;
   
}

function RestyleElementIdOver(elementId,insite) {
    styleHandle = GetStyle(elementId);
	
	if (insite=="mini") {
	    overcolor = "#ddebff";
		newurl = "url(images/hover.jpg)";
	}
	
	if (insite=="miniinset") {
	    overcolor = "#ddebff";
		newurl = "url(images/navigationinsetover.jpg)";
	}	

	
        /*styleHandle.color = overcolor; */
        /*styleHandle.backgroundColor = overcolor; */
		styleHandle.backgroundImage = newurl;

}

var popUpWin=null;
var title = "afriend";

function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
   if(!popUpWin.closed) { 
     popUpWin.close();
	 popUpWin = null;
	 }
  }
  var realurl = "http://www.teach-ict.com/";
  
  realurl += URLStr;
  
  
popUpWin = open(realurl, title, "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=yes,width=450,height=450,left='+left+', top='+top+',screenX='+left+',screenY='+top+'");

mystat();

}


function popUpSpec(URLStr, left, top, width, height)
{
	var windef = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=yes,width="
	windef += width
	windef += ",height="
	windef += height
	windef += ",left="
	windef += left
	windef += ", top="
	windef += top
	windef += ",screenX="
	windef += left
	windef += ",screenY="
	windef += top
	windef += " "
	
	
	
  if(popUpWin)
  {
   if(!popUpWin.closed) { 
     popUpWin.close();
	 popUpWin = null;
	 }
  }

title = "HINT"
  
  
popUpWin = open(URLStr, title, windef);


mystat();

}





function mystat() {

  if(popUpWin)
  {
      popUpWin.status = window.location;
  }
}



function emailCheck (emailStr) {
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
alert("The TO Email address seems incorrect (check @ and .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];
for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("TO Email: The username contains invalid characters.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("TO Email: The domain name contains invalid characters.");
return false;
   }
}
if (user.match(userPat)==null) {
alert("TO Email: The first part of the email address (username) doesn't seem to be valid.");
return false;
}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("TO Email: Destination IP address is invalid!");
return false;
   }
}
return true;
}
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("TO Email: The domain name does not seem to be valid.");
return false;
   }
}
if (checkTLD && domArr[domArr.length-1].length!=2 &&
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("TO Email: The address must end in a well-known domain or two letter " + "country.");
return false;
}
if (len<2) {
alert("TO Email: This address is missing a hostname!");
return false;
}
return true;
}
function emailCheckfrom (emailStr) {
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
alert("The FROM Email address seem incorrect (check @ and .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];
for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("The first part of the FROM email address (username) contains invalid characters.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("FROM Email: The domain name contains invalid characters.");
return false;
   }
}
if (user.match(userPat)==null) {
alert("The first part of the FROM email address (username) doesn't seem to be valid.");
return false;
}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("FROM Email: Destination IP address is invalid!");
return false;
   }
}
return true;
}
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("FROM Email: The domain name does not seem to be valid.");
return false;
   }
}
if (checkTLD && domArr[domArr.length-1].length!=2 &&
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("FROM Email: The address must end in a well-known domain or two letter " + "country.");
return false;
}
if (len<2) {
alert("FROM Email: This address is missing a hostname!");
return false;
}
return true;
}
var preload="";
function checkform() {
  if (document.MYURL.emailsString.value == "") {
    alert("You need to enter an email address");
    return false;
  }
  if (document.MYURL.fromName.value == "") {
    alert("You need to include your name");
    return false;
  }
  if (document.MYURL.fromEmail.value == "") {
    alert("You need to include your email address");
    return false;
  }
  check = document.MYURL.emailsString.value;
  check = emailCheck(check);
  
  if(!check) {
    return false;
  }
  check = document.MYURL.fromEmail.value;
  check = emailCheckfrom(check);
   if(!check) {
    return false;
  }
  return true;
 }
function checktheemail() {
  if (document.MYURL.FromName.value == "") {
    alert("You need to include your email address");
    return false;
  }
  check = document.MYURL.FromName.value;
  check = emailCheckfrom(check);
   if(!check) {
    return false;
  }
  return true;
}

/*javascript for Bubble Tooltips by Alessandro Fulciniti
- http://pro.html.it - http://web-graphics.com */

function enableTooltips(id){
var links,i,h;
if(!document.getElementById || !document.getElementsByTagName) return;
AddCss();
h=document.createElement("span");
h.id="btc";
h.setAttribute("id","btc");
h.style.position="absolute";
document.getElementsByTagName("body")[0].appendChild(h);
if(id==null) links=document.getElementsByTagName("a");
else links=document.getElementById(id).getElementsByTagName("a");
for(i=0;i<links.length;i++){
    Prepare(links[i]);
    }
}

function Prepare(el){
var tooltip,t,b,s,l;
t=el.getAttribute("title");
if(t==null || t.length==0) t="link:";
el.removeAttribute("title");
tooltip=CreateEl("span","tooltip");
s=CreateEl("span","top");
s.appendChild(document.createTextNode(t));
tooltip.appendChild(s);
b=CreateEl("b","bottom");
l=el.getAttribute("href");
if(l.length>30) l=l.substr(0,27)+"...";
l = "";
b.appendChild(document.createTextNode(l));
tooltip.appendChild(b);
setOpacity(tooltip);
el.tooltip=tooltip;
el.onmouseover=showTooltip;
el.onmouseout=hideTooltip;
el.onmousemove=Locate;
}

function showTooltip(e){
document.getElementById("btc").appendChild(this.tooltip);
Locate(e);
}

function hideTooltip(e){
var d=document.getElementById("btc");
if(d.childNodes.length>0) d.removeChild(d.firstChild);
}

function setOpacity(el){
el.style.filter="alpha(opacity:95)";
el.style.KHTMLOpacity="0.95";
el.style.MozOpacity="0.95";
el.style.opacity="0.95";
}

function CreateEl(t,c){
var x=document.createElement(t);
x.className=c;
x.style.display="block";
return(x);
}

function AddCss(){
var l=CreateEl("link");
l.setAttribute("type","text/css");
l.setAttribute("rel","stylesheet");
l.setAttribute("href","bt.css");
l.setAttribute("media","screen");
document.getElementsByTagName("head")[0].appendChild(l);
}

function Locate(e){
var posx=0,posy=0;
if(e==null) e=window.event;
if(e.pageX || e.pageY){
    posx=e.pageX; posy=e.pageY;
    }
else if(e.clientX || e.clientY){
    if(document.documentElement.scrollTop){
        posx=e.clientX+document.documentElement.scrollLeft;
        posy=e.clientY+document.documentElement.scrollTop;
        }
    else{
        posx=e.clientX+document.body.scrollLeft;
        posy=e.clientY+document.body.scrollTop;
        }
    }
document.getElementById("btc").style.top=(posy+10)+"px";
document.getElementById("btc").style.left=(posx-20)+"px";
}