﻿
//ANY CLIENT SIDE MESSAGES CAN BE PUT HERE
var SF_SaveOnlyWarning = "Action Comments and SmartFlow Comments will not be saved.\nDo you want to Procees?";

//function to confirm delete an entry in the form
function Confirm() {
    if (document.all("lblDataStatus").value == "OLD")
        return window.confirm("Delete this record. Are you sure?");
    else
        return false;
}
//function to confirm Void a SmartFlow document
function ConfirmVoid() {
    return window.confirm("Void this SmartFlow document. Are you sure?");
}

//function to confirm delete an entry in the CMR
function ConfirmChanges() {
    return window.confirm("Changes will be lost. Are you sure?");
}

//function to confirm delete an entry in the form
function ConfirmMsg(msg) {
    return window.confirm(msg);
}
function openLegends(link) {
    var url = "../Legend.aspx"
    if (link)
        url += link;

    window.open(url, "legends", "channelmode=no,directories=no, fullscreen=no, height=500, width=600, location=no, menubar=no, resizable=no, scrollbars=yes, status=no, titlebar=yes, toolbar=no", true);
    return true;
}
function openWindow(url, windowName) {
    if (!url) return;
    var strFeatures = "height=600, width=800, scrollbars=yes, resizable=yes, toolbar=yes, location=no, menubar=yes";
    window.open(url, windowName, strFeatures, true);
    return false;
}
function openPrintWindow(url, windowName) {
    if (!url) return;
    var strFeatures = "height=700, width=700, scrollbars=yes, resizable=yes, toolbar=yes";
    window.open(url, windowName, strFeatures, true);
    return false;
}
function openDialogWindowFullScreen(url, width, height, status, windowName) {
    if (!url) return;
    if (!width) width = 800;
    if (!height) height = 600;
    if (!status) status = 'no'
    if (!windowName) name = "WDEIPReport";
    var strFeatures = "height=" + height + ", width=" + width + ", status=" + status + ", scrollbars=1,maximize=1,resizable=1,toolbar=no,location=0, menubar=0"
    var windowRef = window.open(url, windowName, strFeatures, true);

    windowRef.moveTo(0, 0);

    if (document.all) {
        //windowRef.maximize();
        windowRef.resizeTo(screen.availWidth, screen.availHeight);
    }
    else if (document.layers || document.getElementById) {
        if (windowRef.outerHeight < screen.availHeight || windowRef.outerWidth < screen.availWidth) {
            windowRef.outerHeight = screen.availHeight;
            windowRef.outerWidth = screen.availWidth;
        }

        return false;
    }
    return true;
}
var nw
function openAnyWindow(url, name, w, h) {

    name = "image";
    if (!nw || nw.closed) {
        nw = window.open(url, name, 'scrollbars=yes,resizable=yes,status=no,location=no,menubar=no,width=' + w + ',height=' + h);
        if (!nw.opener) {
            nw.opener
        }
        //nw.document.close()
    }
    else {
        nw.close()
        nw = window.open(url, name, 'scrollbars=yes,resizable=yes,status=no,location=no,menubar=no,width=' + w + ',height=' + h);
        nw.focus()
    }
}



function openDialogWindow(url, width, height, status, windowName) {
    if (!url) return;
    if (!width) width = 800;
    if (!height) height = 600;
    if (!status) status = 'no'
    if (!windowName) name = "WDEIPDialog";
    var strFeatures = "height=" + height + ", width=" + width + ", status=" + status + ", scrollbars=yes, resizable=yes, toolbar=no, location=no, menubar=no"
    window.open(url, windowName, strFeatures, true);
    return false;
}
function openCPRWindow(url, width, height, status, windowName) {
    if (!url) return;
    if (!status) status = 'yes';
    if (!width) width = 700;
    if (!height) height = 400;
    if (!windowName) windowName = "WDEIPCPRDialog";
    var strFeatures = "height=" + height + ", width=" + width + "status=" + status + ", scrollbars=yes, resizable=yes, toolbar=yes, location=yes, menubar=yes"
    window.open(url, windowName, strFeatures, true);
    return false;
}
function openHistoryWindow(url, width, height, status, windowName) {
    if (!url) return;
    if (!status) status = 'yes';
    if (!width) width = 700;
    if (!height) height = 400;
    if (!windowName) windowName = "WDEIPHistory";
    var strFeatures = "height=" + height + ", width=" + width + "status=no, scrollbars=yes, resizable=yes, toolbar=no, location=no, menubar=yes"
    window.open(url, windowName, strFeatures, true);
    return false;
}
function openCMRWindow(url, width, height, status, windowName) {
    if (!url) return;
    if (!status) status = 'yes';
    if (!windowName) windowName = "WDEIPCMRDialog";
    var strFeatures = "status=" + status + ", scrollbars=yes, resizable=yes, toolbar=yes, location=no, menubar=yes"
    window.open(url, windowName, strFeatures, true);
    return false;
}
function openCMRPHWindow(url, width, height, status) {
    if (!url) return;
    if (!width) width = 800;
    if (!height) height = 400;
    if (!status) status = 'yes';
    var strFeatures = "height=" + height + ", width=" + width + ",status=" + status + ", scrollbars=yes, resizable=yes, toolbar=yes, location=no, menubar=no"

    window.open(url, "PaymentHistoryDialog", strFeatures, false);
    return false;
}
function openCMRWindowOnly(url, width, height, status) {
    if (!url) return;
    if (!width) width = 800;
    if (!height) height = 400;
    if (!status) status = 'yes';
    var strFeatures = "height=" + height + ", width=" + width + ",status=" + status + ", scrollbars=yes, resizable=yes, toolbar=no, location=no, menubar=no"

    window.open(url, "PaymentHistoryDialog", strFeatures, false);
    return false;
}
function openESWindow(url, width, height, status) {
    if (!url) return;
    if (!width) width = 800;
    if (!height) height = 400;
    if (!status) status = 'yes';
    var strFeatures = "height=" + height + ", width=" + width + ",status=" + status + ", scrollbars=yes, resizable=yes, toolbar=yes, location=no, menubar=no"

    window.open(url, "EvaluationSample", strFeatures, false);
    return false;
}
function openCMRCISWindow(url, width, height, status) {
    if (!url) return;
    if (!width) width = 800;
    if (!height) height = 400;
    if (!status) status = 'yes';
    var strFeatures = "height=" + height + ", width=" + width + ",status=" + status + ", scrollbars=yes, resizable=yes, toolbar=yes, location=no, menubar=no"

    window.open(url, "CustModelInvPOSDialog", strFeatures, false);
    return false;
}
function openCommentsWindow(url, width, height, status) {
    if (!url) return;
    if (!width) width = 525;
    if (!height) height = 150;
    if (!status) status = 'no'
    var strFeatures = "height=" + height + ", width=" + width + ", status=" + status + ", scrollbars=yes, resizable=no, toolbar=no, location=no, menubar=no, left=200, top=200"
    window.open(url, "CPRComments", strFeatures, true);
    return false;
}


function GoPrevious() {
    window.history.back(-1);
    return false;
}
function UpdateCutOffDate() {
    //alert('inside updatecutoffdate');
    var dt = new Date(document.all("CPRHeader1:txtEndDate").value);
    var dt1 = new Date(dt.getFullYear(), dt.getMonth(), dt.getDate() + 30);
    var s = '';
    var i = dt1.getMonth() + 1;
    if (i < 10) s += '0' + i;
    else s += i;

    i = dt1.getDate();
    if (i < 10) s += '/0' + i;
    else s += '/' + i;

    s += '/' + dt1.getFullYear();

    document.all("CPRHeader1:txtCMCutOffDate").value = s;
}

function selectRow(id, source, objectId) {
   // alert("objectId->" + objectId + ", id->" + id + ", source->" + source);
    //window.opener.document.forms[0].onsubmit="javascript: return;";
    window.opener.execScript(source + "_callBack('" + id + "', 0);", "javascript");
    window.close();
}
function SelectPopUpRow(id, source, objectId, popupID) {
    // alert("objectId->" + objectId + ", id->" + id + ", source->" + source);
    //window.opener.document.forms[0].onsubmit="javascript: return;";
    //window.opener.execScript(source + "_callBack('" + id + "', 0);", "javascript");
    debugger;

    document.getElementById(objectId).value = checkedValue;
    $find(popupID).hide();
    // window.close();

}
   
   


function closeWindow() {
    window.close();
    return false;
}
function checkInputData() {
    var s = document.all["txtSearchValue"].value;
    if (s != null && s != 'undefined') {
        var re = /['|"]*/g;
        s = s.replace(re, "");
        document.all["txtSearchValue"].value = s;
    }
    return true;
}
function FormatNumber(num, decimalNum, bolLeadingZero, bolParens) {
    //alert('formatnumber');
    var tmpNum = num;

    // Return the right number of decimal places
    tmpNum *= Math.pow(10, decimalNum);
    tmpNum = Math.floor(tmpNum);
    tmpNum /= Math.pow(10, decimalNum);

    var tmpStr = new String(tmpNum);

    // See if we need to hack off a leading zero or not
    if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
        if (num > 0)
        tmpStr = tmpStr.substring(1, tmpStr.length);
    else
    // Take out the minus sign out (start at 2)
        tmpStr = "-" + tmpStr.substring(2, tmpStr.length);


    // See if we need to put parenthesis around the number
    if (bolParens && num < 0)
        tmpStr = "(" + tmpStr.substring(1, tmpStr.length) + ")";


    return tmpStr;
}


/*function replace(str, from, to) {
var i = str.indexOf(from);
if (!from || !str || i == -1) return str;
var newstr = str.substring(0, i) + to;
if (i+from.length &lt; str.length)
newstr += replace(str.substring(i+from.length,str.length),from,to);
return newstr;
}*/


//function Encode(string, encodeChar, encode)
//{
//	if(encodeChar=="") return string;
//	var rs="___";
//	switch(encodeChar)
//	{
//		case "&": rs = "___";
//	}

//	String str = new String(string);

//	var string1 = str.replace(string, encodeChar, rs);
//	alert(string1);
//	return string1;

//}

