﻿$(document).ready(function () {
    $("html").css("background", "#B1CA2F");
});

$(document).ready(function () {
    $('#faqbox').hide();
    $('a.faq').click(function () {
        var id = $(this).attr('id');
        $('#faqbox' + id).slideToggle(500);
        return false;
    });
});

$(document).ready(function () {
    $('#topmenu > div > .AspNet-Menu-Horizontal > .AspNet-Menu > li:last').addClass('infomenulastitem');
});


if (document.documentElement.attachEvent)
    document.documentElement.attachEvent('onmousedown', function() { event.srcElement.hideFocus = true });

function setSize() {
    var content = document.getElementById('leftmenu').offsetHeight;
    var leftmenu = document.getElementById('content_page').offsetHeight;
    var infobox = document.getElementById('infobox').offsetHeight;

    //alert(leftmenu + "px");

//    pageHeight = parseInt(window.innerHeight ? window.innerHeight : document.body.offsetHeight);
//    pageWidth = parseInt(window.innerWidth ? window.innerWidth : document.body.offsetWidth);

//    if (parseInt(navigator.appVersion) > 3) {
//        if (navigator.appName == "Netscape") {
//            pageHeight = pageHeight - 131;
//        }
//        if (navigator.appName.indexOf("Microsoft") != -1) {
//            pageHeight = pageHeight - 131;
//            pageWidth = pageWidth - 2; //IE6
//        }
//    }
//    document.getElementById('contenttxt').style.width = pageWidth + 'px';

//    document.getElementById('contenttxt').style.height = pageHeight + 'px';
//    document.getElementById('buttom').style.display = 'block';

}

//CENTER MENU
//$(document).ready(function() {
//    var width = 0;
//    $('ul.AspNet-Menu > li').each(function() {
//        width += $(this).width();
//    });
//    $('.topmenu').width(width);
//});



var sePayWinTimeStamp;
var iePayWinTimerStarted = 0;
var epaywin;
var iePayWinAmount = 0;
var iPstart = 1;

function ePayShow(ePaySettings) {

    var ePayForm = document.createElement("form");
    ePayForm.setAttribute("id", "ePay");
    ePayForm.setAttribute("name", "ePay");
    ePayForm.setAttribute("method", "post");
    ePayForm.setAttribute("action", "https://ssl.ditonlinebetalingssystem.dk/popup/default.asp");
    ePayForm.target = "ePay_window";

    for (ePaySetting in ePaySettings) {
        var ePayHidden = document.createElement("input");
        ePayHidden.setAttribute("type", "hidden");
        ePayHidden.setAttribute("name", ePaySetting);
        ePayHidden.setAttribute("value", ePaySettings[ePaySetting]);
        ePayForm.appendChild(ePayHidden);
    }

    var ePayDiv = document.getElementById('ePayDiv');

    if (ePayDiv) {
        ePayDiv.innerHTML = "";
    }
    else {
        ePayDiv = document.createElement("div");
        ePayDiv.setAttribute("id", "ePayDiv");
    }

    ePayDiv.style.display = 'none';
    ePayDiv.appendChild(ePayForm);
    document.body.appendChild(ePayDiv);

    epaywin = window.open("", "ePay_window", "height=600,width=525,menubar=0,resizable=1,scrollbars=1,status=1,titlebar=0,toolbar=0,left=100,top=50");

    if (epaywin) epaywin.focus();

    startePayTimer(ePayForm);

    ePayForm.submit();
}

function startePayTimer(oForm) {
    try {
        if (iePayWinTimerStarted == "0") {
            var objDate = new Date();
            sePayWinTimeStamp = objDate.getFullYear() + "" + (objDate.getMonth() + 1) + "" + objDate.getDate() + "" + objDate.getHours() + "" + objDate.getMinutes() + "" + objDate.getMilliseconds();

            var objNewElement = document.createElement("INPUT");
            objNewElement.type = "hidden";
            objNewElement.name = "_epay_timestamp";
            objNewElement.value = sePayWinTimeStamp;
            oForm.appendChild(objNewElement);

            iePayWinTimerStarted = 1;

            if (oForm.amount.length) {
                for (n = 0; n < oForm.amount.length; n++) {
                    if (oForm.amount[n].checked) {
                        iePayWinAmount = oForm.amount[n].value;
                        break;
                    }
                }
            }
            else
                iePayWinAmount = oForm.amount.value;


            setTimeout("pollTransaction()", 8000)
        }
    }
    catch (err) {
        //error
    }
}

function pollTransaction() {
    var objForm = document.getElementById("ePay");
    var sOrderID = "";
    var sDeclineURL = "";

    if (objForm) {
        try {
            var iWindowClosed = 0;

            if (epaywin.closed)
                iWindowClosed = 1;

            if (objForm.orderid)
                sOrderID = escape(objForm.orderid.value);

            if (objForm.declineurl)
                sDeclineURL = escape(objForm.declineurl.value);

            var objPoll = document.createElement("script");
            objPoll.type = "text/javascript";
            objPoll.src = "https://ssl.ditonlinebetalingssystem.dk/popup/pollaccept.asp?merchantnumber=" + escape(objForm.merchantnumber.value) + "&orderid=" + sOrderID + "&timestamp=" + escape(sePayWinTimeStamp) + "&amount=" + escape(iePayWinAmount) + "&wclosed=" + escape(iWindowClosed) + "&st=" + iPstart + "&durl=" + sDeclineURL;
            document.body.appendChild(objPoll);
            setTimeout("pollTransaction()", 5000);
            iPstart = 0;
        }
        catch (err) {
            //error

        }
    }
}

