﻿var lockOnSubmit = false;
var lockOnUnload = false;
var submitTimeout = null;

function setSubmitLocking() {

    lockOnSubmit = true;
}

function clearSubmitLocking() {
    lockOnSubmit = false;
}

function submitit() {
    if (lockOnSubmit) {
        lockOnUnload = true;
        submitTimeout = window.setTimeout("lockOnSubmit=false;lockOnUnload=false;", 100);
        
    }
}

function CompleteSubmitProcessing() {
	var paneProcessing =document.getElementById("ProcessingPane");


 if (lockOnUnload && paneProcessing != null) {
 	paneProcessing.className = 'FreezePaneOn';
 	
 	   
    	if (document.documentElement.scrollHeight > document.documentElement.clientHeight) {
    		paneProcessing.style.height = document.documentElement.scrollHeight;
    	}
    	else {
    		paneProcessing.style.height = document.documentElement.clientHeight;
    	}


        window.clearTimeout(submitTimeout);
     
    }


}


function GridRow_Hover(e) {
    var x=1;
    e.childNodes[0].className = "DataLeft Hover";
    while (e.childNodes[x]) {
        e.childNodes[x].className = "Data Hover";
        x += 1;
    }

}
function GridRow_Unhover(e) {
    var x = 1;
    e.childNodes[0].className = "DataLeft";
    while (e.childNodes[x]) {
        e.childNodes[x].className = "Data";
        x += 1;
    }
}

    
var OriginalValidatorUpdateDisplay = null;

function NewValidatorUpdateDisplay(val) {
    OriginalValidatorUpdateDisplay(val);
    if (val.controltovalidate) {
        var control = document.getElementById(val.controltovalidate);
        if (control != null)
         {
            control.style.backgroundColor =CheckValidatorsForControl(control) ? '' : '#FFAAAA';
          }

    }
}

function CheckValidatorsForControl(control) 
{
	var result = true;
	var tooltip = '';
    for (var i = 0; i < control.Validators.length; i++)
     {
        if (!control.Validators[i].isvalid) 
        {
        	result = false;
        	tooltip += control.Validators[i].innerText + '';
                control.Validators[i].style.display='none';
        }
       }
       control.title = tooltip;
    return result;
}



function SetNewValidatorUpdateDisplay ()
{
    if (typeof (ValidatorUpdateDisplay) == 'function')
     {
        OriginalValidatorUpdateDisplay = ValidatorUpdateDisplay;
        ValidatorUpdateDisplay = NewValidatorUpdateDisplay;
      } 
}

