function ToggleButton(button, validationGroup)
{
   // If client validators not active
   if (typeof(Page_Validators) == "undefined")
   {
        SetWaitMode(button);
   }

   if (typeof(Page_ClientValidate) == 'function') 
   {
	 // Force Page validation 
	 Page_ClientValidate(validationGroup);                 
	 
	 // If validation passed
	 if(Page_IsValid)
	 {  
		SetWaitMode(button)
	 }
   }
   else
   {
		SetWaitMode(button);
   }
}

function SetWaitMode(button)
{
    button.src = "/Images/Fep_action_Copy.png";
    document.forms[1].submit();
    window.setTimeout("DisableButton( '" + button.id  + "')", 1);           
}

function DisableButton(buttonID) 
{
    window.document.getElementById(buttonID).disabled = true;
}

function Count(text, long) {
	var maxlength = new Number(long); // Change number to your max length.
	if (text.value.length > maxlength) {
		text.value = text.value.substring(0, maxlength);
	}
}

function PrintContent(ctrlName) {
        //window.alert(ctrlName);
        var DocumentContainer = document.getElementById(ctrlName);
        var WindowObject = window.open('', 'AreaImpressao', "width=420,height=225,top=250,left=345,toolbars=no,scrollbars=no,status=no,resizable=no");
        //alert(ctrl);
        //alert(DocumentContainer);
        WindowObject.document.write(DocumentContainer.innerHTML);
        //alert(ctrl);
        WindowObject.document.close();
        WindowObject.focus();
        WindowObject.print();
        WindowObject.close();
}
