﻿    // clears all text (to empty) and combo fields (to -1)
    function ClearForm()
    {
        var formTable = document.getElementById("formTable");
        ChangeAllControlsValue(formTable, "input", "text","");
        ChangeAllControlsValue(formTable, "select", "","-1");
    }

    // Changes all child controls of the parent element with the requested tag and type to the requestd value.
    // Allows to change the value of all controls of a certain type (text boxes, combos etc.) without specifying their names
    function ChangeAllControlsValue(parentElement, controlsTag, controlsType, value)
    {
        var controls = parentElement.getElementsByTagName(controlsTag);
        for( i in controls)
        {
            if (controlsType == "" || controls[i].type == controlsType)
            {
                controls[i].value = value;
            }
        }

    }
    
    //Activates validation on page and then scrolls all the way down 
    // fixes scrolling problem on usual validation
    function ValidateAndScroll()
    {
        Page_ClientValidate();
        window.scrollTo(0,1000);
    }
    
    // clears all text and combo fields in ContactUs form
    function ClearContactForm()
    {
        var formTable = document.getElementById("formTable");
        ChangeAllControlsValue(formTable, "input", "text","");
        ChangeAllControlsValue(formTable, "textarea", "","");
        ChangeAllControlsValue(formTable, "select", "","מנוי התנסות");
    }
