// JavaScript Document

function over1(obj){
//img.src = "images/blink.gif";
document.getElementById(obj).innerHTML = "<img width=\"28\" height=\"23\" src=\"images/blink.gif\"/>";
}
function out1(obj){
//img.src = "images/prawitra_25.gif";
document.getElementById(obj).innerHTML = "<img width=\"28\" height=\"23\" src=\"images/prawitra_25.gif\"/>";
}
function down1(obj){
//img.src = "images/blink.gif";
document.getElementById(obj).innerHTML = "<img width=\"28\" height=\"23\" src=\"images/blink.gif\"/>";
}

function linkchg(highlight){
source=event.srcElement
source.style.backgroundColor=highlight
}

function linkchgback(base){
source.style.backgroundColor=base
}

function readenter(e,readfunc)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if (keycode == 13)
	{
		eval(readfunc);
	}
}
function validateMail(email) {
     if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        return false;
    } else if (email.indexOf("@") == (email.length-1)) {  // @ must not be the last character
        return false;
    } else if (email.indexOf("..") >=0) { // two periods in a row is not valid
		return false;
    } else if (email.lastIndexOf(".") == (email.length-1)) {  // . must not be the last character
		
		return false;
    }
    return true;
}

function allValidChars(field) {
  var parsed = true;
  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
  for (var i=0; i < field.length; i++) {
    var letter = field.charAt(i).toLowerCase();
    if (validchars.indexOf(letter) != -1)
      continue;
    parsed = false;
    break;
  }
  return parsed;
}

function openNewWindow(URL,winName,attributes) { 
  window.open(URL,winName,attributes);
}