﻿// JScript File

function IsValidEmail(addr)
{
        var db=false;
        var invalidChars = '\/\'\\ ";:?!%~`()[]\{\}^|+=*&$#,';
		for (i=0; i<invalidChars.length; i++)
		{
			if (addr.indexOf(invalidChars.charAt(i),0) > -1)
			{
				if (db) alert('email address contains invalid characters');
				return false;
			}
		}
		for (i=0; i<addr.length; i++)
		{
			if (addr.charCodeAt(i)>127)
			{
				if (db) alert("email address contains non ascii characters.");
				return false;
			}
		}

		var atPos = addr.indexOf('@',0);
		if (atPos == -1)
		{
			if (db) alert('email address must contain an @');
			return false;
		}
		if (atPos == 0)
		{
			if (db) alert('email address must not start with @');
			return false;
		}
		if (addr.indexOf('@', atPos + 1) > - 1)
		{
			if (db) alert('email address must contain only one @');
			return false;
		}
		if (addr.indexOf('.', atPos) == -1)
		{
			if (db) alert('email address must contain a period in the domain name');
			return false;
		}
		if (addr.indexOf('@.',0) != -1)
		{
			if (db) alert('period must not immediately follow @ in email address');
			return false;
		}
		if (addr.indexOf('.@',0) != -1)
		{
			if (db) alert('period must not immediately precede @ in email address');
			return false;
		}
		if (addr.indexOf('..',0) != -1) 
		{
			if (db) alert('two periods must not be adjacent in email address');
			return false;
		}
		var suffix = addr.substring(addr.lastIndexOf('.')+1).toLowerCase();
		if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum')
		 {
			if (db) alert('invalid primary domain in email address');
			return false;
		 }
    return true;
}
function IsValidAlphaNumeric(strValue)
{
    var charCode;
    strValue = new String(strValue);
    for(var i=0;i<strValue.length;i++)
    {
        charCode = strValue.charCodeAt(i);
        if( (((charCode >= 48) && (charCode <= 57)) || ((charCode >=65) && (charCode <= 90)) || ((charCode >= 97) && (charCode <= 122))) == false)
            return false;
    }
    return true;
}
function IsNotHtmlTags(strValue)
{
    var charCode;
    strValue = new String(strValue);
    for(var i=0;i<strValue.length;i++)
    {
        charCode = strValue.charCodeAt(i);
        if((charCode == 60) || (charCode == 62))
            return false;
    }
    return true;
}
function IsValidAlphaNumericWithSpace(strValue)
{
    var charCode;
    strValue = new String(strValue);
    for(var i=0;i<strValue.length;i++)
    {
        charCode = strValue.charCodeAt(i);
        if((( (((charCode >= 48) && (charCode <= 57)) || ((charCode >=65) && (charCode <= 90)) || ((charCode >= 97) && (charCode <= 122)) || (charCode == 32)) == false)) || (charCode == 60) || (charCode == 62))
            return false;
    }
    return true;
}

function updateObjects()
{
  objects = document.getElementsByTagName("object");
 //  alert(objects.length);
    for (var x = 0; x < objects.length; x++) {
        objects[x].outerHTML = objects[x].outerHTML;
    }
    
}
