var srcurl;
$(document).ready(function () {

    $('#email').click(function () {
        UpdateNewsletterStatus();
    });

    /* en-GB */
    $("a.showreg").live('click', function (e) {
        if (userLoggedIn) {

            return true;
        }

        e.preventDefault();
        $.fn.colorbox({ innerWidth: 400, href: "/EnglishUK/Account/LogOn", innerHeight: 220, iframe: true, opacity: 0.50, scrolling: false });
        return false;

    });

    $("a.flashPopUpReg").live('click', function (e) {
        if (userLoggedIn) {
            $.fn.colorbox({ innerWidth: 770, innerHeight: 730, href: "/content/uploaded/flash/tutorial/stuart_ralston/interface.swf", iframe: true, opacity: 0.50, scrolling: false });
            return false;
        }


        e.preventDefault();
        $.fn.colorbox({ innerWidth: 400, href: "/EnglishUK/Account/LogOn?ReturnUrl=/EnglishUK/Home/Education/", innerHeight: 220, iframe: true, opacity: 0.50, scrolling: false });
        return false;

    });
     
    $("a.flashPopUpRegCloseBone").live('click', function (e) {
        if (userLoggedIn) {
            $.fn.colorbox({ innerWidth: 770, innerHeight: 730, href: "/content/uploaded/flash/qotm/QOTM_C2_3.swf", iframe: true, opacity: 0.50, scrolling: false });
            return false;
        }


        e.preventDefault();
        $.fn.colorbox({ innerWidth: 400, href: "/EnglishUK/Account/LogOn?ReturnUrl=/EnglishUK/Home/Education/", innerHeight: 220, iframe: true, opacity: 0.50, scrolling: false });
        return false;

    });

    $("a.qotmPopupReg").live('click', function (e) {
        if (userLoggedIn) {
            $.fn.colorbox({ innerWidth: 770, innerHeight: 730, href: "/content/uploaded/flash/qotm/QOTM_C2_1v3.swf", iframe: true, opacity: 0.50, scrolling: false });
            return false;
        }

        e.preventDefault();
        $.fn.colorbox({ innerWidth: 400, href: "/EnglishUK/Account/LogOn?ReturnUrl=/EnglishUK/Home/Education/", innerHeight: 220, iframe: true, opacity: 0.50, scrolling: false });
        return false;

    });

    $("a.atlasPopupReg").live('click', function (e) {
        if (userLoggedIn) {
            return true;
        }

        e.preventDefault();
        $.fn.colorbox({ innerWidth: 400, href: "/EnglishUK/Account/LogOn?ReturnUrl=/EnglishUK/Home/Services", innerHeight: 220, iframe: true, opacity: 0.50, scrolling: false });
    });

    /* colorbox */
    $(".signIn").colorbox({ innerWidth: 400, innerHeight: 220, iframe: true, opacity: 0.50, scrolling: false });
    $(".signInPngButton").colorbox({ innerWidth: 400, innerHeight: 220, iframe: true, opacity: 0.50, scrolling: false });
    $(".NavSignIn").colorbox({ innerWidth: 400, innerHeight: 220, iframe: true, opacity: 0.50, scrolling: false });
    $(".forgottenPassword").colorbox({ innerWidth: 400, innerHeight: 225, iframe: true, opacity: 0.50, scrolling: false });
    $(".popup").colorbox({ innerWidth: "500px", innerHeight: "90%", iframe: true, opacity: 0.50, scrolling: true });
    $(".videoPopUp").colorbox({ innerWidth: "535px", innerHeight: 360, iframe: true, opacity: 0.50, scrolling: true });
    /* add my JQuery function for opening a new window (tutorial)*/
    $(".flashPopUp").colorbox({ innerWidth: 770, innerHeight: 730, iframe: true, opacity: 0.50, scrolling: true });
    $(".BerlinPopUp").colorbox({ innerWidth: "100%", innerHeight: "100%", iframe: true, opacity: 0.50, scrolling: true });
    $(".qotmPopup").colorbox({ innerWidth: 770, innerHeight: 730, iframe: true, opacity: 0.50, scrolling: true });

    /* es-ES */
    $("a.showregSpanish").live('click', function (e) {
        if (userLoggedIn) {

            return true;
        }

        e.preventDefault();
        $.fn.colorbox({ innerWidth: 400, href: "/Spanish/Account/LogOn", innerHeight: 220, iframe: true, opacity: 0.50, scrolling: false, close: "Cerrar" });
        return false;

    });

    $("a.flashPopUpRegSpanish").live('click', function (e) {
        if (userLoggedIn) {
            $.fn.colorbox({ innerWidth: 770, innerHeight: 730, href: "/content/uploaded/flash/tutorial/stuart_ralston/interface.swf", iframe: true, opacity: 0.50, scrolling: false, close: "Cerrar" });
            return false;
        }

        e.preventDefault();
        $.fn.colorbox({ innerWidth: 400, href: "/Spanish/Account/LogOn?ReturnUrl=/Spanish/Home/Education/", innerHeight: 220, iframe: true, opacity: 0.50, scrolling: false, close: "Cerrar" });
        return false;

    });

    $(".signInSpanish").colorbox({ innerWidth: 400, innerHeight: 220, iframe: true, opacity: 0.50, scrolling: false, close: "Cerrar" });
    $(".NavSignInSpanish").colorbox({ innerWidth: 400, innerHeight: 220, iframe: true, opacity: 0.50, scrolling: false, close: "Cerrar" });
    $(".forgottenPasswordSpanish").colorbox({ innerWidth: 400, innerHeight: 225, iframe: true, opacity: 0.50, scrolling: false, close: "Cerrar" });
    $(".popupSpanish").colorbox({ innerWidth: "500px", innerHeight: "90%", iframe: true, opacity: 0.50, scrolling: true, close: "Cerrar" });
    $(".videoPopUpSpanish").colorbox({ innerWidth: "535px", innerHeight: 360, iframe: true, opacity: 0.50, scrolling: true, close: "Cerrar" });
    $(".flashPopUpSpanish").colorbox({ innerWidth: 770, innerHeight: 730, iframe: true, opacity: 0.50, scrolling: true, close: "Cerrar" });
    $(".BerlinPopUpSpanish").colorbox({ innerWidth: "100%", innerHeight: "100%", iframe: true, opacity: 0.50, scrolling: true, close: "Cerrar" });

    /* de-DE */
    $("a.showregGerman").live('click', function (e) {
        if (userLoggedIn) {

            return true;
        }

        e.preventDefault();
        $.fn.colorbox({ innerWidth: 400, href: "/German/Account/LogOn", innerHeight: 220, iframe: true, opacity: 0.50, scrolling: false, close: "Close" });
        return false;

    });

    $("a.flashPopUpRegGerman").live('click', function (e) {
        if (userLoggedIn) {
            $.fn.colorbox({ innerWidth: 770, innerHeight: 730, href: "/content/uploaded/flash/tutorial/stuart_ralston/interface.swf", iframe: true, opacity: 0.50, scrolling: false, close: "Close" });
            return false;
        }

        e.preventDefault();
        $.fn.colorbox({ innerWidth: 400, href: "/German/Account/LogOn?ReturnUrl=/German/Home/Education/", innerHeight: 220, iframe: true, opacity: 0.50, scrolling: false, close: "Close" });
        return false;

    });

    $(".signInGerman").colorbox({ innerWidth: 400, innerHeight: 220, iframe: true, opacity: 0.50, scrolling: false, close: "Beenden" });
    $(".navSignInGerman").colorbox({ innerWidth: 400, innerHeight: 220, iframe: true, opacity: 0.50, scrolling: false, close: "Beenden" });
    $(".forgottenPasswordGerman").colorbox({ innerWidth: 400, innerHeight: 225, iframe: true, opacity: 0.50, scrolling: false, close: "Beenden" });
    $(".popupGerman").colorbox({ innerWidth: "500px", innerHeight: "90%", iframe: true, opacity: 0.50, scrolling: true, close: "Beenden" });
    $(".videoPopUpGerman").colorbox({ innerWidth: "535px", innerHeight: 360, iframe: true, opacity: 0.50, scrolling: true, close: "Beenden" });
    $(".videoPopUpGermanMedium").colorbox({ innerWidth: "1070px", innerHeight: 720, iframe: true, opacity: 0.50, scrolling: true, close: "Beenden" });
    $(".flashPopUpGerman").colorbox({ innerWidth: 770, innerHeight: 730, iframe: true, opacity: 0.50, scrolling: true, close: "Beenden" });
    $(".berlinPopUpGerman").colorbox({ innerWidth: "100%", innerHeight: "100%", iframe: true, opacity: 0.50, scrolling: true, close: "Beenden" });
});



function SubmitIMPForm()
{
    document.frmOsteoporosisOnline.submit();
}

$(document).ready(function()
{
    $("a.extern2").click(function()
    {
        srcurl = $(this).attr('href');
        //mywindow = window.open('/Home/Redirect', '_blank');


        $(".btn_forward").attr('href', srcurl);
        $(".btn_forward").attr('target', "_blank");

        $.fn.colorbox({ opacity: 0.50, inline: true, href: "#DvRedirectAlt", scrolling: false, close: false });
        return false;
    });

    /* colorbox */
    $(".signIn").colorbox({ innerWidth: 400, innerHeight: 220, iframe: true, opacity: 0.50, scrolling: false });
    $(".forgottenPassword").colorbox({ innerWidth: 400, innerHeight: 225, iframe: true, opacity: 0.50, scrolling: false });

});

$(document).ready(function () {
    $("a.extern3").click(function () {
        srcurl = $(this).attr('href');
        //mywindow = window.open('/Home/Redirect', '_blank');


        $(".btn_forwardSpanish").attr('href', srcurl);
        $(".btn_forwardSpanish").attr('target', "_blank");

        $.fn.colorbox({ opacity: 0.50, inline: true, href: "#DvRedirectAlt", scrolling: false, close: false });
        return false;
    });

    /* colorbox */
    $(".signIn").colorbox({ innerWidth: 400, innerHeight: 220, iframe: true, opacity: 0.50, scrolling: false });
    $(".forgottenPassword").colorbox({ innerWidth: 400, innerHeight: 225, iframe: true, opacity: 0.50, scrolling: false });

});

$(document).ready(function () {
    $("a.externGSK").click(function () {
        srcurl = $(this).attr('href');
        //mywindow = window.open('/Home/Redirect', '_blank');


        $(".btn_forward").attr('href', srcurl);
        $(".btn_forward").attr('target', "_blank");

        $.fn.colorbox({ opacity: 0.50, inline: true, href: "#DvRedirectGSK", scrolling: false, close: false });
        return false;
    });

    /* colorbox */
    $(".signIn").colorbox({ innerWidth: 400, innerHeight: 220, iframe: true, opacity: 0.50, scrolling: false });
    $(".forgottenPassword").colorbox({ innerWidth: 400, innerHeight: 225, iframe: true, opacity: 0.50, scrolling: false });

});

$(document).ready(function () {
    $("a.externAMG").click(function () {
        srcurl = $(this).attr('href');
        //mywindow = window.open('/Home/Redirect', '_blank');


        $(".btn_forward").attr('href', srcurl);
        $(".btn_forward").attr('target', "_blank");

        $.fn.colorbox({ opacity: 0.50, inline: true, href: "#DvRedirectAMG", scrolling: false, close: false });
        return false;
    });

    /* colorbox */
    $(".signIn").colorbox({ innerWidth: 400, innerHeight: 220, iframe: true, opacity: 0.50, scrolling: false });
    $(".forgottenPassword").colorbox({ innerWidth: 400, innerHeight: 225, iframe: true, opacity: 0.50, scrolling: false });

});

$(document).ready(function() {

    $('form.rating').click(function() {
        var f = $(this);
        var action = f.attr("action");
        var serializedForm = f.serialize();
        $.post(action, serializedForm,
            function() {
            });
        return false;
    });

});

function CloseColorBox() {
    $.fn.colorbox.close();
}



function valRegistrationForm() {

    var toReturn = true;

    if ($("#Pwd").val() != "") {
        $("#Password").val(hex_md5($("#Pwd").val()));
    }
    else {
        $("#Password").val("");
    }


    if ($("#ConfPassword").val() != "") {
        $("#Password2").val(hex_md5($("#ConfPassword").val()));
    }
    else {
        $("#Password2").val("");
    }

    $("#pwdCount").val($("#Pwd").val().length);


    $("#Pwd").val("");
    $("#ConfPassword").val("");

    return toReturn;
}

function OpenWindow(url) {
    window.open(url, 'BAPopUp', 'width=800,height=600,scrollbars=yes,resizable=yes');
}

//following scroll function from http://css-tricks.com/snippets/jquery/smooth-scrolling/
$(function()
{
    $('a[href*=#]').click(function()
    {
        if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '')
        && location.hostname == this.hostname)
        {
            var $target = $(this.hash);

            $target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');

            if ($target.length)
            {

                var targetOffset = $target.offset().top;

                $('html,body').animate({ scrollTop: targetOffset }, 1000);

                return false;
            }
        }
    });
});


function SetNewsLetter(status) 
{
    $("#email").attr("checked", status);
}

function UpdateNewsletterStatus() {
    var postData = {};
    postData.id = $("#email").attr("checked");
    
    $.ajax({
        url: '/EnglishUK/Home/SetNewsLetter',
        type: 'POST',
        data: postData,
        dataType: 'json',
        success: function (data) {
            //currentDocId = parseInt(data.PageId);            
        },
        error: function (xhr, status, error) {
            $("#email").attr("checked", false);            
            $.fn.colorbox({ innerWidth: 400, href:'/EnglishUK/Account/LogOn', innerHeight: 220, iframe: true, opacity: 0.50, scrolling: false });
        }
    });

}


