
//update.asp
function Update(sActionName)
{
   //var oNewWindow;	
   var Validated;
   //window.status = sActionName;
   bSendAction = false;
   
   //alert(sActionName);
   gbChanged = true;

   if ((sActionName == "btnCancel") || (sActionName == "mnuWizardCancel") || (sActionName == "btnClose") || (sActionName == "mnuClose") || (sActionName == "mnuCancel") || (sActionName == "btnCancelPass") || (sActionName == "btnCancelVal"))
   {
      bSendAction = true;
      gbChanged = false;
   }
   else
   {
     Validated = Validate(sActionName);
	 
	 //This is a fix for handling the order of events on the building page. 
	 //We must open a new window and then close it just to get the events to work correctly when searching for a building zip code
	/*
	 if (typeof(mbSearchingZip) != "undefined" ){
		oNewWindow = window.open("",null,"height=1,left=0,location=no,menubar=no,scrollbars=no,top=5000,width=1,titlebar=no,statusbar=no,toolbar=no");	
		oNewWindow.close();
		if (mbSearchingZip == true){
			if (sActionName == msCurrentBuilding)
				Validated == true;
			else
			Validated == false;
		}				
	}
	*/
     if (Validated == true)
     {
        bSendAction = Validated;
     }
     else
     {
        bSendAction = Validated;
     }
   }
   
   if (bSendAction == true) 
   {     
    //If the Close Valuation 'scren' is displayed do not allow 
	//this action to happen.
      if (window.document.getElementById('tblCloseValuationCheck') != null)
         {
            if ((tblCloseValuationCheck.style.display == 'none') && (tblCalculator.style.display == 'none') && (tblComments.style.display == 'none'))
               {
                  SendAction(sActionName,gsPageName,gbChanged);
               }
         }
      else 
         {
            SendAction(sActionName,gsPageName,gbChanged);
         }
   }
   
   return bSendAction;
}

