function TestBrowser()
{
	var MNav=navigator.userAgent.toLowerCase();
	this.Mozilla = false;
	this.IE = false;
	this.NS6=false;
	this.OP=false;
	this.NS=true;
	this.Name='Unknown. May be Netscape Navigator.';

	if (MNav.indexOf('opera')!=-1)
	{
		this.OP=true;
		this.Name='Opera';
		this.NS=false;
		MNav=null;
		return this;
	}

	if ((MNav.indexOf('gecko')!=-1) && (MNav.substr(MNav.indexOf('gecko')+6) >= 20020530))
	{
		Mozilla = true;
		this.Name='Mozilla';
		this.NS=false;
		MNav=null;
		return this;
	}

	MNav=null;

	if(document.getElementById&&!document.all)
	{
		this.NS6=true;
		this.Name='NS6UP';
		this.NS=false;
		return this;
	}
	if(document.all)
	{
		this.IE=true;
		this.Name='IE';
		this.NS=false;
		return this;
	}
	return this;
}

	
String.prototype.trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

function truncateForm( form ) {
    for( i = 0 ; i < form.length ; i++ ) {
        if( form.elements[i].type == 'text' || form.elements[i].type == 'textarea' )
            form.elements[i].value = form.elements[i].value.trim();
    };
}

function validateField( value , display_name, required, strRe, strFst, len )
{
    var re;
    re = new RegExp( strRe, "i");
    var fst;
    var val = value.trim();
    fst = new RegExp( strFst, "i");
    if ( val.length > 0 ) {
        for (var i = 0; i < val.length; i++) {
            var chr = val.charAt(i);
            if (!(((i > 0) && (chr.search(re)==0)) || ((i==0) && (chr.search(fst)==0)))) {
                alert("Please enter a valid "+ display_name);
                return false;
            }
        }
    }else if( required )
    {
        alert("Field "+ display_name +" must be filled.");		
	return false;
    }
    if (arguments.length == 6 && required && value.length<len) {
     	alert	('Field '+display_name+' minimum length - '+len+' chars!');
     	return false;
    }
    return true;
}

function isEmail( 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})(\\]?)$");
    str = str.replace(/ /,'');
    return (!r1.test(str) && r2.test(str));
}


function FormSubmit(To)
{
	if(document.forms[0] != null)
	{
		document.forms[0].action=To;
		if(document.forms[0].__VIEWSTATE != null)
		{
			document.forms[0].__VIEWSTATE.name+='_Was';
		}
		document.forms[0].submit();
	}
}
