﻿function ClickButton(event, focusControl)
{
    event = event || window.event;

    var keyCode = null;

    if( event.which )
    {
        keyCode = event.which;
    }
    else if( event.keyCode )
    {
        keyCode = event.keyCode;
    }

    if( 13 == keyCode )
    {
        document.getElementById(focusControl).focus();
        return false;
    }

    return true;
}

function IsIE()
{
    var agt=navigator.userAgent.toLowerCase();

    if (agt.indexOf("msie") != -1)
        return true;

    return false;
}

function textMaxLength(obj, maxLength, evt)
{
    var charCode=(evt.which) ? evt.which : event.keyCode
    var max = maxLength - 0;
    var text = obj.value;

    if(text.length > max)
    {
        var ignoreKeys = [8,46,37,38,39,40,35,36];
    
        for(i=0;i<ignoreKeys.length;i++)
        {
            if(charCode==ignoreKeys[i])
            {
                return true;
            }
        }

        return false;
    }
    else
    {
        return true;
    }
}

function popUp(URL, id, ieWidth,ieHeight,ffWidth, ffHeight) 
{
	// default width and height to ff
	
	var width   = ffWidth;
	var height  = ffHeight;
	
	if (navigator.appName == "Microsoft Internet Explorer")
	{                   
		width = ieWidth;
		height = ieHeight;
	}                        
	
	var left    = (screen.width - width) / 2;
	var top     = (screen.height - height) / 2;
	
	window.open(URL, id, 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=' + width + ',height=' + height + ',left = ' + left +',top = ' + top + '');
}
