<!--

function saveOrgData(file) 
{
	// create new date array 
	var dataArray = new Array( );
	// store username and old password in cookie
    dataArray[0] = document.forms[0].id.value;
	dataArray[1] = document.forms[0].oldpassword.value;
	// assign dataArray the string converted dataArray
	var dataArray = array2String(dataArray);
	// Set cookie expiration date to 10 minutes
    var expDate = getExpDate(0, 0, 10);
	// Set cookie
    setCookie("hg039424", dataArray, expDate); 
	// Go to next page passed from the parameter file.
	location.href=file;
}

function readData( ) 
{
	// Read data from cookie
    var dataArray = getCookie("hg039424");
	// Delete cookie for security reasons
	deleteCookie("hg039424");
	// store and convert the string dataArray to an array
	dataArray = string2Array(dataArray);
	// Create place holder variables for hidden userName and Password field on new page's form
	document.forms[0].elements['id'].value = dataArray[0].toLocaleString();
	document.forms[0].elements['oldpassword'].value = dataArray[1].toLocaleString();
}

// validates that the field value string has one or more characters in it
function isNotEmpty(elem) 
{
    var str = elem.value;
    if(str == null || str.length == 0) {
        alert("Please fill in all required fields");
        return false;
    } else {
        return true;
    }
}

// validates that the entry is 8 characters long when
// input field's maxlength attribute is set to 16
function isLen8(elem) 
{
    var str = elem.value;
    var re = /\b.{8}\b/;
    if (!str.match(re)) 
	{
        alert("User Name required 8 Characters. Please try again");
        return false;
    } else {
        return true;
    }
}

// validates that the entry is formatted as an email address
function isEMailAddr(elem) {
    var str = elem.value;
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!str.match(re)) {
        alert("Verify the email address format.");
        return false;
    } else {
        return true;
    }
}

function array2String(array) {
    var output = "";
    if (array) {
        output += "[";
        for (var i in array) {
            val = array[i];
            switch (typeof val) {
                case ("object"):
                    if (val[0]) {
                        output += array2String(val) + ",";
                    } else {
                        output += object2String(val) + ",";
                    }
                    break;
                case ("string"):
                    output += "'" + escape(val) + "',";
                    break;
                default:
                    output += val + ",";
            }
        }
        output = output.substring(0, output.length-1) + "]";
    }
    return output;
}

function string2Array(string) 
{
    eval("var result = " + string);
    return result;
}

// Utility function to retrieve an expiration date in proper
// format; pass three integer parameters for the number of days, hours,
// and minutes from now you want the cookie to expire (or negative
// values for a past date); all three parameters are required,
// so use zeros where appropriate
function getExpDate(days, hours, minutes) 
{
    var expDate = new Date( );
    if (typeof days == "number" && typeof hours == "number" && 
        typeof hours == "number") {
        expDate.setDate(expDate.getDate( ) + parseInt(days));
        expDate.setHours(expDate.getHours( ) + parseInt(hours));
        expDate.setMinutes(expDate.getMinutes( ) + parseInt(minutes));
        return expDate.toGMTString( );
    }
}
   
// Utility function called by getCookie( )
function getCookieVal(offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1) {
        endstr = document.cookie.length;
    }
    return unescape(document.cookie.substring(offset, endstr));
}
   
// Primary function to retrieve cookie by name
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 "";
}
   
// Store cookie value with optional details as needed
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie = name + "=" + escape (value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}
   
// Remove the cookie by setting ancient expiration date
function deleteCookie(name,path,domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

function validate(form) 
{
    var pwd1 = form.newpassword1.value;
    var pwd2 = form.newpassword2.value;

    if (!isNotEmpty(form.newpassword1)) {return false;}
    if (!isNotEmpty(form.newpassword2)) {return false;}

	if (pwd1 == pwd2) {
       return true;
    } else {
       alert("New and confirmaiton passwords do not match. Please try again.");
       return false;
    }
}

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.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);
  if(!x && document.getElementById) x=document.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);
}
//-->