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



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);
	
	    setcolor = "#85c7ff";
		newurl = "url(images/base.jpg)";
    
		
	
        /*styleHandle.color = setcolor;
        styleHandle.backgroundColor = setcolor; */
		styleHandle.backgroundImage = newurl;
   
}

function RestyleElementIdOver(elementId,insite) {
    styleHandle = GetStyle(elementId);
	
	
	    overcolor = "#ddebff";
		newurl = "url(images/hover.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 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;
}
