﻿// JScript File
this.showHide = function(objIDToShow, objIDToHide)
{
    setInputVisibility(objIDToShow, true);
    setInputVisibility(objIDToHide, false);   
}

this.setInputVisibility = function (objID, visibility)
{   
    var divNode =  document.getElementById(objID);
     
    if(!divNode)
        return false;
    
    divNode.style.display = visibility ? "" : "none"; // changed "block" to "" - ed
        return true;     
}

this.RemoveRedundantFields = function()
{
    var theForm = document.forms[0];
    if(theForm)
    {
        if(theForm.__LASTFOCUS)
            theForm.__LASTFOCUS.disabled = true;
        if(theForm.__EVENTTARGET)
            theForm.__EVENTTARGET.disabled = true;
        if(theForm.__EVENTARGUMENT)
            theForm.__EVENTARGUMENT.disabled = true;
    }
}
 
function ConfigureBlankFieldRemovalOnSubmitClick(objID)
{
   var theButton = document.getElementById(objID);
   if(theButton)
    {
        theButton.onclick = function()
        {
            var theForm = document.forms[0];
                
            if(theForm)
            {    
                var URL = location.href.split('?')[0] + "?";
      
                for(var counter = 0; counter < theForm.elements.length; counter++)
                {
                    var formField = theForm.elements[counter];
                    if(formField)
                    {
                        if(formField.name == "__VIEWSTATE") //move viewstate param to the end (cosmetic not functional)
                            continue;

                        if(formField.type == "radio" && !formField.checked)
                            continue;
                            
                        if(formField.disabled)
                            continue; 
                        
                        if(!formField.value) 
                            continue;

                        URL = URL + formField.name + "=" + formField.value + "&";
                    }
                }
                
                URL = URL + "__VIEWSTATE="; //you need this
            }
            location.href = URL; //redirect
            return false; //cancel the event or the form gets submitted anyway by the default mechanism and redirect is lost
        }
    }
}


