﻿$(document).ready(function() {
    initButtons();
    animateMenu();
    checkQuery();
});

function initButtons() {
    $('#showMore').click(function() {
        $('#text').slideToggle("slow");
        $('html, body').animate({ scrollTop: $('body').height() }, 300);
    });

    $('#contentMenu a').click(function() {
        var itemClass = $(this).attr("class");
        if (itemClass.length != 0) {
            $('#contentSubMenu div').slideUp("slow", function() {
            });
            $('#' + itemClass).slideDown("slow");
        }
    });

    $("#mailSubscription").focus(function() {
        $(this).attr("value","");
    });

    $("#mailSubscription").attr("value", "email@address");
}

function animateMenu() {
    $('#contentMenu').slideDown("slow");
}

function checkQuery() {

    if ($("#activationGuid").length != 0) {
        var guid = $("#activationGuid").val();
        if (guid != "") {
            openWindow("newsletter.aspx?guid=" + guid, "700", "230");
        }
    }

    if ($("#mailAddress").length != 0) {
        var mail = $("#mailAddress").val();
        if (mail != "") {
            openWindow("newsletter.aspx?mail=" + mail, "700", "230");
        }
    }
}

function mailConfirmation() {
    openWindow("confirmation.aspx", "500", "300");
}

// ************************************************** //

function openWindow(winUrl, winWidth, winHeight) {
    tb_show("", winUrl + "&keepThis=true&TB_iframe=true&height=" + winHeight + "&width=" + winWidth, "");
}

function setIndex(indx) {
    $("#index").attr("value",indx);
}
