﻿var one_day = 1000 * 60 * 60 * 24
var m_names = new Array("January", "February", "March",
"April", "May", "June", "July", "August", "September",
"October", "November", "December");

var Database_Min_Date = new Date().setFullYear(1753, 1, 1);

$(function() {
    $('#loading').hide();
    $('#error').hide();

    //load the grid when the document loads. this code will run only once
    //hook on to the click events of all pagination
    //related links, and when clicked load the updated grid through AJAX
    //this will zero in on the needed <a> elements in the Grid

    //Add table row hightlight when hovering on it.
//    $("table.autoHighlight tr")
//        .live("mouseover", function(event) {
//            $("table.autoHighlight tr").removeClass("hover");
//            $(this).addClass("hover");
//        });
//    $("table.autoHighlight tr")
//        .live("mouseout", function(event) {
//            $(this).removeClass("hover");
//        });
});

function confirmAction() {
    return confirm("Are you sure?");
}

function handleAjaxBegin() {
    hideError();
    showLoading();
}
function handleAjaxComplete() {
    hideLoading();
    hideError();
}
function handleAjaxSuccess() {
    hideLoading();
    hideError();
}
function handleAjaxError() {
    hideLoading();
    showError();
}

function handleMessageAutoClose() {
    $.timer(2000, function() {
        if ($('#messageAutoClose').val() == 'true') {
            $.modal.close();
        }
    });
}

function showLoading() {
    //Get the window height and width  
    var winH = $(window).height();  
    var winW = $(window).width();  

    //Set the popup window to center
    $('#loading').css('top', winH / 2 - $('#loading').height() / 2);
    $('#loading').css('left', winW / 2 - $('#loading').width() / 2);  

    //transition effect
    $('#loading').show();
}
function hideLoading() {
    $('#loading').hide();
}
function showError() {
    $('#error').fadeIn();
}
function hideError() {
    $('#error').fadeOut();
}


(function($) {
    $.fn.ToNumericControl = function() {
        return this.keydown(function(e) {
            var evt = e || window.event;

            if (e.keyCode == 46 || e.keyCode == 8 || e.keyCode == 9 || e.keyCode >= 33 && e.keyCode <= 40)
                return true;

            if (e.shiftKey) return false;
            
            if (e.keyCode >= 48 && e.keyCode <= 57 || e.keyCode >= 96 && e.keyCode <= 105) {
                return true;
            }
            else {
                return false;
            }
        });
    }
})(jQuery);



(function($) {
    $.fn.ToNumericControlWithDash = function() {
        return this.keydown(function(e) {
            var evt = e || window.event;
            if (e.keyCode == 46 || e.keyCode == 8 || e.keyCode == 9 || e.keyCode >= 33 && e.keyCode <= 40)
                return true;

            if (e.shiftKey) return false;

            if (e.keyCode >= 48 && e.keyCode <= 57 || e.keyCode >= 96 && e.keyCode <= 105 || e.keyCode == 109) {
                return true;
            }
            else {
                return false;
            }
        });
    }
})(jQuery);


function InitPhotoGallery() {
}
