<!--
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =
	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
	win = window.open(mypage,myname,settings);
	win.focus();
}
function SwitchMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("cont").getElementsByTagName("DIV");
		if(el.style.display == "none"){
			for (var i=0; i<ar.length; i++){
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}
function ChangeClass(menu, newClass) { 
	 if (document.getElementById) { 
	 	document.getElementById(menu).className = newClass;
	 } 
}
document.onselectstart = new Function("return true");
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_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_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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function openNewWindow(url, name, xtra) {
	newWindow = window.open(url, name, xtra);
	newWindow.focus();
	//newWindow.daddy = self;
}
function confirmEmail(form){
	if(trim(form.user_ID.value).length==0){
		alert("User ID cannot be empty. Please enter a valid User ID");
		form.user_ID.focus();
		return false;
	}
	if(trim(form.email_Address.value).length==0){
		alert("Email Address cannot be empty. Please enter a valid Email Address");
		form.email_Address.focus();
		return false;
	}
	if(validEmail(form.email_Address.value)){
		alert("Please enter a valid Email Address");
		form.email_Address.focus();
		return false;
	}
	return true;
}

function trim(str){
  var i=0,p = str.length-1;
  while(str.charAt(i)==' ') i++;
  while(str.charAt(p)==' ') p--;
  if(i>p) return '';
  return str.substring(i,p+1);
}

function checkEmail(str, userid, num){
	if(str.value==null){
		alert("Please Enter Your Email Address First.");
		str.focus();
	}
	else if(str.value==""){
		alert("Please Enter Your Email Address First.");
		str.focus();
	}
	else if(validEmail(str.value)){
		alert("Please Enter Valid Email Address.");
		str.focus();
	}
	else{
		emailfirst = "";
		email = str.value;
		emailfirst = email.substring(0, email.indexOf("@"));
		userid.value=emailfirst+num;
	}
}

function validEmail(email){
	
	if(email.indexOf("@")<0){
		return true;
	}
	if(email.indexOf(".")<0){
		return true;
	}
}

function _checkPassword(pass, rePass) {
  tmpPass = trim(pass);
  tmpRePass = trim(rePass);

  if(tmpRePass!=tmpPass) {
    return false;
  }
  if(tmpPass.length<5) {
    return false;
  }
  return true;
}
function _checkEmptyValue(value){
  if(trim(value).length==0){	
    return true;
  }else{
    return false;
  }
}

function _checkValidEmail(str) {
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}


function _checkNonEmptyValue(value){
  if(trim(value).length==0){
    return false;
  }else{
    return true;
  }
}

var ERROR_IN_FORM = false;
var ERROR_STR="You the have following errors:\n---------------------------------------------------------\n";

function _checkIfValidDataEntered(form) {
  inputObj = form.firstName;
  if(!_checkNonEmptyValue(inputObj.value)){
    ERROR_IN_FORM=true;
    ERROR_STR += "\n* Field <"+inputObj.id+"> cannot be Empty.";    
  }
  
  inputObj = form.lastName;
  if(!_checkNonEmptyValue(inputObj.value)){
    ERROR_IN_FORM=true;
    ERROR_STR += "\n* Field <"+inputObj.id+"> cannot be Empty.";    
  }
  
  inputObj = form.email;
  if(!_checkValidEmail(inputObj.value)){
    ERROR_IN_FORM=true;
    ERROR_STR += "\n* Field <"+inputObj.id+"> is not valid.";
  }
  
  inputObj = form.userid;
  if(!_checkNonEmptyValue(inputObj.value)){
    ERROR_IN_FORM=true;
    ERROR_STR += "\n* Field <"+inputObj.id+"> cannot be Empty.";    
  }
  
  if(!_checkPassword(form.password.value, form.confirmpassword.value)) {
    ERROR_IN_FORM=true;
    ERROR_STR += "\n* Passwords do not match or the length of the passwords is less than 5 characters.";
  }
  
  if(ERROR_IN_FORM) {
    alert(ERROR_STR);
    ERROR_IN_FORM=false;
    ERROR_STR="You the have following errors:\n---------------------------------------------------------\n";
    return false;
  }
  return true;
}
//-->

