﻿/***************************\
* Greybox Related Functions *
\***************************/
var GB_ROOT_DIR = '/js/greybox/';
var curID = '';

function CloseGB()
{
    GB_hide();
}

function CloseGBandPost()
{
    GB_hide();

    // based on which button was clicked
    if (curID == '')
        alert('Unknown error. Please try again.');
    else
        causePostback(curID);
}

function causePostback(id)
{
    eval(unescape(document.getElementById(id).href));
}
/*******************************\
* End Greybox Related Functions *
\*******************************/

/****************************\
* Calendar Related Functions *
\****************************/
function createDatePicker(id)
{
    $('#' + id).css('margin-right', '3px');
    $('#' + id).datepicker(
            {
                showOn: 'button',
                buttonImage: '/images/calendar/calendar.jpg',
                buttonImageOnly: true,
                changeMonth: true,
                changeYear: true,
                showButtonPanel: true,
                currentText: 'Go To Today',
                closeText: 'Close',
                yearRange: '-1:+10'
            });
}

function createDatePickers()
{
    $('.date').css('margin-right', '3px');
    $('.date').datepicker(
    {
        showOn: 'button',
        buttonImage: '/images/calendar/calendar.jpg',
        buttonImageOnly: true,
        changeMonth: true,
        changeYear: true,
        showButtonPanel: true,
        currentText: 'Go To Today',
        closeText: 'Close',
        yearRange: '-1:+10'
    });
}
/********************************\
* End Calendar Related Functions *
\********************************/



// custom show/hide function to show images inpage... so they do not take up as much space
function imgMouseOver(id)
{
    // used in the function below
    var iImgHeight = 100;

    $(document).ready(function()
    {
        // make sure we even need to do anything with the image (it could be small enough that it will be "sized up")
        if ($('#' + id).attr('width') > iImgHeight)
        {

            // save the width of the image
            $('#' + id).data('width', ($('#' + id).attr('width') < 650) ? $('#' + id).attr('width') : 650);

            // set the mouseover action to display full size
            $('#' + id).mouseenter(
                    function(e)
                    {
                        // set the Animation boolean
                        if (!$('#' + id).data('bAnimate'))
                        {
                            $('#' + id).data('bAnimate', true);
                            $('#' + id).animate({ width: $('#' + id).data('width') }, 500);
                        }
                    });

            // set the mouseout action to shrink to 100px
            $('#' + id).mouseleave(
			        function()
			        {
			            $('#' + id).animate({ width: iImgHeight + 'px' }, 500, 'linear', function()
			            {
			                $('#' + id).data('bAnimate', false);
			            });
			        });

            // init image to 100px, add hand cursor, and make relative
            $('#' + id).css({ 'position': 'absolute', 'cursor': 'hand', 'cursor': 'pointer', 'width': '100px', 'top': '0', 'left': '0', 'z-index': '900' });

            // make the image parent a relative positioned element and put a place holder under the image with the same height and width
            $('#' + id).parent().css('position', 'relative');
            $('#' + id).before('<div style="position:relative;width:100px;height:' + $('#' + id).height() + 'px;">&nbsp;</div>');
        }
    });
}  
