﻿    function ShowLoading() {
        oTable = document.getElementById('ctl00_ContentPlaceHolder1_dlProducts');
        oTable.deleteRow(oTable.getElementsByTagName("tr")[0]);
        oRow = oTable.insertRow(-1);
        var oCell = oRow.insertCell(0);
        oCell.innerHTML = "Asteptati... <img alt='Incarcare' src='./images/loadingSmall.gif' />";
    }

    function BookMarkPage(pageURL, pageTitle) {
        if (document.all) {
            window.external.AddFavorite(pageURL, pageTitle)
        }
        if (window.sidebar) {
            window.sidebar.addPanel(pageTitle, pageURL, "");
        }        
    }

    function ShowDetails(controlID, display) {
        if (display != undefined) {
            document.getElementById(controlID).style.display = display
        }
        else {
            if (document.getElementById(controlID).style.display == "none") {
                document.getElementById(controlID).style.display = "inline"
            }
            else {
                document.getElementById(controlID).style.display = "none"
            }
        }
    }

    function ShowEntityDetails(ctlSource) {
        var bChecked;
        
        if (ctlSource != undefined) {
            bChecked = ctlSource.checked
        }
        // Selects both checkboxes top & bottom
        var htmlCheckboxes = document.getElementsByTagName("input");
        for (i = 0; i < htmlCheckboxes.length; i++) {
            if (htmlCheckboxes[i].id.indexOf("chkDetails") > 0) {
                if (ctlSource == undefined) {
                    htmlCheckboxes[i].checked = !htmlCheckboxes[i].checked;
                    bChecked = htmlCheckboxes[i].checked;
                }
                else {
                    if (ctlSource.id != htmlCheckboxes[i].id) {
                        htmlCheckboxes[i].checked = ctlSource.checked;
                        break;
                    }
                }
            }
        }    
        
        // Display/Hide details
        var htmlTables = document.getElementsByTagName("table");
        for (i = 0; i < htmlTables.length; i++) {
            if (htmlTables[i].id.indexOf("table_") == 0) {
                ShowDetails(htmlTables[i].id, (bChecked ? "inline" : "none"))
            }
        }
    }

    function SelectCompanies(ctlSource) {
        // Selects both checkboxes top & bottom
        var htmlCheckboxes = document.getElementsByTagName("input");
        for (i = 0; i < htmlCheckboxes.length; i++) {
            if (htmlCheckboxes[i].id.indexOf("chkSelectAll") > 0) {
                if (ctlSource == undefined) {
                    htmlCheckboxes[i].checked = !htmlCheckboxes[i].checked;
                }
                else {
                    if (ctlSource.id != htmlCheckboxes[i].id) {
                        htmlCheckboxes[i].checked = ctlSource.checked;
                        break;
                    }
                }
            }
        } 
            
        var htmlInput = document.getElementsByTagName("input");
        for (i = 0; i < htmlInput.length; i++) {
            if (htmlInput[i].id.indexOf("chkSelect_") == 0) {
                htmlInput[i].checked = ctlSource.checked;
            }
        }
    }
    
    function ShowHideDIV(divID, imgID, path) {
        if (document.getElementById(divID).style.display == "none") {
            document.getElementById(divID).style.display = "inline"
            document.getElementById(imgID).src = path + "/images/btnClose.png"
        }
        else {
            document.getElementById(divID).style.display = "none"
            document.getElementById(imgID).src = path + "/images/btnOpen.png"
        }
    }

    function ShowDIV(divID, imgID, path) {
        if (document.getElementById(divID)) {
            document.getElementById(divID).style.display = "inline"
            document.getElementById(imgID).src = path + "/images/btnClose.png"
        }
    }

    function ContactForm() {
        var htmlInput = document.getElementsByTagName("input");
        var companyID = "";
        
        for (i = 0; i < htmlInput.length; i++) {
            if (htmlInput[i].id.indexOf("chkSelect_") == 0) {
                if (htmlInput[i].checked) {
                    companyID += "," + htmlInput[i].value
                }
            }
        }

        if (companyID.length != 0) {
            if (navigator.appVersion.indexOf("MSIE") > 0) {
                window.frames["iframeContact"].document.forms["MessageForm"].elements("selComp").value = companyID.substring(1);
                window.frames["iframeContact"].document.forms["MessageForm"].submit()
            }
            else {
                //alert(window.iframeContact.document.forms["MessageForm"])
                window.iframeContact.document.forms["MessageForm"].selComp.value = companyID.substring(1);
                window.iframeContact.document.forms["MessageForm"].submit()            
            }
        }
    }