function blinkExecute(target,color){
  document.getElementById(target).style.backgroundColor = color;
}

function blinkBlink (target){
  color1 = "#feff6f"; // blinking color
  color2 = "#ffffff"; // background color

  setTimeout('blinkExecute("'+target+'","'+color1+'")',0);
  setTimeout('blinkExecute("'+target+'","'+color2+'")',500);
  setTimeout('blinkExecute("'+target+'","'+color1+'")',1000);
  setTimeout('blinkExecute("'+target+'","'+color2+'")',1500);
  setTimeout('blinkExecute("'+target+'","'+color1+'")',2000);
  setTimeout('blinkExecute("'+target+'","'+color2+'")',2500);
  setTimeout('blinkExecute("'+target+'","'+color1+'")',3000);
  setTimeout('blinkExecute("'+target+'","'+color2+'")',3500);
  setTimeout('blinkExecute("'+target+'","'+color1+'")',4000);
  setTimeout('blinkExecute("'+target+'","'+color2+'")',4500);
  document.getElementById(target).focus();
}

function reportCard(id)
  {
  var thisWin = window.open("report.card.php?id="+id, "Report Card","width=400,height=200,status=no,scrollbars=no,resizable=no,top=200,left=200");
  thisWin.opener = self;
  thisWin.focus();
  var this_doc = thisWin.document;
  this_doc.close();
  }
   


function verify()
  {
  msg = "Are you sure you want to delte this record?";
  return confirm(msg);
  }

function send()
   {document.form1.submit()}
   

  
	var arrayOfRolloverClasses = new Array();
	var arrayOfClickClasses = new Array();
	var activeRow = false;
	var activeRowClickArray = new Array();
	
function highlightTableRow()
	{
		var tableObj = this.parentNode;
		if(tableObj.tagName!='TABLE')tableObj = tableObj.parentNode;

		if(this!=activeRow){
			this.setAttribute('origCl',this.className);
			this.origCl = this.className;
		}
		this.className = arrayOfRolloverClasses[tableObj.id];
		
		activeRow = this;
		
	}
	
function clickOnTableRow()
	{
		var tableObj = this.parentNode;
		if(tableObj.tagName!='TABLE')tableObj = tableObj.parentNode;		
		
		if(activeRowClickArray[tableObj.id] && this!=activeRowClickArray[tableObj.id]){
			activeRowClickArray[tableObj.id].className='';
		}
		this.className = arrayOfClickClasses[tableObj.id];
		
		activeRowClickArray[tableObj.id] = this;
				
	}
	
function resetRowStyle()
	{
		var tableObj = this.parentNode;
		if(tableObj.tagName!='TABLE')tableObj = tableObj.parentNode;

		if(activeRowClickArray[tableObj.id] && this==activeRowClickArray[tableObj.id]){
			this.className = arrayOfClickClasses[tableObj.id];
			return;	
		}
		
		var origCl = this.getAttribute('origCl');
		if(!origCl)origCl = this.origCl;
		this.className=origCl;
		
	}
		
function addTableRolloverEffect(tableId,whichClass,whichClassOnClick)
	{
		arrayOfRolloverClasses[tableId] = whichClass;
		arrayOfClickClasses[tableId] = whichClassOnClick;
		
		var tableObj = document.getElementById(tableId);
		var tBody = tableObj.getElementsByTagName('TBODY');
		if(tBody){
			var rows = tBody[0].getElementsByTagName('TR');
		}else{
			var rows = tableObj.getElementsByTagName('TR');
		}
		for(var no=0;no<rows.length;no++){
			rows[no].onmouseover = highlightTableRow;
			rows[no].onmouseout = resetRowStyle;
			
			if(whichClassOnClick){
				rows[no].onclick = clickOnTableRow;	
			}
		}
		
	}

    
  function eCheckEMail(sn)
    {
    s= sn.value;
    if (s.indexOf("@") == -1) return false;
    if (s.indexOf(".") == -1) return false;
    at=false;
    dot=false;
    for (var i = 0; i < s.length; i++)
      {
      ch = s.substring(i, i + 1)
      if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z")
              || (ch == "@") || (ch == ".") || (ch == "_")
              || (ch == "-") || (ch >= "0" && ch <= "9"))
                {
                if (ch == "@")
                  {
                  if (at) return false;
                  else at=true;
                  }
                if ((ch==".") && at)
                   dot=true;
                }
      else return false;
      }
   return dot;
   }

  function CheckEMail(theForm)
    {
    for(var i=1; i<CheckEMail.arguments.length; i++)
      if (!eCheckEMail(theForm.elements[CheckEMail.arguments[i]]))
        {
        alert("Field entry is not valid");
        theForm.elements[CheckEMail.arguments[i]].focus();
        return false;
        }
    return true;
    }


  function CheckRequiredFields(theForm)
    {
    for(i=1; i<CheckRequiredFields.arguments.length; i++)
      if(theForm.elements[CheckRequiredFields.arguments[i]].value=="")
        {
        alert("This field is required");
        theForm.elements[CheckRequiredFields.arguments[i]].focus();
        return false;
        }
    return true;
    }

  function CheckPW(theForm)
    {
    if(theForm.elements[CheckPW.arguments[1]].value != theForm.elements[CheckPW.arguments[2]].value)
      {
      alert("Password fields do not match");
      theForm.elements[CheckPW.arguments[1]].focus();
      return false;
      }
    return true;
    }

  function CheckForm(theForm)
    {
    if(CheckRequiredFields(theForm, '<?php echo $validateFields; ?>'))
      <?php
      if($validateEmail)
        {
        ?>
        if(CheckEMail(theForm, <?php echo $validateEmail; ?>))
        <?php
        }
          if($validatePW)
            {
            ?>
            if(CheckPW(theForm, <?php echo $validatePW; ?>))
            <?php
            }
      ?>
      return true;
    return false;
    }
   
