﻿// -----------------------------------------------------------------
// deklarations
// -----------------------------------------------------------------

var NS_URL = '/pages/PopupVPos.aspx';
var NS_PROGRESS = '#ProgressInfo';
var NI_TIMEOUT = 1000;
var _button;

// -----------------------------------------------------------------
// functions
// -----------------------------------------------------------------

function VPosConnect(p) {
    // hide progress
    var o = $(NS_PROGRESS);
    if (o) o.css('display','none');

    // enable go button again
    VPosSetButton(true);

    // show popup
    //return cu_CustomPopup("Virtual pos", NS_URL + '?' + p, 750, 550);
    return cu_generatePopup("vposPopup", NS_URL + '?' + p, 750, 550, "VPOS - Raiffeisen Payment Gateway ");
}

function VPosShow(b, p) {
    // disable go button
    _button =$("#"+b);

    // disable button
    VPosSetButton(false);

    // show popup with delay
    window.setTimeout("VPosConnect('" + p + "')", NI_TIMEOUT);
}

function VPosSetButton(enabled) {
    // get button
    if (_button) _button.disabled = !enabled;
}

function VPosStart(name) {
    var o = MM_findObj(name);
    if (o) o.submit();
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}


function VPosPrintWindow() {
    window.print();
}
