function newso()
{
if (document.forminfo.first.value == "")
		  {
		  alert ("First Name field is Required!");
		  document.forminfo.first.focus();
		  return false;
	      } 
	if (document.forminfo.last.value == "")
		  {
		  alert ("Last Name field is Required!");
		  document.forminfo.last.focus();
		  return false;
	      } 
	if (document.forminfo.id.value == "")
		  {
		  alert ("Login ID field is Required!");
		  document.forminfo.id.focus();
		  return false;
	      } 
		  
	if (document.forminfo.email.value == "")
		{
		alert ("eMail is Required!");
		document.forminfo.email.focus();
		return false;
		}	  
    	
	if (document.forminfo.pw_question.value == "")
		{
		alert ("secret Question field can not be empty!");
		document.forminfo.pw_question.focus();
		return false;
		}		
	if (document.forminfo.pw_answer.value == "")
		{
		alert ("secret Answer field can not be empty!");
		document.forminfo.pw_answer.focus();
		return false;
		}	
	if (document.forminfo.city.value == "")
		  {
		  alert ("City field is Required!");
		  document.forminfo.city.focus();
		  return false;
	      } 
	if (document.forminfo.street1.value == "")
		  {
		  alert ("Address field is Required!");
		  document.forminfo.street1.focus();
		  return false;
	      } 	  		
	if (document.forminfo.country.options[document.forminfo.country.selectedIndex].value == "")
		{
		alert ("Country is required ...");
		document.forminfo.country.focus();
		return false;
		}	
	
	var plaintext1 = document.forminfo.pw1.value;
	
	if (plaintext1.length == 0){
	alert ("No Password has been Entered!");
	document.forminfo.pw1.focus();
	return false;
	}	 
	
	if (plaintext1.length < 6)
		{
		alert ("Password should be at least 6 characters..");
		document.forminfo.pw1.focus();
		return false;
		}	
	 
	if (document.forminfo.pw1.value != document.forminfo.pw2.value)
	{
	alert ("retyped Password is not the same as Password!");
	document.forminfo.pw1.focus();
	return false;
	}	
	document.forms["forminfo"].pw.value = plaintext1;
	document.forms["forminfo"].pw1.value = '';
	document.forms["forminfo"].pw2.value = '';
	return true;
}	
function newss()
{
	if (document.forminfo.first.value == "")
		  {
		  alert ("First Name field is Required!");
		  document.forminfo.first.focus();
		  return false;
	      } 
	if (document.forminfo.last.value == "")
		  {
		  alert ("Last Name field is Required!");
		  document.forminfo.last.focus();
		  return false;
	      } 
	if (document.forminfo.id.value == "")
		  {
		  alert ("Login ID field is Required!");
		  document.forminfo.id.focus();
		  return false;
	      } 
		  
	if (document.forminfo.email.value == "")
		{
		alert ("eMail is Required!");
		document.forminfo.email.focus();
		return false;
		}	  
    	
	if (document.forminfo.pw_question.value == "")
		{
		alert ("secret Question field can not be empty!");
		document.forminfo.pw_question.focus();
		return false;
		}		
	if (document.forminfo.pw_answer.value == "")
		{
		alert ("secret Answer field can not be empty!");
		document.forminfo.pw_answer.focus();
		return false;
		}	
		
	var plaintext1 = document.forminfo.pw1.value;
	
	if (plaintext1.length == 0){
	alert ("No Password has been Entered!");
	document.forminfo.pw1.focus();
	return false;
	}	 
	
	if (plaintext1.length < 6)
		{
		alert ("Password should be at least 6 characters..");
		document.forminfo.pw1.focus();
		return false;
		}	
	 
	if (document.forminfo.pw1.value != document.forminfo.pw2.value)
	{
	alert ("retyped Password is not the same as Password!");
	document.forminfo.pw1.focus();
	return false;
	}	
	//document.forms["forminfo"].pw.value = TEAencrypt(plaintext1);
	document.forms["forminfo"].pw.value = plaintext1;
	document.forms["forminfo"].pw1.value = '';
	document.forms["forminfo"].pw2.value = '';
	return true;
}	
function loginso()
{
	if (document.incPass.pw1.value == "")
	  {
	  alert ("Password is a required field and can not be Blank...!");
	  document.incPass.pw1.focus();
	  return false;
      } 
	//document.forms["incPass"].pw.value = TEAencrypt(document.incPass.pw1.value);
	document.forms["incPass"].pw.value = document.incPass.pw1.value;
	document.forms["forminfo"].pw1.value = '';
	return true;
}	
function loginlv()
{
	if (document.lv_login.user_name.value == "")
		  {
		  alert ("User Name Field is Required!");
		  document.lv_login.user_name.focus();
		  return false;
	      }
	if (document.lv_login.pw1.value == "")
	  {
	  alert ("Password is a required field and can not be Blank...!");
	  document.lv_login.pw1.focus();
	  return false;
      } 
	//document.forms["lv_login"].pw.value = TEAencrypt(document.lv_login.pw1.value);
	document.forms["lv_login"].pw.value = document.lv_login.pw1.value;
	document.forms["lv_login"].pw1.value = '';
	
	return true;
}	
function resetso()
{
	var plaintext1 = document.forms["incPass"].pw1.value;
	if (plaintext1.length == 0){
	alert ("No Password has been Entered!");
	document.incPass.pw1.focus();
	return false;
	}	 
	if (plaintext1.length < 6)
		{
		alert ("Password should be at least 6 characters..");
		document.incPass.pw1.focus();
		return false;
		}	
	if (document.incPass.pw1.value != document.incPass.pw2.value)
	{
	alert ("retyped Password is not the same as Password!");
	document.incPass.pw1.focus();
	return false;
	}	
	//document.forms["incPass"].pw.value = TEAencrypt(plaintext1);
	document.forms["incPass"].pw.value = plaintext1;
	document.forms["incPass"].pw2.value = '';
	return true;
}	
function TEAencrypt(plaintext)
{
	var password = 'ghodsi';
    var asciitext = escape(plaintext).replace(/%20/g,' ');
    var v = strToLongs(asciitext);  
    if (v.length <= 1) v[1] = 0;  
    var k = strToLongs(password.slice(0,16)); 
    var n = v.length;

    var z = v[n-1], y = v[0], delta = 0x9E3779B9;
    var mx, e, q = Math.floor(6 + 52/n), sum = 0;

    while (q-- > 0) {  // 6 + 52/n operations gives between 6 & 32 mixes on each word
        sum += delta;
        e = sum>>>2 & 3;
        for (var p = 0; p < n; p++) {
            y = v[(p+1)%n];
            mx = (z>>>5 ^ y<<2) + (y>>>3 ^ z<<4) ^ (sum^y) + (k[p&3 ^ e] ^ z);
            z = v[p] += mx;
        }
    }

    var ciphertext = longsToStr(v);
	if (ciphertext.search("#")) {
		ciphertext = ciphertext.replace("#","");
		}
    return escCtrlCh(ciphertext);
}

function strToLongs(s) {  
    var l = new Array(Math.ceil(s.length/4));
    for (var i=0; i<l.length; i++) {
        l[i] = s.charCodeAt(i*4) + (s.charCodeAt(i*4+1)<<8) + 
               (s.charCodeAt(i*4+2)<<16) + (s.charCodeAt(i*4+3)<<24);
    }
    return l;  
}              

function longsToStr(l) {  // convert array of longs back to string
    var a = new Array(l.length);
    for (var i=0; i<l.length; i++) {
        a[i] = String.fromCharCode(l[i] & 0xFF, l[i]>>>8 & 0xFF, 
                                   l[i]>>>16 & 0xFF, l[i]>>>24 & 0xFF);
    }
    return a.join('');  
}

function escCtrlCh(str) {  
    return str.replace(/[\0\t\n\v\f\r\xa0'"!]/g, function(c) { return '!' + c.charCodeAt(0) + '!'; });
}

function unescCtrlCh(str) {  
    return str.replace(/!\d\d?\d?!/g, function(c) { return String.fromCharCode(c.slice(1,-1)); });
}
