﻿function clearInput(control) {
    ctrl = document.getElementById(control);
    if (ctrl.value == "Email" || ctrl.value == "Password" || ctrl.value == "Search")
        ctrl.value = "";
}

function addInput(control, text)
{
    ctrl = document.getElementById(control);
    if (ctrl.value == "")
        ctrl.value = text;
}
function switchCss(control, styleClass) {
    ctrl = document.getElementById(control);
    ctrl.setAttribute('className', styleClass) || 
    ctrl.setAttribute('class', styleClass);

    //alert(control);
}


function switchCSSRow(control, styleClass) {
    ctrl = document.getElementById(control);
    //ctrl.className = styleClass;
    //alert(control);
}

function SetClassClick(row, checkbox) {
    ctrlRow = document.getElementById('ctl00_ContentPlaceHolder1_gridPlots_' + row);
    if (ctrlRow == null)
        ctrlRow = document.getElementById('ctl00_ContentPlaceHolder1_gridSaved_' + row);
    ctrlBox = document.getElementById('ctl00_ContentPlaceHolder1_gridPlots_' + row + '_' + checkbox);
    if (ctrlBox == null)
        ctrlBox = document.getElementById('ctl00_ContentPlaceHolder1_gridSaved_' + row + '_' + checkbox);
    //if (ctrlBox.checked)
    //    ctrlRow.className = 'gridPlotItemBlue';
    //else
        ctrlRow.className = 'gridPlotItem';
}


function SetClassOver(row, checkbox) {
    ctrlRow = document.getElementById('ctl00_ContentPlaceHolder1_gridPlots_' + row);
    if (ctrlRow == null)
        ctrlRow = document.getElementById('ctl00_ContentPlaceHolder1_gridSaved_' + row);
    ctrlBox = document.getElementById('ctl00_ContentPlaceHolder1_gridPlots_' + row + '_' + checkbox);
    if (ctrlBox == null)
        ctrlBox = document.getElementById('ctl00_ContentPlaceHolder1_gridSaved_' + row + '_' + checkbox);
    //if (ctrlBox.checked)
    //    ctrlRow.className = 'gridPlotItemBlue';
    //else
        ctrlRow.className = 'gridPlotItemGreen';
}

function SetClassOut(row, checkbox) {
    ctrlRow = document.getElementById('ctl00_ContentPlaceHolder1_gridPlots_' + row);
    if (ctrlRow == null)
        ctrlRow = document.getElementById('ctl00_ContentPlaceHolder1_gridSaved_' + row);
    ctrlBox = document.getElementById('ctl00_ContentPlaceHolder1_gridPlots_' + row + '_' + checkbox);
    if (ctrlBox == null)
        ctrlBox = document.getElementById('ctl00_ContentPlaceHolder1_gridSaved_' + row + '_' + checkbox);
    //if (ctrlBox.checked)
    //    ctrlRow.className = 'gridPlotItemBlue';
    //else
        ctrlRow.className = 'gridPlotItem';
}

function GeneratePDF() {
    var eventName = "btnSingle_Click";
    var eventArgs = "Generate";
    var prm = Sys.WebForms.PageRequestManager.getInstance();

    if (!Array.contains(prm._asyncPostBackControlIDs, eventName)) {
        prm._asyncPostBackControlIDs.push(eventName);
    }

    if (!Array.contains(prm._asyncPostBackControlClientIDs, eventName)) {
        prm._asyncPostBackControlClientIDs.push(eventName);
    }

    __doPostBack(eventName, eventArgs);
}

function UploadComplete(sender, args) {
       __doPostBack('AsyncFileUpload1', '');     
    }





    function OpenDocumentViewer(image) {
        var previewTextbox = $find("<%= previewImage.ClientID %>");
        previewTextbox.value = image;
        var wnd = $find("<%= DocumentWindow.ClientID %>");
        wnd.show();
    }
    var textbox;
    function OpenFileExplorerDialog(sender) {
        textbox = document.getElementById(sender);
        var wnd = $find("<%= ExplorerWindow.ClientID %>");
        alert(wnd);
        wnd.show();
    }
    
    function OnFileSelected(fileSelected) {
        textbox.value = fileSelected;
        doPostBackAsync('txtDoc_TextChanged', textbox.id);
    }
    function doPostBackAsync(eventName, eventArgs) {
        var prm = Sys.WebForms.PageRequestManager.getInstance();
        
        if (!Array.contains(prm._asyncPostBackControlIDs, eventName)) {
            prm._asyncPostBackControlIDs.push(eventName);
        }

        if (!Array.contains(prm._asyncPostBackControlClientIDs, eventName)) {
            prm._asyncPostBackControlClientIDs.push(eventName);
        }
        __doPostBack(eventName, eventArgs);
    }

    function ToggleSelectedStateClient() {
        alert();
        //doPostBackAsync('ToggleSelectedState', '');
        _doPostBack('ToggleSelectedState', '');
    }

    function ToggleSelectedRowClient(ctrl) {
        alert(ctrl.checked);
        //doPostBackAsync('ToggleSelectedState', ctrl.id);
        _doPostBack('ToggleSelectedState', '');
    }



