/**
 * Submit a form from a input field.
 * EG:
 *   <input name="test" type="text" size=10 onKeyPress="return submitEnter(this)">
 *
 * @param DomElement form
 * @return boolen
 */
function submitEnter(form)
{

    var keycode;
    if (window.event) {
        keycode = window.event.keyCode;
    } else if (e) {
        keycode = e.which;
    } else {
        return true;
    }
    if (keycode == 13)
    {
        form.submit();
        return false;
    } else {
        return true;
    }
}

/**
 *  Popup window.
 *
 * @param string url - The url to show in the popup window
 * @param integer width - (optional) The width in pixels
 * @param integer height - (optional) The height in pixels
 * @param string scrollbars - (optional) 'yes'/'no' values
 * @param string targetName - (optional) Changes the target name of the window, use this for sub popups.
 * @param string modal - (optional) 'yes'/'no' values,  yes give the popup a modal dialog box effect.
 */
var __popupWin = null;

function popup(url)
{
    var width = arguments[1] ? arguments[1] : 455;
    var height = arguments[2] ? arguments[2] : 500;
    var scrollbars = arguments[3] ? arguments[3] : 'yes';
    var resizable = arguments[4] ? arguments[4] : 'yes';
    var targetName = arguments[5] ? arguments[5] : 'info';
    var modal = arguments[6] ? arguments[6] : 'no';

    var LeftPosition = 0;
    var TopPosition = 0;

    if (__popupWin != null && !__popupWin.closed) {
        __popupWin.close();
    }

    try {
        if(window.opener){
            LeftPosition =(window.opener.innerWidth-width) / 2;
            TopPosition =((window.opener.innerHeight-height)/2) + 60;
        } else if(window.innerWidth) {
            LeftPosition =(window.innerWidth-width) / 2;
            TopPosition =((window.innerHeight-height)/2) + 60;
        } else {
            LeftPosition =(parseInt(window.screen.width) - width)/2;
            TopPosition=((parseInt(window.screen.height) - height)/2) + 60;
        }
    } catch(e) {}

    __popupWin = window.open(url,targetName,'scrollbars='+scrollbars+',width='+width+
        ',height='+height+',resizable='+resizable+',left=' + LeftPosition +
        ',top=' + TopPosition+',modal='+modal);

    if (window.focus) {
        __popupWin.focus();
    }
    return __popupWin;
}

/**
 * Submit a form once only, used for submitting a payment form.
 * Put a call to this function in an onSubmit event on a form.
 *
 * @param DOMElement btn -
 */
var __wasSubmitted = false;
function submitOnce(btn)
{
    if (wasSubmitted == true) {
        alert("Request already submitted, please wait....");
     } else {
        btn.className = 'btn_disable';
        btn.blur();
        wasSubmitted = true;
     }
}


function Image_preloadArray()
{
}