
//Author: Shashank.
//Function to clear value of all controls on a form
//Please extend this function as required for your control's type
function ClearAllControls(form) 
{
    //Get all elements on the form
    var e = form.elements;
    for (var i=0; i<e.length; i++)
    {
        //Clear each element based on its type
        switch (e[i].type)
        {
            
             //TextBox
             case "text" :
                e[i].value = "";
                break;
             //Multi-line Text Box
             case "textarea" :
                e[i].value = "";
                break;
             //Password
             case "password":
              e[i].value = "";
                break;
             //Check Box
             case "checkbox" :
                e[i].checked = false;
                break; 
             case "select-one":
                e[i].selectedIndex = 0;
                break;
        }
    }
}

function SetDefaultFocus(nameOfControl)
{
    var ctrl = document.getElementById(nameOfControl);
    if (ctrl != null) {
        //Shashank - Cannot set focus to a hidden control.
        if (ctrl.style.visibility == "visible") {
            ctrl.focus();
        }
    }
}


var showSubMenu = function(height, width, subMenuName) {

var ctrl = document.getElementById(subMenuName.toString());

    ctrl.style.height = height + "px";
    ctrl.style.width = width + "px";
}

function switch_product_img(divName, totalImgs) {
    for (var i = 1; i <= totalImgs; i++) {
        var showDivName = 'photo_' + i;
        var showObj = document.getElementById(showDivName);
        if (showObj != null) {
            if (showDivName == divName)
                showObj.style.display = 'block';
            else
                showObj.style.display = 'none';
        }
    }
}
