function ValidatorUpdateIsValid() {
    var i;

	// These 3 loops figure out if the field has an Invalid validator attached to it...
	
	// First reset all of the fields...
    for (i = 0; i < Page_Validators.length; i++)
    {
		var val = Page_Validators[i];
		var o = document.all[ val.controltovalidate ];
		if ( o != null )
		{
			if ( o.length > 0 && o.className == null )
			{
				for ( var j = 0; j < o.length; j++ )
				{
					o[j].NewClassName = "";
					if ( o[j].className == "Text" || o[j].className == "TextFailed" )
						o[j].NewClassName = "Text";
				}
			}
			else
			{
				o.NewClassName = "";
				if ( o.className == "Text" || o.className == "TextFailed" )
					o.NewClassName = "Text";
			}
		}
	}

	// If this validator is InValid, then update the field it is validating...
    for (i = 0; i < Page_Validators.length; i++)
    {
		var val = Page_Validators[i];
		var o = document.all[ val.controltovalidate ];
		if ( ! val.isvalid )
		{
			if ( o != null )
			{
				if ( o.length > 0 && o.className == null )
				{
					for ( var j = 0; j < o.length; j++ )
					{
						o[j].NewClassName = "Failed";
						if ( o[j].className == "Text" || o[j].className == "TextFailed" )
							o[j].NewClassName = "TextFailed";
					}
				}
				else
				{
					o.NewClassName = "Failed";
					if ( o.className == "Text" || o.className == "TextFailed" )
						o.NewClassName = "TextFailed";
				}
			}
		}
	}

	// Now update all of the fields with their new CSS classes...
    for (i = 0; i < Page_Validators.length; i++)
    {
		var val = Page_Validators[i];
		var o = document.all[ val.controltovalidate ];
		if ( o != null )
		{
			if ( o.length > 0 && o.className == null )
			{
				for ( var j = 0; j < o.length; j++ )
					o[j].className = o[j].NewClassName;
			}
			else
			{
				o.className = o.NewClassName;
				if ( o.relatedControl && document.all( o.relatedControl ) )
					document.all( o.relatedControl ).className = o.className;
			}
		}
	}



	// Microsoft Code from here down...
    for (i = 0; i < Page_Validators.length; i++) {
        if (!Page_Validators[i].isvalid) {
            Page_IsValid = false;
            return;
        }
   }
   Page_IsValid = true;
}





var sInitialPageState;
function window.onload()
{
	// Save off the current state of the form when the page loads
	// This is compared with the state of the form if the user clicks "Cancel".
	sInitialPageState = getFormState();
}

// Returns a string that holds the current state of all form fields...
// This is used to see if the user has changed anything when they click the "Cancel" button.
function getFormState()
{
	var s = "";
	for ( var i = 0; i < document.body.all.length; i++ )
	{
		var o = document.body.all[ i ];
		if ( o.tagName == "INPUT" && o.type == "text" )
			s += "|" + o.value;
		else if ( o.tagName == "INPUT" && o.type == "radio" && o.checked )
			s += "|" + o.value;
		else if ( o.tagName == "SELECT" )
		{
			if ( o.multiple == false )
				s += "|" + o.selectedIndex;
			else if ( o.name.indexOf( ":lstSelected" ) != -1 )
			{
				s += "|";
				for ( var j = 0; j < o.options.length; j++ )
					s += "{" + o.options[ j ].value;
			}
		}
		else if ( o.tagName == "TEXTAREA" )
			s += "|" + o.value;
	}
	return s;
}



function PhysicianToolbarEdit()
{
	__doPostBack( gsToolbarID, "edit" );
}
function PhysicianToolbarSave()
{
	Page_ValidationActive = false;
	Form1.onsubmit();
	Page_ValidationActive = true;

	if (typeof(Page_ClientValidate) == 'function')
		Page_ClientValidate();
	
	if ( Page_IsValid )
		__doPostBack( gsToolbarID, "save" );
}


function photoValidation( source, args )
{
	if ( document.body.all.radioUpload.checked )
		args.IsValid = ( document.body.all.filePhoto.value != "" );
	else
		args.IsValid = true;
}
