﻿function PrintContent4Div(dvClientID) {
    //Print Content of the Div in a New Blank Window  
    var disp_setting = "toolbar=no,location=no,directories=no,menubar=no,";
    disp_setting += "scrollbars=yes,left=0,top=0,resizable=yes,width=900, height=650,";
    var content_vlue = document.getElementById(dvClientID).innerHTML;
    var docprint = window.open("", "", disp_setting);
    docprint.document.open();
    docprint.document.write('<html><head><title></title>');
    docprint.document.write('</head><body onLoad="self.print()">');
    docprint.document.write(content_vlue);
    docprint.document.write("</body></html>");
    docprint.document.close();
    docprint.focus();
    return false;
}

function ShowImgeLarge(imgPath) {
    var disp_setting = "toolbar=no,location=no,directories=no,menubar=no,";
    disp_setting += "scrollbars=yes,left=0,top=0,resizable=yes,width=900, height=650,";
    var content_vlue = "<img src='" + imgPath + "'/>";
    var docprint = window.open("", "", disp_setting);
    docprint.document.open();
    docprint.document.write('<html><head><title></title>');
    docprint.document.write('</head><body>');
    docprint.document.write(content_vlue);
    docprint.document.write("</body></html>");
    docprint.document.close();
    docprint.focus();
    return false;
}

function RefreshCurrentPage() {
    location.reload(true);
}

function DeleteRow(ConfirmMsg, SelectMsg, CheckBoxName) {
    var boolChkBox = false;
    var boolfoo = false;
    var elem;
    for (i = 0; i <= document.forms[0].length; i++) {
        elem = document.forms[0].elements[i];
        if (elem != null)
            if ((elem.type == 'checkbox')) {
            if (elem.name.indexOf(CheckBoxName) > -1)
                if (elem.checked) {
                boolChkBox = true;
                break;
            }
        }
    }
    if (boolChkBox) {
        boolfoo = confirm(ConfirmMsg);
    }
    else {
        alert(SelectMsg);
        boolfoo = false;
    }
    return boolfoo;
}

function Confirm2(ConfirmMsg, SelectMsg, CheckBoxName) {
    var boolChkBox = false;
    var boolfoo = false;
    var elem;
    for (i = 0; i <= document.forms[0].length; i++) {
        elem = document.forms[0].elements[i];
        if (elem != null)
            if ((elem.type == 'checkbox')) {
            if (elem.name.indexOf(CheckBoxName) > -1)
                if (elem.checked) {
                boolChkBox = true;
                break;
            }
        }
    }
    if (boolChkBox) {
        boolfoo = confirm(ConfirmMsg);
    }
    else {
        alert(SelectMsg);
        boolfoo = false;
    }
    return boolfoo;
}

function MoveItem(ctrlSource, ctrlDestination, Type, Hidden, Message) {

    var Source = document.getElementById(ctrlSource);
    var Destination = document.getElementById(ctrlDestination);

    if ((Source != null) && (Destination != null)) {
        if (Source.options.selectedIndex < 0) {
            alert(Message);
        }
        while (Source.options.selectedIndex >= 0) {
            //var newOption = new Option(); // Create a new instance of ListItem
            var strText, strValue;

            strText = Source.options[Source.options.selectedIndex].text;
            strValue = Source.options[Source.options.selectedIndex].value;

            //                 newOption.text = Source.options[Source.options.selectedIndex].text;
            //                 newOption.value = Source.options[Source.options.selectedIndex].value;
            //                
            //                Destination.options[Destination.length] = newOption; //Append the item in Destination


            var newOpt;
            newOpt = document.createElement("OPTION");
            newOpt = new Option(strText, strValue);
            newOpt.id = strValue;

            Destination.options.add(newOpt);

            Source.remove(Source.options.selectedIndex);  //Remove the item from Source
        }
    }
    if (Type == "Add")
        UpdateHiddenField(ctrlDestination, Hidden);
    else
        UpdateHiddenField(ctrlSource, Hidden);
}
