﻿
function ExpandCollapseDivByJquery(divId) {
    $(divId).slideToggle("slow");
    $(this).toggleClass("active");
    return false;
}

function resolveURLmouseovermouseout(buttonname, imageurl) {
    document.getElementById(buttonname).src = imageurl;
}

function ShowHideDiv(objId, obj1, obj2) {
    if (document.getElementById(objId).style.display == 'none') {
        document.getElementById(objId).style.display = 'block';
        if (obj1 != '')
            document.getElementById(obj1).className = 'city_popup';

        if (obj2 != '')
            document.getElementById(obj2).className = 'city_popup_main';

    }
    else {
        document.getElementById(objId).style.display = 'none';
        if (obj1 != '')
            document.getElementById(obj1).className = '';

        if (obj2 != '')
            document.getElementById(obj2).className = '';
    }
}




/***************************************************
To extact numbers and decimal values in text START
/***************************************************/
function extractNumber(obj, decimalPlaces, allowNegative) {
    var temp = obj.value;

    // avoid changing things if already formatted correctly
    var reg0Str = '[0-9]*';
    if (decimalPlaces > 0) {
        reg0Str += '\\.?[0-9]{0,' + decimalPlaces + '}';
    } else if (decimalPlaces < 0) {
        reg0Str += '\\.?[0-9]*';
    }
    reg0Str = allowNegative ? '^-?' + reg0Str : '^' + reg0Str;
    reg0Str = reg0Str + '$';
    var reg0 = new RegExp(reg0Str);
    if (reg0.test(temp)) return true;

    // first replace all non numbers
    var reg1Str = '[^0-9' + (decimalPlaces != 0 ? '.' : '') + (allowNegative ? '-' : '') + ']';
    var reg1 = new RegExp(reg1Str, 'g');
    temp = temp.replace(reg1, '');

    if (allowNegative) {
        // replace extra negative
        var hasNegative = temp.length > 0 && temp.charAt(0) == '-';
        var reg2 = /-/g;
        temp = temp.replace(reg2, '');
        if (hasNegative) temp = '-' + temp;
    }

    if (decimalPlaces != 0) {
        var reg3 = /\./g;
        var reg3Array = reg3.exec(temp);
        if (reg3Array != null) {
            // keep only first occurrence of .
            //  and the number of places specified by decimalPlaces or the entire string if decimalPlaces < 0
            var reg3Right = temp.substring(reg3Array.index + reg3Array[0].length);
            reg3Right = reg3Right.replace(reg3, '');
            reg3Right = decimalPlaces > 0 ? reg3Right.substring(0, decimalPlaces) : reg3Right;
            temp = temp.substring(0, reg3Array.index) + '.' + reg3Right;
        }
    }

    obj.value = temp;
}
function blockNonNumbers(obj, e, allowDecimal, allowNegative) {
    var key;
    var isCtrl = false;
    var keychar;
    var reg;

    if (window.event) {
        key = e.keyCode;
        isCtrl = window.event.ctrlKey
    }
    else if (e.which) {
        key = e.which;
        isCtrl = e.ctrlKey;
    }

    if (isNaN(key)) return true;

    keychar = String.fromCharCode(key);

    // check for backspace or delete, or if Ctrl was pressed
    if (key == 8 || isCtrl) {
        return true;
    }

    reg = /\d/;
    var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
    var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;

    return isFirstN || isFirstD || reg.test(keychar);
}
function blockSpace(ctrl, e) {
    var isIE = document.all ? true : false;
    var isNS = document.layers ? true : false;
    var key = (isIE) ? window.event.keyCode : e.which;
    if (key == 32) {
        return false;
    }
    else {
        return true;
    }
}
function onlyDigits(obj, e, allowDecimal, allowNegative) {
    var key;
    var isCtrl = false;
    var keychar;
    var reg;

    if (window.event) {
        key = e.keyCode;
        isCtrl = window.event.ctrlKey
    }
    else if (e.which) {
        key = e.which;
        isCtrl = e.ctrlKey;
    }

    if (isNaN(key)) return true;

    keychar = String.fromCharCode(key);

    // check for backspace or delete, or if Ctrl was pressed
    if (key == 8 || isCtrl || key==43 || key==45) {
        return true;
    }

    reg = /\d/;
    var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;

    return isFirstN || reg.test(keychar);
}

//Functions	for Validate Numeric with +-
function validateNumeric(obj, e, allowDecimal, allowNegative) {
    var key;
    var isCtrl = false;
    var keychar;
    var reg;

    if (window.event) {
        key = e.keyCode;
        isCtrl = window.event.ctrlKey
    }
    else if (e.which) {
        key = e.which;
        isCtrl = e.ctrlKey;
    }

    if (isNaN(key)) return true;

    keychar = String.fromCharCode(key);

    // check for backspace or delete, or if Ctrl was pressed
    if (key == 8 || isCtrl) {
        return true;
    }
    //check for + and - sign
    if (key == 43 || key == 45 || isCtrl) {
        return true;
    }

    reg = /\d/;
    var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
    //	var isFirstAdd = allowDecimal ? keychar == '+' && obj.value.indexOf('+') == -1 : false;
    //var isFirstHyphen = allowDecimal ? keychar == '-' && obj.value.indexOf('-') == -1 : false;

    return isFirstN || reg.test(keychar);
}
function setImages(ctrl, imgCtrl, type) {
    var baseCtrl = document.getElementById(ctrl);
    var baseImgCtrl = document.getElementById(imgCtrl);

    if (baseCtrl == null) {
        if (ctrl.indexOf('u_suggestbusiness_') > -1) {
            ctrl = 'ctl00_cphContent_u_suggestbusiness_' + ctrl.substring(ctrl.lastIndexOf('_') + 1);
            baseCtrl = document.getElementById(ctrl);
        }
        else
            return;
    }

    if (baseCtrl.value != '')
        return;

    baseImgCtrl.style.display = 'none';

    if (type == 1)//control focus
    {
        baseCtrl.focus();
        baseImgCtrl.style.display = 'none';
    }
    else if (type == 2)//control blur
    {
        if (baseCtrl.value == '')
            baseImgCtrl.style.display = 'block';
    }
}
/***************************************************
To extact numbers and decimal values in text END
/***************************************************/

/****************************************
Function for grid checkbox select START
/***************************************/
// Checked all Check Box in Grid View...
function SelectGrid(oTemp, nGridName, checkBoxName) {

    var oGrid, sGrid;
    oGrid = eval("document.getElementById('ctl00_cphContent_" + nGridName + "')");
    sGrid = "ctl00_cphContent_" + nGridName;

    if (oTemp.checked == true)
        sCheck = true;
    else
        sCheck = false;

    for (i = 1; i <= oGrid.rows.length + 1; i++) {
        if (i < 10)
        { ctrli = "0" + i; }
        else
        { ctrli = i; }

        var oCheck = eval("document.getElementById('" + sGrid + "_ctl" + ctrli + "_" + checkBoxName + "')");

        if (oCheck) {
            if (oCheck.disabled == false) {
                oCheck.checked = sCheck;
            }
        }
    }
}

//Function For UnChecking All Check box
function UnSelectGrid(oTemp, nGridName, checkBoxName) {
    var oGrid, sGrid;
    oGrid = eval("document.getElementById('ctl00_cphContent_" + nGridName + "')");
    sGrid = "ctl00_cphContent_" + nGridName;

    var sCheck;

    if (oTemp.checked == true)
        sCheck = true;
    else
        sCheck = false;


    for (i = 1; i <= oGrid.rows.length + 1; i++) {
        if (i < 10)
        { ctrli = "0" + i; }
        else
        { ctrli = i; }

        var oCheck = eval("document.getElementById('" + sGrid + "_ctl" + ctrli + "_" + checkBoxName + "')");
        if (oCheck) {
            if (sCheck == false) {
                oCheck.checked = false;
            }

        }
    }
}

/****************************************
Function for grid checkbox select END
/***************************************/

//Function To Loop Through Checkboxes in Datagrid and check if any Checkbox is SELECTED
function confirmDelete(nGridNumber, what) {

    var selected = 0;
    var oGrid, sGrid;


    if (nGridNumber == '1') { oGrid = ctl00_cphContent_grdData; sGrid = "ctl00_cphContent_usrctrlEmp_GvEmployee"; }
    if (nGridNumber == 2) { oGrid = ctl00_cphContent_grdData1; sGrid = "ctl00_cphContent_usrctrlEmployer_GvEmployer"; }

    if (nGridNumber == '1') {
        for (i = 1; i <= (oGrid.rows.length + 1); i++) {

            if (i < 10)
            { ctrli = "0" + i; }

            else
            { ctrli = i; }


            var oCheck = eval("document.getElementById('" + sGrid + "_ctl" + ctrli + "_chkDelete')");
            //alert('ereere');
            if (oCheck) {
                if (oCheck.checked) {
                    if (what != "Email" && what != "Donate") {
                        selected = 1;
                        return confirm('Are you sure you want to' + ' ' + what + ' ' + 'this contact?')

                    }
                }
            }
        }

        if (selected == 0) {
            alert('Please select you want to' + ' ' + what);
            return false;
        }
    }

    if (nGridNumber == 2) {
        for (i = 1; i <= (oGrid.rows.length + 1); i++) {

            if (i < 10)
            { ctrli = "0" + i; }
            else
            { ctrli = i; }

            var oCheck = eval("document.getElementById('" + sGrid + "_ctl" + ctrli + "_chkDelete1')");

            if (oCheck) {
                if (oCheck.checked) {
                    if (what != "Email" && what != "Donate") {
                        selected = 1;
                        return confirm('Are you sure you want to' + ' ' + what + ' ' + 'your selection(s)?')
                    }
                }
            }
        }

        if (selected == 0) {
            alert('Please select items to' + ' ' + what);
            return false;
        }
    }
}

//Function for Redirecting the page to specified loacation within some time specified.

function SplashScreenSeconds(url, msg) {
    var TARG_ID = "spanSplashScreenSeconds"; //Span declared in html form
    var DEF_MSG = "Redirecting...";
    if (!msg) {
        msg = DEF_MSG;
    }
    if (!url) {
        throw new Error('You didn\'t include the "url" parameter');
    }
    var e = document.getElementById(TARG_ID);

    if (!e) {
        throw new Error('"spanSplashScreenSeconds" element id not found');
    }

    var cTicks = parseInt(e.innerHTML);
    var timer = setInterval(function() {
        if (cTicks) {
            e.innerHTML = --cTicks;
        }
        else {
            clearInterval(timer);
            //document.body.innerHTML = msg;
            location = url;
        }

    }, 1000);
}


//Function For validation Check any one Check box in Grid



function checkboxValidation(nGridNumber, nGridName, nAction, nFieldName, nchkboxname) {
    var oGrid, sGrid;

    if (nGridNumber == 1) {
         oGrid = eval("getObj('ctl00_cphContent_" + nGridName + "')");
        sGrid = nGridName;
    }

    if (oGrid.rows.length > 0) {
        var flag = 0;
        for (i = 0; i <= oGrid.rows.length-1; i++) {
            if (i < 10)
            { ctrli = "0" + i; }
            else
            { ctrli = i; }
            var oCheck = eval("getObj('ctl00_cphContent_" + sGrid + "_ctl" + ctrli + "_" + nchkboxname + "')");

            if (oCheck.checked == true) {
                flag = 1;
                return confirm('Are you sure you want to ' + nAction + ' this ' + nFieldName + '?');
            }
        }

        if (flag == 0) {
            alert("Please select " + nFieldName + "");
            return false;
        }
    }
}
//Function For validation Check any one Check box in Grid
function getObj(objID) {
    if (document.getElementById) {
        if (document.getElementById(objID) == null)
            return window.parent.document.getElementById(objID);

        return document.getElementById(objID)
    }
    else if (document.all) {
        if (document.all(objID) == null)
            return window.parent.document.all[objID];

        return document.all[objID];
    }
    else if (document.layers) {
        if (document.layers(objID) == null)
            return window.parent.document.layers[objID];

        return document.layers[objID];
    }
}
function checkboxValidationWithoutHeader(nGridNumber, nGridName, nAction, nFieldName, nchkboxname) {
    var oGrid, sGrid;
    if (nGridNumber == 1) {
        oGrid = eval("getObj('" + nGridName + "')");
        sGrid = nGridName;
    }

    if (oGrid.rows.length > 1) {
        var flag = 0;
        for (i = 1; i <= oGrid.rows.length; i++) {
            if (i < 10)
            { ctrli = "0" + i; }
            else
            { ctrli = i; }
            var oCheck = eval("getObj('" + sGrid + "_ctl" + ctrli + "_" + nchkboxname + "')");

            if (oCheck.checked == true) {
                flag = 1;
                return confirm('Are you sure you want to ' + nAction + ' this ' + nFieldName + '?');
            }
        }

        if (flag == 0) {
            alert("Please select " + nFieldName + "");
            return false;
        }
    }
}
function blockLessGreaterSymbol(evt) {
    //less than - 60
    //greater than - 62

    if (evt.keyCode == 60 || evt.which == 60 || evt.keyCode == 62 || evt.which == 62) {
        return false;
    }
    return true;
}


function validateForName(evt) {
    //less than - 60
    //greater than - 62
    var key;
    if (window.event) {
        key = evt.keyCode;
    }
    else if (e.which) {
        key = evt.which;
    }


    if (key >= 65 && evt.keyCode <= 90 || key >= 97 && key <= 122) {
        return true;
    }
    else {
        return false;
    }
}
//For Enter Button
function enterSubmit() {
    DisableSubmitButtonID = eval("document.getElementById('ctl00_DisableSubmitButtonID').value");
    if (DisableSubmitButtonID != '0') {
        var id = eval("document.getElementById('ctl00_SubmitButtonID').value");
        if (id == "") {
            return;
        }
        else {
            if (id.indexOf(',') != -1) {
                var obtnId = new Array();
                obtnId = id.split(',');
                for (i = 0; i < obtnId.length; i++) {
                    if (document.getElementById(obtnId[i])) {
                        document.getElementById(obtnId[i]).focus();
                    }
                }
            }
            else {                
                document.getElementById(id).focus();
            }
        }
    }
}

function enableSubmit() {
    document.getElementById('ctl00_DisableSubmitButtonID').value = "1";
}
function disableSubmit() {
    document.getElementById('ctl00_DisableSubmitButtonID').value = "0";
}

function ClearDateField(objId) {
    document.getElementById(objId).value = "";
}

function SetFileInTextBox(obj1, obj2, obj3, obj4) {
    document.getElementById(obj3).style.visibility = 'visible';
    document.getElementById(obj1).value = document.getElementById(obj2).value;
    document.getElementById(obj4).value = 1;
}

function ClearFileInTextBox(obj1, obj2, obj3, obj4) {
    document.getElementById(obj3).style.visibility = 'hidden';
    document.getElementById(obj1).value = "";
    obj4.value = "";
}

function resolveURLmouseovermouseout(buttonname, imageurl) {
    document.getElementById(buttonname).src = imageurl;
}

/***********************************************************************
Method: Methods for ajax set data and send email
***********************************************************************/
function getFormElementForValGroup(form1, valGroup, type) {
    if (getFormElement(form1, valGroup)) {
        if (type == 8) {
            var name = document.getElementById("ctl00_cphContent_txtName").value;
            var businessName = document.getElementById("ctl00_cphContent_txtBusinessName").value;
            var businessType = document.getElementById("ctl00_cphContent_txtBusinessType").value;
            var addrees1 = document.getElementById("ctl00_cphContent_txtAddress1").value;
            var addrees2 = document.getElementById("ctl00_cphContent_txtAddress2").value;
            var comment = document.getElementById("ctl00_cphContent_txtComment").value;
            //send email and set data
            Send_PromoteBusiness_DataEmail(name, businessName, businessType, addrees1, addrees2, comment);
        }
    }
    return false;

}
function fillDays(iMonth, iYear, ddlMonth, ddlDay) {
    var daysInMonth = 32 - new Date(iYear, iMonth, 32).getDate();
}
function checkCCExpiryDate(monthdll, yearddl) {
    var curDate = new Date();
    var curmonth = curDate.getMonth() + 1;
    var curYear = curDate.getFullYear();

    if (parseInt(document.getElementById(yearddl).value) > parseInt(curYear))
        return true;
    else if ((document.getElementById(monthdll).value) < parseInt(curmonth) && parseInt(document.getElementById(yearddl).value) == parseInt(curYear))
        return false;
    else
        return true;

}

/***********************************************************************
Method: Methods for date, month and year dropdown
***********************************************************************/

function fillDateMonthYearDDL(objDateDDL, objMonthDDL, objYearDDL) {

    var dDDL = document.getElementById(objDateDDL);
    var mDDL = document.getElementById(objMonthDDL);
    var yDDL = document.getElementById(objYearDDL);
    emptyList(dDDL);
    year = parseInt(yDDL.value);
    month = parseInt(mDDL.value);
    BindDays(year, month, dDDL);
}

function CheckLeap(year) {
    if ((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0))
        return true;
    else
        return false;
}

function BindDays(year, month, dateDDL) {
    var i;
    var opt;

    switch (month) {
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            for (i = 1; i <= 31; i++) {
                opt = new Option(i, i); //create new option
                dateDDL.options[dateDDL.options.length] = opt; //Add the new option it to the select  
            }
            break;
        case 2:
            if (CheckLeap(year)) {
                for (i = 1; i <= 29; i++) {
                    opt = new Option(i, i); //create new option
                    dateDDL.options[dateDDL.options.length] = opt; //Add the new option it to the select  
                }
            }
            else {
                for (i = 1; i <= 28; i++) {
                    opt = new Option(i, i); //create new option
                    dateDDL.options[dateDDL.options.length] = opt; //Add the new option it to the select  
                }
            }
            break;
        case 4:
        case 6:
        case 9:
        case 11:
            for (i = 1; i <= 30; i++) {
                opt = new Option(i, i); //create new option
                dateDDL.options[dateDDL.options.length] = opt; //Add the new option it to the select  
            }
            break;
    }
}

function emptyList(recevierObj) {
    //alert(document.getElementById(recevierObj.id).options.length);
    for (i = 1; i < (document.getElementById(recevierObj.id).options.length + 1); i++) {
        document.getElementById(recevierObj.id).remove(i - 1);
        i--;
    }
    //return true;
}
function CollapseSearchSection() {
    $("#divSearch").slideToggle("slow");
    $(this).toggleClass("active");
}
function checkACNNumber(objACNTextBox) {
    var acn = document.getElementById(objACNTextBox).value;
    var weight = "8,7,6,5,4,3,2,1";
    var l_weight
    var l_weight = weight.split(",");
    var l_sum = 0;
    var l_remainder = 0;
    var l_calculatedCheckDigit = 0;
    if (acn == "")
        return true;

    // Ensure acn is 9 digits long
    if (acn.length != 9)
        return false;
    // Sum the multiplication of all the digits and weights
    for (i = 0; i < l_weight.length; i++) {
        l_sum += parseInt(acn.substr(i, 1), 10) * l_weight[i];
    }

    // Divide by 10 to obtain remainder
    l_remainder = l_sum % 10;

    // Complement the remainder to 10
    l_calculatedCheckDigit = (10 - l_remainder == 10) ? 0 : (10 - l_remainder);

    // Compare the calculated check digit with the actual check digit
    if (parseInt(l_calculatedCheckDigit, 10) == parseInt(acn.substr(8, 1), 10))
        return true;
    else
        return false;
}
function checkABNNumber(objABNTextBox) {
    var abn = document.getElementById(objABNTextBox).value;
    var weight = "10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19";
    var l_weight = weight.split(',');
    var l_sum = 0;

    if (abn == "")
        return true;
    // Ensure ABN is 11 digits long
    if (abn.length != 11) {
        return false;
    }
    // Sum the multiplication of all the digits and weights
    for (i = 0; i < l_weight.length; i++) {
        // Subtract 1 from the first left digit before multiplying against the weight
        if (i == 0)
            l_sum = (parseInt(abn.substr(i, 1), 10) - 1) * l_weight[i];
        else {
            l_sum += parseInt(abn.substr(i, 1), 10) * l_weight[i];

        }
    }
    // Divide the sum by 89, if there is no remainder the ABN is valid
    if ((l_sum % 89) == 0)
        return true;
    else
        return false;
}
//Use this function to set default business
function SetDefault(focus, Obj, txt) {
    if (focus == true && Obj.value == txt) {
        Obj.value = "";
    }
    else {
        if (Obj.value == "") {
            Obj.value = txt;
        }
    }
}
function checkRequiredField(Obj, txt) {
    if (document.getElementById(Obj).value == "" || document.getElementById(Obj).value == txt)
        return false;
    else
        return true;
}

function MM_openBrWindow(theURL, winName, features) { //v2.0
    window.open(theURL, winName, features);
}
function ValidateAusStreetNo(objText) {

    // avoid changing things if already formatted correctly
    //var reg1 = new RegExp('^[0-9]+-[0-9]+$'); //10-10
    //var reg2 = new RegExp('^[0-9]+$'); //10
    //var reg3 = new RegExp('^[0-9]+/[0-9]+-[0-9]+$'); //10/10-20	

    //if (reg1.test(document.getElementById(objText).value)) return true;
    //if (reg2.test(document.getElementById(objText).value)) return true;
    //if (reg3.test(document.getElementById(objText).value)) return true;
    //return false;
    return true;
}
function StopSpecialChar(e) {
    var key;
    if (window.event) {
        key = e.keyCode;
        //	isCtrl = window.event.ctrlKey
    }
    else if (e.which) {
        key = e.which;
        //	isCtrl = e.ctrlKey;
    }

    if (key == 37 || key == 38 || key == 42 || key == 43 || key == 44 || key == 58 || key == 60 || key == 62 || key == 63 || key == 92 || key == 46)
        return false;
    else
        return true;
}
function RemoveSpecialChar(objTextBox) {
    var str = document.getElementById(objTextBox).value;
    if (str.indexOf('<') != -1)
        return false;
    else if (str.indexOf('>') != -1)
        return false;
    else if (str.indexOf(',') != -1)
        return false;
    else if (str.indexOf('*') != -1)
        return false;
    else if (str.indexOf('%') != -1)
        return false;
    else if (str.indexOf(':') != -1)
        return false;
    else if (str.indexOf("\\") != -1)
        return false;
    else if (str.indexOf('?') != -1)
        return false;
    else if (str.indexOf('.') != -1)
        return false;
    else if (str.indexOf('&') != -1)
        return false;
    else
        return true;
}
function checkQuantity(txtbox, minValue) {
    if (parseInt(document.getElementById(txtbox).value, 10) == minValue)
        return false;
    else
        return true;
}

function Validate(obj, valgroup, imageUrl) {
    var form = document.getElementById("aspnetForm")
    var isValidate = getFormElement(form, valgroup);
    if (!isValidate)
        return false;
    else {
        obj.src = imageUrl;
        obj.removeAttribute("onmouseover");
        obj.removeAttribute("onmouseout");
        setTimeout(function() { obj.disabled = true; }, 0);
        //$.blockUI({ message: '<div style="color:red;font-size:25px;font-weight:bold;text-transform: uppercase;">Your Request is being processed.</div><div style="color:#000000;font-size:22px;font-weight:bold;padding: 20px;"> Please do not press<br/><span style="color:red;">"BUY NOW"</span> button again <br/> or <br/> browser <span style="color:red;">"Back"</span> or <span style="color:red;">"REFRESH"</span> buttons.</div>' });
        //$.blockUI({ message: '<div style="width:100%;"><div style="float:left;"><img src="http://localhost/shareonlive/images/indicator.gif" /></div><div style="float:left;color:#000000;font-size:25px;font-weight:bold;">Please wait whilst we process your payment</div></div>' });
        $.blockUI();
        return true;
    }
}

function getCookie(c_name) {
    var i, x, y, ARRcookies = document.cookie.split(";");
    for (i = 0; i < ARRcookies.length; i++) {
        x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
        y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
        x = x.replace(/^\s+|\s+$/g, "");
        if (x == c_name) {
            return unescape(y);
        }
    }
}
function isValidDate(value) {
    try {
        value = value.replace("-", "/").replace(".", "/");
        var SplitValue = value.split("/");
        var OK = true;
        if (!(SplitValue[0].length == 1 || SplitValue[0].length == 2)) {
            OK = false;
        }
        if (OK && !(SplitValue[1].length == 1 || SplitValue[1].length == 2)) {
            OK = false;
        }
        if (OK && SplitValue[2].length != 4) {
            OK = false;
        }
        if (OK) {
            var Day = parseInt(SplitValue[0]);
            var Month = parseInt(SplitValue[1]);
            var Year = parseInt(SplitValue[2]);

            if (OK = ((Year > 1900) && (Year < new Date().getFullYear()))) {
                if (OK = (Month <= 12 && Month > 0)) {
                    var LeapYear = (((Year % 4) == 0) && ((Year % 100) != 0) || ((Year % 400) == 0));

                    if (Month == 2) {
                        OK = LeapYear ? Day <= 29 : Day <= 28;
                    }
                    else {
                        if ((Month == 4) || (Month == 6) || (Month == 9) || (Month == 11)) {
                            OK = (Day > 0 && Day <= 30);
                        }
                        else {
                            OK = (Day > 0 && Day <= 31);
                        }
                    }
                }
            }
        }
        return OK;
    }
    catch (e) {
        return false;
    }
}


function CheckPaymentSchedule(eleId,eleIdText)
{
    if(document.getElementById(eleId).checked)
    {
        if(eleId == 'ctl00_cphContent_rbtnUpfront')
        {
            if(document.getElementById(eleIdText).value == '-1')
            {
                return false;
            }
            else if(document.getElementById(eleIdText).value == '')
            {
                return false;
            }
            else
            {
                   return true;
            }
        }
        else if(eleId == 'ctl00_cphContent_rbtnRemainder')
        {
            if(document.getElementById(eleIdText).value == '')
            {
                return false;
            }
            else
            {
                   return true;
            }
        }
        else
        {
            return true;
        }
    }
    else
    {
           return true;
    }
}

function CheckDealPayment(eleId,eleIdText)
{
    if(document.getElementById('ctl00_cphContent_chkPayment').checked)
    {
        if(document.getElementById(eleId).checked)
        {
            if(eleId == 'ctl00_cphContent_rbtnUpfront')
            {
                if(document.getElementById(eleIdText).value == '-1')
                {
                    return false;
                }
                else if(document.getElementById(eleIdText).value == '')
                {
                    return false;
                }
                else
                {
                       return true;
                }
            }
            else if(eleId == 'ctl00_cphContent_rbtnRemainder')
            {
                if(document.getElementById(eleIdText).value == '')
                {
                    return false;
                }
                else
                {
                       return true;
                }
            }
            else
            {
                return true;
            }
        }
        else
        {
               return true;
        }
    }
    else
    {
        return true;
    }
}

function ShowPaymentSchedule()
{
    if(document.getElementById('ctl00_cphContent_chkPayment').checked)
    {
        document.getElementById('ctl00_cphContent_divPayment').style.visibility = "visible";
    }
    else
    {
        document.getElementById('ctl00_cphContent_divPayment').style.visibility = "hidden";
    }
}
