﻿function docall() {

    $(document).ready(function() {



        ShowResourceForEval();
        //resource show on page 3 - would ve better to convert to ajax!
        //$("[id$=tabs]").click(function() {
        //ShowResourceForEval();
        //});


        ///////////////////// BUDGET
        //Making textfield only accept numeric values
        $("[id$=staffBudgetAmountTextBox]").keydown(function(event) {
            // Allow only backspace and delete

            if (event.keyCode == 46 || event.keyCode == 8) {
                // let it happen, don't do anything
            }
            else {
                // Ensure that it is a number and stop the keypress
                if (event.shiftKey) {
                    event.preventDefault();
                }
                if (!CheckNumericKeyInfo(event.keyCode, event.which) || (event.keyCode == 16 || (event.keyCode == 9 && event.shiftKey))) {
                    event.preventDefault();

                }
            }
        });

        /////////////////////
        //Making textfield only accept numeric values
        $("[id$=resourceBudgetAmountTextBox]").keydown(function(event) {
            // Allow only backspace and delete

            if (event.keyCode == 46 || event.keyCode == 8) {
                // let it happen, don't do anything
            }
            else {
                // Ensure that it is a number and stop the keypress
                if (event.shiftKey) {
                    event.preventDefault();
                }
                if (!CheckNumericKeyInfo(event.keyCode, event.which) || (event.keyCode == 16 || (event.keyCode == 9 && event.shiftKey))) {
                    event.preventDefault();

                }
            }
        });
        ////////////////////////////////////////

        //login button
        $("#loginButton").click(function() {
            location.href = "login.aspx";

        });

        //admin

        //admin admin-budget
        $(".admin-budget").hover(
            function() {
                //alert('');
                $(this).addClass("hover");
            },
            function() {
                $(this).removeClass("hover");
            }
        );

        $(".admin-budget").click(function() {
            $find('PleaseWaitPopup').show();
            var budgetID = ($(this).attr("id"));
            //alert(budgetID);
            var date = new Date(); var timestamp = date.getTime();
            var mydata = { dowhat: "ListForAdminByBudget", budgetID: budgetID, randomTime: timestamp };
            $.ajax({
                type: "GET",
                url: "ajax/ajax.aspx",
                data: mydata,
                error: function(msg) {
                    alert("error: " + msg);
                },
                success: function(response) {
                    if (response != "") {

                        $("#admin-budget").attr("innerHTML", response);
                        LoadAjaxJqery(budgetID); // handles events from generated code
                    }
                    else {
                        $("#admin-budget").attr("innerHTML", 'No plans found for this budget');
                    }
                }

            });
            $find('PleaseWaitPopup').hide();
        });

        //admin admin-manager
        $(".admin-manager").hover(
            function() {
                //alert('');
                $(this).addClass("hover");
            },
            function() {
                $(this).removeClass("hover");
            }
        );

        $(".admin-manager").click(function() {
            $find('PleaseWaitPopup').show();
            var managerID = ($(this).attr("id"));
            //alert(budgetID);
            var date = new Date(); var timestamp = date.getTime();
            var mydata = { dowhat: "ListForAdminByManager", managerID: managerID, randomTime: timestamp };
            $.ajax({
                type: "GET",
                url: "ajax/ajax.aspx",
                data: mydata,
                error: function(msg) {
                    alert("error: " + msg);
                },
                success: function(response) {
                    if (response != "") {

                        $("#admin-budget").attr("innerHTML", response);
                        LoadAjaxJqery(managerID); // handles events from generated code
                    }
                    else {
                        $("#admin-budget").attr("innerHTML", 'No plans found for this budget');
                    }
                }

            });
            $find('PleaseWaitPopup').hide();
        });
        //admin - set status
        $(".admin-selected").change(function() {
            //alert($(this).val() + ' | ' + $(this).attr("name"));
            //return false;
            var planID = $(this).attr("name");
            var statusID = $(this).val();
            var date = new Date(); var timestamp = date.getTime();
            var mydata = { dowhat: "changeAdminStatus", planID: planID, statusID: statusID, randomTime: timestamp };

            $.ajax({
                type: "GET",
                url: "ajax/ajax.aspx",
                data: mydata,
                error: function(msg) {
                    alert("error: " + msg);
                },
                success: function(response) {
                    if (response != "") {
                        Boxy.alert(response, null, { title: 'Message' });
                    }
                    else {
                        alert('OK');
                        location.href = "admin.aspx";
                    }
                }

            });

        });

        //desc area word count
        ///////////////////////////////////////////////////////////////////////////////
        $("[id$=planDescription]").each(function() {
            // get current number of characters  
            //var length = $(this).val().length;  
            // get current number of words  
            var length = $(this).val().split(/\b[\s,\.-:;]*/).length;
            // update characters  
            //$(this).parent().find('.counter').html( length + ' characters');  
            // bind on key up event
            $(this).keyup(function() {
                // get new length of characters  
                //var new_length = $(this).val().length;  
                // get new length of words  
                var new_length = $(this).val().split(/\b[\s,\.-:;]*/).length - 1;
                // update
                $('#charCount').html(new_length + ' words');
                if (new_length > 500) {
                    $("[id$=UpdateDEscriptionButton]").hide();
                    $('#charCount').html('<strong>You may only have up to 500 words. (' + new_length + ')</strong>');
                }
                else {
                    $("[id$=UpdateDEscriptionButton]").show();
                }
            });
        });
        ///////////////////////////////////////////////////////////////////////////////

        //hide buttons for read only - page one
        if ($("[id$=PageOneReadOnly]").attr("value") == "true") {
            $(".save-control").animate({ height: 'hide', opacity: 'hide' }, 'slow');
            $(".other-eval-edit").animate({ height: 'hide', opacity: 'hide' }, 'slow');
            //$("#go-submit").animate({ height: 'hide', opacity: 'hide' }, 'slow');
            $("[id$=EditButton]").animate({ height: 'hide', opacity: 'hide' }, 'slow');
        }
        //hide buttons for Locked
        if ($("[id$=LockedHiddenField]").attr("value") == "true") {
            $(".go-submit").hide();
        }
        //hide delete button for all stages apart from status 1
        if ($("[id$=ProjectStatusHiddenField]").attr("value") != "1") {
            $("#go-delete").hide();
        }

        //Create New Project
        $("#newproject").click(function() {

            if ($(".new-project").is(":hidden") == true) {
                $(".new-project").animate({ height: 'show', opacity: 'show' }, 'slow');
                $("#newproject").attr("value", "cancel");
                $("#newproject").attr("class", "brown_button");
                $("#new-project-title").hide();
                $(".showyr").hide();
                
            }
            else {
                $(".new-project").animate({ height: 'hide', opacity: 'hide' }, 'slow');
                $("#newproject").attr("value", "Create new project file");
                $("#newproject").attr("class", "brown_button");
                $("#new-project-title").show();
                $(".showyr").show();
                
            }
        });

        $("#newProject-save").click(function() {

            if (trim($("#newProject").attr("value")) == "") { Boxy.alert("Please enter a name for this project", null, { title: 'Message' }); return false };
            $find('PleaseWaitPopup').show();
            var planName = $("#newProject").attr("value");
            var date = new Date(); var timestamp = date.getTime();
            var mydata = { params: planName, dowhat: "newProject", randomDate: timestamp };

            $.ajax({
                type: "GET",
                url: "ajax/ajax.aspx",
                data: mydata,
                error: function(msg) {
                    alert("error: " + msg);
                    IsSuccess = false;
                },
                success: function(response) {
                    $find('PleaseWaitPopup').hide();
                    if (response != "") {
                        if (response.slice(0, response.indexOf("-")) == "OK") {
                            var projectNum = response.slice(response.indexOf("-") + 1, response.length);
                            //alert(projectNum);
                            location.href = "project.aspx?project=" + projectNum;
                        }
                        else {
                            Boxy.alert(response, null, { title: 'Message' });
                            //$("#newProject").attr("value", "");
                            $("#newProject").focus();

                        }

                    }
                    else {
                        //$find('PleaseWaitPopup').hide();

                    }
                }

            });
        });
        // Displaying lists of plans
        /////////////////////////////

        //jquery replecement code for html select for year select
        /////////////////////////////
        
		        
        $(".dropdown dt a").click(function() {
            $(".dropdown dd ul").toggle();
            
        });

        $(".dropdown dd ul li a").click(function() {
	         
            var text = $(this).html();
            $(".dropdown dt a span").html(text);
            $(".dropdown dd ul").hide();
            //$("#result").html("Selected value is: " + getSelectedValue("sample"));
            ListPlans(parseFloat(getSelectedValue("sample")));
        });

        function getSelectedValue(id) {
            return $("#" + id).find("dt a span.value").html();
        }

        $(document).bind('click', function(e) {
            var $clicked = $(e.target);
            if (!$clicked.parents().hasClass("dropdown"))
                $(".dropdown dd ul").hide();
        });
        
        //list plans by sselected year - old select method

        $("#yearselect").change(function() {
            var yeartoshow = trim($(this).val());
            //var date = new Date(); var timestamp = date.getTime();
            ListPlans(parseFloat(yeartoshow));
            
        });

        //////////////////////////////////

        //list plans on demand
        /*
        $("#listPlans").click(function() {
        var date = new Date(); var timestamp = date.getTime();
        var mydata = { dowhat: "listPlans", randomTime: timestamp };
        //alert('jj');
        $.ajax({
        type: "GET",
        url: "ajax/ajax.aspx",
        data: mydata,
        error: function(msg) {
        alert("error: " + msg);
        },
        success: function(response) {
        //alert(response);
        if (response != "") {
        $("#plan-list").attr("innerHTML", response).animate({ height: 'show', opacity: 'show' }, 'slow');
        }
        else {
        $("#plan-list").attr("innerHTML", "<p>no plans - err</p>").animate({ height: 'show', opacity: 'show' }, 'slow');
        }
        }

            });
        });
        */
        ///////////////////////////////////////


        //submit project to line manager
        //top menu
        $('.go-submit').click(function() {
            Boxy.confirm("Your Project will be locked until reviewed by your line manager<br /><br />Please confirm:", function() { SubmitToManager(); }, { title: 'Submit Project to Line Manager?' });
            return false;
        });

        $('#go-delete').click(function() {
            Boxy.confirm("Your Project will be <b>deleted!</b><br /><br />Please confirm that you wish to delete this project:", function() { DeleteProject(); }, { title: 'Delete Project?' });
            return false;
        });

        /////
        $("#go-exit").click(function() {
            Boxy.confirm("Please confirm:", function() { location.href = "default.aspx"; }, { title: 'Exit this project?' });
            return false;
        });


        //////////////////////////////////////////////////////////
        //other budget
        $(".budget-edit").click(function() {
            if ($("#div-budget-label").is(":hidden") == false) {
                $("#div-budget-label").animate({ height: 'hide', opacity: 'hide' }, 'slow');
                $("#div-budget-text").animate({ height: 'show', opacity: 'show' }, 'slow');
            }
            else {
                $("#div-budget-label").animate({ height: 'show', opacity: 'show' }, 'slow');
                $("#div-budget-text").animate({ height: 'hide', opacity: 'hide' }, 'slow');
            }
        });
        $(".eval-edit").click(function() {
            if ($("#div-eval-label").is(":hidden") == false) {
                $("#div-eval-label").animate({ height: 'hide', opacity: 'hide' }, 'slow');
                $("#div-eval-text").animate({ height: 'show', opacity: 'show' }, 'slow');
            }
            else {
                $("#div-eval-label").animate({ height: 'show', opacity: 'show' }, 'slow');
                $("#div-eval-text").animate({ height: 'hide', opacity: 'hide' }, 'slow');
            }
        });
        //desc dide
        $(".desc-edit").click(function() {
            if ($("#div-desc-label").is(":hidden") == false) {
                $("#div-desc-label").animate({ height: 'hide', opacity: 'hide' }, 'slow');
                $("#div-desc-text").animate({ height: 'show', opacity: 'show' }, 'slow');
                //var myID = $("[id$=planDescription]").attr("id");

                //new nicEditor({ buttonList: ['bold', 'italic', 'indent', 'outdent', 'ol', 'left', 'center', 'right'] }).panelInstance(myID);
                //nicEditors.allTextAreas();
            }
            else {
                $("#div-desc-label").animate({ height: 'show', opacity: 'show' }, 'slow');
                $("#div-desc-text").animate({ height: 'hide', opacity: 'hide' }, 'slow');
            }
        });


        ////////////////////////////////////////
        //other eval
        $(".other-eval-edit").click(function() {
            if ($("#other-desc-label").is(":hidden") == false) {
                $("#other-desc-label").animate({ height: 'hide', opacity: 'hide' }, 'slow');
                $("#div-other-eval").animate({ height: 'show', opacity: 'show' }, 'slow');
            }
            else {
                $("#other-desc-label").animate({ height: 'show', opacity: 'show' }, 'slow');
                $("#div-other-eval").animate({ height: 'hide', opacity: 'hide' }, 'slow');
            }
        });
        //////////////////////////////////////////////////
        $(".helptitle").click(function() {
            if ($(this).next().is(":hidden") == true) {
                $(this).next().animate({ height: 'show', opacity: 'show' }, 'slow');
            }
            else {
                $(this).next().animate({ height: 'hide', opacity: 'hide' }, 'fast');
            }
        });

        //priority - text
        $("#priority-title").click(function() {
            if ($("#priority-text").is(":hidden") == false) {
                $("#priority-text").animate({ height: 'hide', opacity: 'hide' }, 'fast');
            }
            else {
                $("#priority-text").animate({ height: 'show', opacity: 'show' }, 'slow');
            }
        });

        //eval info
        $("#eval-info-head").click(function() {
            if ($("#eval-info-text").is(":hidden") == false) {
                $("#eval-info-text").animate({ height: 'hide', opacity: 'hide' }, 'fast');
            }
            else {
                $("#eval-info-text").animate({ height: 'show', opacity: 'show' }, 'slow');
            }
        });
        //ajax save stuff
        //first generic
        $(".save-control").click(function() {

            $find('PleaseWaitPopup').show();
            var idtosave = $(this).attr("id").slice(0, $(this).attr("id").lastIndexOf('-'));

            var projID = $("[id$=PlanID]").attr("value");
            //alert(projID);
            var name = GetVal(idtosave, "chkbox");
            //alert(Left(name, 5)); //return false;
            if (Left(name, 5) == 'style' || Left(name, 2) == '""') { name = ''; }
            //alert(name);
            var mydata = { params: name, dowhat: idtosave, projectid: projID };

            if (!DoAjaxJQ(mydata)) { alert('error in jquery call to ajax.aspx'); }
        });

        //media upload
        $(".media-edit").click(function() {
            if ($("#media-upload").is(":hidden") == false) {
                $("#media-upload-edit").animate({ height: 'hide', opacity: 'hide' }, 'slow');
                $("#media-upload").animate({ height: 'show', opacity: 'show' }, 'slow');
            }
            else {
                $("#media-upload").animate({ height: 'show', opacity: 'show' }, 'slow');
                $("#media-upload-edit").animate({ height: 'hide', opacity: 'hide' }, 'slow');
            }
        });


        // dates & project type
        $(".dateproject").click(function() {
            $find('PleaseWaitPopup').show();
            var projID = $("[id$=PlanID]").attr("value");
            var date = new Date(); var timestamp = date.getTime();

            var idtosave = "startDate";
            var name = GetVal(idtosave, "datetime");
            var mydata = { params: name, dowhat: idtosave, projectid: projID, randtime: timestamp };
            if (!DoAjaxJQ(mydata)) { alert('error in jquery call to ajax.aspx'); }


            var idtosave = "endDate";
            var name = GetVal(idtosave, "datetime");
            var mydata = { params: name, dowhat: idtosave, projectid: projID, randtime: timestamp };
            if (!DoAjaxJQ(mydata)) { alert('error in jquery call to ajax.aspx'); }

            var idtosave = "projectType";
            var name = GetVal(idtosave, "datetime");
            var mydata = { params: name, dowhat: idtosave, projectid: projID, randtime: timestamp };
            if (!DoAjaxJQ(mydata)) { alert('error in jquery call to ajax.aspx'); }

        });

        // Estimated Attendees & Age Range
        $(".attendeeage").click(function() {
            $find('PleaseWaitPopup').show();
            var projID = $("[id$=PlanID]").attr("value");
            var date = new Date(); var timestamp = date.getTime();
            var estMaleAtt;
            var estFemaleAtt;

            var idtosave = "estMaleAtt";
            var estMaleAtt = GetVal(idtosave, "datetime");
            var mydata = { params: estMaleAtt, dowhat: idtosave, projectid: projID, randtime: timestamp };
            if (!DoAjaxJQ(mydata)) { alert('error in jquery call to ajax.aspx'); }

            var idtosave = "estFemaleAtt";
            var estFemaleAtt = GetVal(idtosave, "datetime");
            var mydata = { params: estFemaleAtt, dowhat: idtosave, projectid: projID, randtime: timestamp };
            if (!DoAjaxJQ(mydata)) { alert('error in jquery call to ajax.aspx'); }

            var idtosave = "ageRangeMale";
            var name = GetVal(idtosave, "chkbox");
            if (Left(name, 5) == 'style' || Left(name, 2) == '""') { name = ''; }
            //check to see if estMaleAtt is > 0
            if (estMaleAtt > 0 && name == '') {
                Boxy.alert('Please enter an age range', null, { title: 'Missing Field' });
                return false;
            }
            var mydata = { params: name, dowhat: idtosave, projectid: projID, randtime: timestamp };
            if (!DoAjaxJQ(mydata)) { alert('error in jquery call to ajax.aspx'); }

            var idtosave = "ageRangeFemale";
            var name = GetVal(idtosave, "chkbox");
            if (Left(name, 5) == 'style' || Left(name, 2) == '""') { name = ''; }
            //check to see if estFemaleAtt is > 0
            if (estFemaleAtt > 0 && name == '') {
                Boxy.alert('Please enter an age range', null, { title: 'Missing Field' });
                return false;
            }
            var mydata = { params: name, dowhat: idtosave, projectid: projID, randtime: timestamp };
            if (!DoAjaxJQ(mydata)) { alert('error in jquery call to ajax.aspx'); }

        });




    });
}

function GetVal(idtosave, datatype) {
    switch (datatype)
    {
        case "datetime":
            var name = $("[id$=" + idtosave + "]").attr("value");
            break;
        case "chkbox":
            var name = $("[id$=" + idtosave + "]").attr("innerHTML");
            name = name.slice(0, name.lastIndexOf("name"));
            name = name.slice(name.lastIndexOf("value=") + 6, name.length);
            break;
        default:
            var name = "error - nor data type in jquery";
            break; 
    } 
    return name;
}

function DoAjaxJQ(mydata) {
    //Boxy.alert('mmm', null, { title: 'Message' });
    
    var IsSuccess = true;
    
    $.ajax({
        type: "GET",
        url: "ajax/ajax.aspx",
        data: mydata,
        error: function(msg) {
            alert("error: " + msg);
            IsSuccess = false;
        },
        success: function(response) {
            if (response != "") {
                alert(response);
            }
            else {
                $find('PleaseWaitPopup').hide();
                
            }
        }

    });
    return IsSuccess;
}
function SubmitToManager() { //update project status
    //alert('OK');
    var projID = $("[id$=PlanID]").attr("value");
    var statID = $("[id$=ProjectStatusHiddenField]").attr("value");
    
    var date = new Date(); var timestamp = date.getTime();
    var mydata = { dowhat: "submitToManager", projectid: projID, statusid: statID, randTime: timestamp};
    $.ajax({
        type: "GET",
        url: "ajax/ajax.aspx",
        data: mydata,
        error: function(msg) {
            alert("error: " + msg);
        },
        success: function(response) {

            if (response != "") {
                Boxy.alert(response, null, { title: 'Message' });
            }
            else {
                location.href = "default.aspx?msg=plan_submitted";
            }
        }
    });
}

function DeleteProject() {
    var projID = $("[id$=PlanID]").attr("value");
    var date = new Date(); var timestamp = date.getTime();
    var mydata = { dowhat: "deleteProject", projectid: projID, randTime: timestamp };
    
    $.ajax({
        type: "GET",
        url: "ajax/ajax.aspx",
        data: mydata,
        error: function(msg) {
            alert("error: " + msg);
        },
        success: function(response) {

            if (response != "") {
                Boxy.alert(response, null, { title: 'Message' });
            }
            else {
                location.href = "default.aspx?msg=plan_deleted";
            }
        }

    });
}


function trim(stringToTrim) {
    return stringToTrim.replace(/^\s+|\s+$/g, "");
}

function ListPlans(yearToShow) {
   
    var date = new Date(); var timestamp = date.getTime();
    
    var startdate = '01 Apr ' + yearToShow;
    var enddate = '31 Mar ' + (yearToShow + 1);
    var mydata = { dowhat: "listPlans", startdate: startdate, enddate: enddate, randomTime: timestamp };

    $.ajax({
        type: "GET",
        url: "ajax/ajax.aspx",
        data: mydata,
        error: function(msg) {
            alert("error: " + msg);
        },
        success: function(response) {

            if (response != "") {
                if (trim(response) == "X") {
                    location.href = "login.aspx?msg=sessionend";
                }
                else {
                    var responseTitle = "<div>Project plans for " + yearToShow + " / " + (yearToShow + 1) + "</div>";
                    $("[id$=WelcomeLabel]").attr("innerHTML", responseTitle);
                    $("#plan-list").attr("innerHTML", response).show();
                    
                }
            }
            else {
                $("#plan-list").attr("innerHTML", "<p>no plans - err</p>").show();
            }
        }

    });
}
function ShowYearSelect(whatType) {
    var selectDiv = "#" + ((whatType == 'html') ? 'yearforplanHTML' : 'yearforplan');
   // alert(selectDiv);
    var date = new Date(); var timestamp = date.getTime();
    var mydata = { dowhat: "showyearselect", selectType: whatType,  randomTime: timestamp };

    $.ajax({
        type: "GET",
        url: "ajax/ajax.aspx",
        data: mydata,
        error: function(msg) {
            alert("error: " + msg);
        },
        success: function(response) {

            if (response != "") {
                if (trim(response) == "X") {
                    location.href = "login.aspx?msg=sessionend";
                }
                else {
                    $(selectDiv).attr("innerHTML", response).show();
                }
            }
            else {
                $(selectDiv).attr("innerHTML", "<p>no plans - err</p>").show();
            }
        }

    });
}
function Left(str, n) {
    if (n <= 0)
        return "";
    else if (n > String(str).length)
        return str;
    else
        return String(str).substring(0, n);
}
//popluate resorce list on eval page
function ShowResourceForEval() {
    //alert('');
    var projID = $("[id$=PlanID]").attr("value");
    
    var date = new Date(); var timestamp = date.getTime();
    var mydata = { projID: projID, dowhat: "ShowResource", randomDate: timestamp };
    $.ajax({
        type: "GET",
        url: "ajax/ajax.aspx",
        data: mydata,
        error: function(msg) {
            alert("error: " + msg);
            IsSuccess = false;
        },
        success: function(response) {
            if (response != "") {
    
                $("#content-right").attr("innerHTML", response);
            }
            else {
                $("#content-right").attr("innerHTML", "no project resources");
            }
        }

    });
}
// function to handle on change firing from budget admin generated code
function LoadAjaxJqery(budgetID) {


    //admin - set status
    $(".admin-selected").change(function() {
        //alert($(this).val() + ' | ' + $(this).attr("name") + ' ' + budgetID);
        //return false;
        var planID = $(this).attr("name");
        var statusID = $(this).val();
        var date = new Date(); var timestamp = date.getTime();
        var mydata = { dowhat: "changeAdminStatus", planID: planID, statusID: statusID, randomTime: timestamp };

        $.ajax({
            type: "GET",
            url: "ajax/ajax.aspx",
            data: mydata,
            error: function(msg) {
                alert("error: " + msg);
            },
            success: function(response) {
                if (response != "") {
                    Boxy.alert(response, null, { title: 'Message' });
                }
                else {
                    ShowListForBudget(budgetID);
                    //location.href = "adminbudget.aspx";
                }
            }

        });

    });
}


function ShowListForBudget(managerID) {

    var date = new Date(); var timestamp = date.getTime();
    var mydata = { dowhat: "ListForAdminByManager", managerID: managerID, randomTime: timestamp };
    $.ajax({
        type: "GET",
        url: "ajax/ajax.aspx",
        data: mydata,
        error: function(msg) {
            alert("error: " + msg);
        },
        success: function(response) {
            if (response != "") {

                $("#admin-budget").attr("innerHTML", response);
                LoadAjaxJqery(managerID); // handles events from generated code
            }
            else {
                $("#admin-budget").attr("innerHTML", 'No plans found for this manager');
            }
        }

    });
}



//is mumeric fubction
function CheckNumericKeyInfo($char, $mozChar) {
    // alert('keyCode: ' + $mozChar);
    if ($mozChar != null) { // Look for a Mozilla-compatible browser
        if (($mozChar >= 48 && $mozChar <= 57) || $mozChar == 0 || $char == 8 || $mozChar == 13) $RetVal = true;
        else {
            $RetVal = false;
            //alert('Please enter a numeric value.');
        }
    }
    else { // Must be an IE-compatible Browser
        if (($char >= 48 && $char <= 57) || $char == 13) $RetVal = true;
        else {
            $RetVal = false;
            //alert('Please enter a numeric value.');
        }
    }
    return $RetVal;
}
function ShowMediaEditButton(msg) {
    //alert(msg);
    document.getElementById("media-upload").style.display = 'none';
    document.getElementById("media-upload-edit").style.display = 'block';
    document.getElementById("media-edit-msg").innerHTML = msg;

}