//begin practice

function checkCount() {
//alert("hi");
var hours = 48;
var expDays = 2; // number of days the cookie should last
var page = "/twe/scorer400.htm";
var windowprops = "width=410,height=340,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no";
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
//var cnt = GetCookie('count');
//var ct = GetCookie('count');//unnecessary line
//if (count == null) {
if(!GetCookie('cnt')){
//alert("hi");
//cnt=1;
//SetCookie('count', count, exp);
//WM_setCookie('myCookie','count','count','77','/','',-1)
WM_setCookie('cnt','1','1',hours,'/','',-1);
window.open(page, "pop", windowprops);
}
else {
//alert("hii");
//count++;
//WM_setCookie('count','1','1',hours,'/','',-1);
//SetCookie('count', count, exp);
   }
}

// end practice





//begin about toefl, toefl
function changePage(newLoc)
 {
   nextPage = newLoc.options[newLoc.selectedIndex].value
		
   if (nextPage != "")
   {
      document.location.href = nextPage
   }
 }
// end about toefl, toefl



<!-- Begin index
function emailCheck (email) {

    reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;    //not valid
    reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
// valid

    if( !reg1.test( email) && reg2.test( email))
    return true
else{
 alert("That is not a current log-in name; You might want to contact technical support")   
document.login.user.focus();
    return false}
}
//  End -->
<!--
var expires = 90;
var today = new Date();
var expr = new Date(today.getTime() + (expires * 86400000));
var idnum = window.location.search.substring(1);
if (idnum) {
var startPos = idnum.indexOf("reseller=");
    if (startPos > -1) {
        //startPos = startPos + 9;endPos = idnum.length;
//var value =  idnum.substring(startPos,endPos);
//var name = 'reseller';
//document.cookie = name + "=" +value +
document.cookie = idnum +( ";expires=" + expr.toGMTString()) + ( ";path=/");
}}
// -->

//endindex
function WM_setCookie (name, NS_value, IE_value, hours, path, domain, evalValue) {


    daValue = (navigator.appName == 'Netscape')?NS_value:IE_value;

    //fix layer ref if not supported (thanks, Ken Sundermeyer!)

    if ((daValue.indexOf('document.layers[')==0 && document.layers==null)|| (daValue.indexOf('document.all[')==0 && document.all==null)) {

      daValue = 'document'+daValue.substring(daValue.substring(0,daValue.lastIndexOf('.')).lastIndexOf('.'),daValue.length);

    }


    if(evalValue == 1) daValue = eval(daValue + '.value');


  // set the cookie, adding any parameters that were specified

  // (convert hours to milliseconds (*3600000) and then to a GMTString)

    document.cookie = name + '=' + escape(daValue) + ((hours)?(';expires=' + ((new Date((new Date()).getTime() + parseInt(hours)*3600000)).toGMTString())):'') + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:'');

}


function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) endstr = document.cookie.length;
	return unescape (document.cookie.substring (offset, endstr));
}
function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i,j) == arg) return getCookieVal (j);
	i = document.cookie.indexOf ("",i) + 1;
	if (i == 0) break;
	}
	return null
}

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) { //v3.0
  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); return x;
}

function MM_nbGroup(event, grpName) { //v3.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    if ((nbArr = document[grpName]) != null)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = args[i+1];
      nbArr[nbArr.length] = img;
  } }
}

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];}
}

//TWE

function CountDown() {
//how much time they get

if(timetwe>0)
{
var minutes=Math.floor(timetwe/60)
var remainder=timetwe-minutes*60
document.math.timer.value=minutes + ":" + remainder;
timetwe=timetwe-1;
var gameTimer=setTimeout("CountDown()", 1000)}
else if (timetwe==0)
{document.math.timer.value="0";
timesup=1;
alert('Time\'s Up!');
document.math.submit();
}}

function startgame(){
timetwe=60*30;//make these global but only
timesup=0;//after start game is called
var started=0;
var eStr = document.math.Name.value;
var ePat=/^[^@]+@[^.]+\./
var matchArray=eStr.match(ePat)
if (matchArray==null) {
	alert("This is a GetTOEFL member feature - Please contact the site administrator")
	return false}
if (started!=0)
{alert('You\'ve Already Started!');}
else
{
started=1;
CountDown();
}
}
// the signup score page

function validEmail(email)
{
    reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;    //not valid
    reg2 = 
/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
// valid


    if( !reg1.test( email) && reg2.test( email))
    return true
    
    return false
}

function validate()

{var invalid = " ";
if((document.thisform.username.value.length > 4 ) && (document.thisform.username.value.indexOf(invalid)== -1)) {
if( validEmail( document.thisform.email.value)) {
if(document.thisform.username.value==document.thisform.username2.value){



	return true
			}						

else {
         								alert( "The two entered passwords are not equal"); 
										document.thisform.username2.focus();
										return false}}


            							else {
         								alert( "Please enter a current email address."); 
										document.thisform.email.focus();
										return false}}
else {alert("Your password must have a minimum of 5 characters and contain no spaces.");
document.thisform.username.focus();return false}
}
//-->

<!--
function go(what) {

var reEmail1 = /^.+\@yahoo\.com$/;
var reEmail2 = /^.+\@hotmail\.com$/;
  
       if (reEmail1.test(what.email.value)||reEmail2.test(what.email.value)) return true;

    for (var i=0;i<2;i++) {
        if (what.radiobutton[i].checked) {
var v = what.radiobutton[i].value;
var x = what[v].value;
if (!i){WM_setCookie('extended','document.thisform.elements[0]','document.thisform.elements[0]','','/','',1)} else {WM_setCookie('short','document.thisform.elements[1]','document.thisform.elements[1]','','/','',1)}

}}

var cook=GetCookie('reseller');

var w=(what.action=("https://secure.element5.com/shareit/checkout.html?productid="+x+"&languageid=1&backlink=http%3A%2F%2Fwww.gettoefl.com%2Fregistrationform%2Fthanks4.htm&currencies=USD&reseller="+cook));
what.method="post";
        
    
}

// end signup score page

//begin structure and listening once only -- preparation.htm

function readCookie(cookieName){
// page to go to if cookie exists
var go_to = "/score.htm";
    var start = document.cookie.indexOf(cookieName);
    if (start == -1){ 
WM_setCookie('EMAIL','document.survey.submit_by','document.survey.submit_by','1440','/','',1)

} else {
        alert("Due to bandwidth resritictions, \none practice test per student; \nPlease sign up or donate to \npractice for the TOEFL test and \nsupport Get TOEFL's mission"); 

//window.location = go_to;return false;
    }
}