function getRandom()
{
    var ranNum= Math.round(Math.random()*100);
    return ranNum;
}

function newWin(imgSrc,imgWidth,imgHeight)
{
    width  = imgWidth + 20;
    height = imgHeight+ 50;
    var leftPos = Math.floor( (screen.width - width) / 2);
    var topPos = Math.floor( (screen.height - height) / 2);
    var params = "\"top="+topPos+",left="+leftPos+",width="+width+",height="+height;
    var openWin = window.open(imgSrc, "", params+", location=no, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes");
    openWin.resizeTo(width,height);
    openWin.focus();
}



function choose(choice)
{
    if (document.getElementById('selected_amount'))
        document.getElementById('selected_amount').value = choice.value;
}


function processTransaction()
{
    selMoney = document.getElementById('selected_amount').value;

    if (selMoney == "NULL")
    {
        alert("You must choose the unit pack");
        return false;
    }

    document.getElementById('returnURL').value = document.getElementById('default_unit_return').value;
    document.orderForm.action="https://www.paypal.com/cgi-bin/webscr";
}


function processTimeTransaction()
{
    selMoney = document.getElementById('selected_amount').value;

    if (selMoney == "NULL")
    {
        alert("You must choose the time pack");
        return false;
    }

    document.getElementById('returnURL').value = document.getElementById('default_time_return').value;

    // To disable PayPal comment out here
    document.orderForm.action="https://www.paypal.com/cgi-bin/webscr";
    // and enable that
    //document.orderForm.action=document.getElementById('test').value + "&mc_gross=100.00&txn_id=1";
    
}



function HpbImgPreload()
{
    var appVer=parseInt(navigator.appVersion);
    var isNC=false,isN6=false,isIE=false;
    if (document.all && appVer >= 4) isIE=true;
    else
        if (document.getElementById && appVer > 4) isN6=true;
    else
        if (document.layers && appVer >= 4) isNC=true;
    if (isNC||isN6||isIE) {
        if (document.images) {
            var imgName = HpbImgPreload.arguments[0];
            var cnt;
            swImg[imgName] = new Array;
            for (cnt = 1; cnt < HpbImgPreload.arguments.length; cnt++) {
                swImg[imgName][HpbImgPreload.arguments[cnt]] = new Image();
                swImg[imgName][HpbImgPreload.arguments[cnt]].src = HpbImgPreload.arguments[cnt];
            }
        }
    }
}


function HpbImgFind(doc, imgName)
{
    for (var i=0; i < doc.layers.length; i++) {
        var img = doc.layers[i].document.images[imgName];
        if (!img) img = HpbImgFind(doc.layers[i], imgName);
        if (img) return img;
    }
    return null;
}


function HpbImgSwap(imgName, imgSrc)
{
    var appVer=parseInt(navigator.appVersion);
    var isNC=false,isN6=false,isIE=false;
    if (document.all && appVer >= 4) isIE=true;
    else
        if (document.getElementById && appVer > 4) isN6=true;
    else
        if (document.layers && appVer >= 4) isNC=true;
    if (isNC||isN6||isIE) {
        if (document.images) {
            var img = document.images[imgName];
            if (!img) img = HpbImgFind(document, imgName);
            if (img) img.src = imgSrc;
        }
    }
}

function _HpbJumpURL(url)
{
    if (url != '') {
        window.location = url;
    }
}

