﻿Levemir.Util.Namespace('Levemir.App');

Levemir.App = {
    "Menu": function (url) {
    },
    /*
    .png{
    _background: url(/images/xxxx.png) no-repeat !important; 
    filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=noscale, src="/images/xxxxx.png");
    background:none;
    width:118px;height:133px;
    }
    */
    "FixPng": function (className) {
        //        var imgs = $(document).find("img");
        //        for (var i = 0; i < imgs.length; i++) {
        //            var src = imgs.eq(i).attr("src").toUpperCase();
        //            if (src.indexOf(".PNG") > 0) {
        //                imgs.eq(i).addClass(className);
        //            }
        //        }
        $(document).find("img[src$='png']").addClass(className);
    },  // end FIxPng
    /// tb is a jquery object
    "Search": function (tb) {
        var value = $.trim(tb.val());
        if (value.length == 0) {
            tb.focus();
        }
        else {
            window.location.href = "../Search.aspx?search=" + escape(value);
        }
    },
    "EnterSearch": function (tbId, e) {
        e = (e) ? e : window.event;
        var code = (e.keyCode || e.which);
        if (code == 13 || code == 32) {
            var search = $("#" + tbId);
            if ($.trim(search.val()).length == 0) {
                search.focus();
            }
            else {
                Levemir.App.Search(search);
            }
            return false;
        }

        if (window.event) {
            e.cancelBubble = true;
        } else {
            e.stopPropagation();
        }
        return true;
    },
    // in the header.ascx
    "ClickNordiskSites": function () {
        var div = $(".header_top_right");
        var top = 0;
        var right = div.offset().left + div.width();
        $.blockUI({
            message: $('#PopupNordiskSites'),
            css: {
                top: top + "px",
                right: right + "px",
                cursor: "default"
            }
        });
    },

    //Style about water impact
    "Water": function () {
        $(".water").focus(function () {
            if ($(this).val() == this.title) {
                $(this).val('').css('color', 'black');
            }
        })
        .blur(function () {
            if (this.value == '') {
                $(this).val(this.title).css('color', '#999999');
            }
        });
    },
    "Videos": [
    // 0
                {"image": "", "thumbenail": "", "title": "", "video": "", "description": "" }
    // 1
                , { "image": "/Images/Videos/Lev-Pen-Video-Thumbnail.jpg", "thumbenail": "/Images/Videos/thumbenail/Lev-Pen-Video-Thumbnail.jpg", "title": "Levemir® FlexPen® (7:09 min.)", "video": "Levemir_NovoFine.v3.flv", "description": " A video that shows you how to use your Levemir® FlexPen®. " }
    // 2
                , { "image": "/Images/Videos/Video_03-Thumbnail.jpg", "thumbenail": "/Images/Videos/thumbenail/Video_03-Thumbnail.jpg", "title": "How Levemir® Works (5:24 min.)", "video": "143546_Levemir MOA Animation_Patient.flv", "description": "An animation that shows the science behind how Levemir® works. " }
    // 3
                , { "image": "/Images/Videos/video_03.jpg", "thumbenail": "/Images/Videos/thumbenail/video_03.jpg", "title": "Get as much support as possible (0:16 min.)", "video": "Levemir_NovoFine.v3.flv", "description": "Rudy credits his family, friends, and medical team with helping him manage diabetes.  " }
    // 4
                , { "image": "/Images/Videos/video_04.jpg", "thumbenail": "/Images/Videos/thumbenail/video_04.jpg", "title": "Meet Michele (7:19 min.)", "video": "Levemir_NovoFine.v3.flv", "description": "Michele is a 40-year-old woman with type 1 diabetes who uses NovoLog® in a pump.  " }
    // 5
                , { "image": "/Images/Videos/video_05.jpg", "thumbenail": "/Images/Videos/thumbenail/video_05.jpg", "title": "Meet Kennedy (6:00 min.) ", "video": "Levemir_NovoFine.v3.flv", "description": "Kennedy is a 9-year-old girl with type 1 diabetes who uses NovoLog® in a pump.  " }
    // 6
                , { "image": "/Images/Videos/Video_01-Thumbnail.jpg", "thumbenail": "/Images/Videos/thumbenail/Video_01-Thumbnail.jpg", "title": "One less thing to think about (2:12 min.) ", "video": "Levemir.flv", "description": "Janice uses FlexPen® because it fits her lifestyle. Learn how a conversation with her doctor introduces her to insulin delivery on the go." }
    // 7
                , { "image": "/Images/Videos/video_07.jpg", "thumbenail": "/Images/Videos/thumbenail/video_07.jpg", "title": "Learning about diabetes (12:21 min.)", "video": "143540_What is Diabetes MOD Animation_Patient.flv", "description": "An animation that shows how diabetes affects the body. " }
    // 8
                , { "image": "/Images/Videos/video_08.jpg", "thumbenail": "/Images/Videos/thumbenail/video_08.jpg", "title": "The moment we knew (0:48 min.)", "video": "143494-Snapshot2_010411_TheMomentWeKnew.07.flv", "description": "Kennedyʼs mother recalls the day Kennedy was diagnosed with type 1 diabetes. " }
    // 9
                , { "image": "/Images/Videos/video_09.jpg", "thumbenail": "/Images/Videos/thumbenail/video_09.jpg", "title": "Warning signs of type 2 diabetes (0:50 min.)", "video": "143509-Snapshot8_010411_WarningSigns.08.flv", "description": "Rudy describes the symptoms he experienced leading up to his type 2 diabetes diagnosis.  " }
    // 10
                , { "image": "/Images/Videos/video_10.jpg", "thumbenail": "/Images/Videos/thumbenail/video_10.jpg", "title": "What is basal-bolus therapy? (4:56 min.) ", "video": "143542_What is Basal Bolus Therapy MOD Animation_Patient.flv", "description": "A long-acting insulin analog, like Levemir®, can be taken along with a fast-acting insulin for tighter blood sugar control. " }
    // 11
                , { "image": "/Images/Videos/Lev-Pen-Video-Player.jpg", "thumbenail": "/Images/Videos/thumbenail/Lev-Pen-Video-Player.jpg", "title": "Levemir® FlexPen® ", "video": "Levemir_NovoFine.v3.flv", "description": "Learn more about the features of the FlexPen® " }
    // 12
                , { "image": "/Images/Videos/video_12.jpg", "thumbenail": "/Images/Videos/thumbenail/video_12.jpg", "title": "NovoLog® FlexPen® works for me (2:17 min.)", "video": "143515-Snapshot12_010411_FlexpenWorksForMe.11.flv", "description": "Rudy explains why he feels the NovoLog® FlexPen® is right for him." }
    // 13
                , { "image": "/Images/Videos/video_13.jpg", "thumbenail": "/Images/Videos/thumbenail/video_13.jpg", "title": "The tools are better (0:20 min.)", "video": "143512-Snapshot10_010411_ToolsAreMuchBetter.12.flv", "description": "Rudy discusses the tools for treating diabetes in the past and how they have improved.  " }
    // 14
                , { "image": "/Images/Videos/video_14.jpg", "thumbenail": "/Images/Videos/thumbenail/video_14.jpg", "title": "Testing blood sugar is important (0:40 min.)", "video": "143522-Snapshot19_010411_TestingImportant.13.flv", "description": "Michele describes her schedule for running, meals, and testing blood sugar levels. " }
    // 15
                , { "image": "/Images/Videos/video_15.jpg", "thumbenail": "/Images/Videos/thumbenail/video_15.jpg", "title": "Managing diabetes takes commitment (2:21 min.) ", "video": "143514-Snapshot11_010411_ManagingDiabetesTakesCommitment.14.flv", "description": "Rudy lists his priorities when it comes to managing his diabetes with the NovoLog® FlexPen®. " }
    // 16
                , { "image": "/Images/Videos/video_16.jpg", "thumbenail": "/Images/Videos/thumbenail/video_16.jpg", "title": "Exercise is important for managing diabetes (0:23 min.)", "video": "143520-Snapshot17_010411_ExerciseImportantPart.15.flv", "description": "Michele expresses her love of running and its benefits for managing her diabetes. " }
    // 17
                , { "image": "/Images/Videos/video_17.jpg", "thumbenail": "/Images/Videos/thumbenail/video_17.jpg", "title": "You can still enjoy eating (0:27 min.)", "video": "143516-Snapshot13_010411_StillEnjoyEating.16.flv", "description": "Rudy talks about enjoying food with friends while controlling portions.  " }
    // 18
                , { "image": "/Images/Videos/video_18.jpg", "thumbenail": "/Images/Videos/thumbenail/video_18.jpg", "title": "What I tell my friends (0:35 min.)", "video": "143492-Snapshot1_010411_WhatITellMyFriends.17.flv", "description": "Kennedy explains how she deals with telling friends about her diabetes. " }
    // 19
                , { "image": "/Images/Videos/video_19.jpg", "thumbenail": "/Images/Videos/thumbenail/video_19.jpg", "title": "My parentʼs journey with my type 1 diabetes (0:31 min.)", "video": "143523-Snapshot20_010411_ParentsJourney.18.flv", "description": "Michele recalls her childhood with type 1 diabetes and how it affected her parents. " }
    // 20
                , { "image": "/Images/Videos/video_020.jpg", "thumbenail": "/Images/Videos/thumbenail/video_20.jpg", "title": "Ask about FlexPen® (1:20 min.) ", "video": "raj.20.flv", "description": "Raj uses FlexPen® as a backup to her insulin pump. Learn how one simple talk changed how insulin fits into her busy life. " }
    // 21
                , { "image": "/Images/Videos/video_021.jpg", "thumbenail": "/Images/Videos/thumbenail/video_21.jpg", "title": "Insulin in public? (1:20 min.) ", "video": "Miranda.21.flv", "description": "Miranda doesn't like people to know she takes insulin. See how FlexPen® lets her dose in public discreetly." }
    // 22
                , { "image": "/Images/Videos/video_022.jpg", "thumbenail": "/Images/Videos/thumbenail/video_22.jpg", "title": "Insulin on the go (1:05 min.) ", "video": "Calvin.22.flv", "description": "Calvin does not want to miss out on any life moments. See how FlexPen® helps make his insulin delivery on the go." }
    // 23
                , { "image": "/Images/Videos/video_023.jpg", "thumbenail": "/Images/Videos/thumbenail/video_23.jpg", "title": "Doctor knows best (1:15 min.)", "video": "Dr_Rosen.23.flv", "description": "Learn how Dr. Rosen prescribes FlexPen® and why he thinks itʼs good for doctors and patients. " }
    // 24
                , { "image": "/Images/Videos/video_24.jpg", "thumbenail": "/Images/Videos/thumbenail/video_24.jpg", "title": "It hit us hard (0:20 min.) ", "video": "143495-Snapshot3_010411_ItHitUsHard.23.flv", "description": "Kennedyʼs father recalls the day Kennedy was diagnosed with type 1 diabetes." }
    // 25
                , { "image": "/Images/Videos/video_25.jpg", "thumbenail": "/Images/Videos/thumbenail/video_25.jpg", "title": "Finding a doctor you work well with (0:25 min.) ", "video": "143500-Snapshot5_010411_CollaborationWithPhysicianIsCrucial.24.flv", "description": "Kennedyʼs father describes why finding the right doctor is so important.  " }
    // 26
                , { "image": "/Images/Videos/video_26.jpg", "thumbenail": "/Images/Videos/thumbenail/video_26.jpg", "title": "The pump: A physicianʼs perspective (0:39 min.)", "video": "143503-Snapshot6_010411_WhyThePump_Physician.25.flv", "description": "Dr. Anita Swamy explains why she is a big proponent of the pump when it comes to children. " }
    // 27
                , { "image": "/Images/Videos/video_27.jpg", "thumbenail": "/Images/Videos/thumbenail/video_27.jpg", "title": "The pump: Parentsʼ perspective (0:35 min.)", "video": "143507-Snapshot7_010411_WhyThePump_Parent.26.flv", "description": "Kennedyʼs parents explain why they feel NovoLog® in a pump is the best choice for her." }
    // 28
                , { "image": "/Images/Videos/video_28.jpg", "thumbenail": "/Images/Videos/thumbenail/video_28.jpg", "title": "How I managed my pregnancy (2:30 min.)", "video": "143521-Snapshot18_010411_IManagedMyPregnancy.27.flv", "description": "Michele explains why she chose to use NovoLog® in a pump during pregnancy." }
    // 29
                , { "image": "/Images/Videos/video_29.jpg", "thumbenail": "/Images/Videos/thumbenail/video_29.jpg", "title": "The crucial doctor/patient relationship (0:29 min.)", "video": "143524-Snapshot21_010411_DoctorPatientRelationship.28.flv", "description": "Michele speaks about her close relationship with her endocrinologist." }
    // 30
                , { "image": "/Images/Videos/video_30.jpg", "thumbenail": "/Images/Videos/thumbenail/video_30.jpg", "title": "The challenges of type 1 diabetes (0:26 min.)", "video": "143525-Snapshot22_010411_ThereAreChallenges.29.flv", "description": "Michele talks about how she gets through the occasional challenging day with type 1 diabetes.   " }
    // 31
                , { "image": "/Images/Videos/video_31.jpg", "thumbenail": "/Images/Videos/thumbenail/video_31.jpg", "title": "Letting your doctor know how you feel (0:20 min.)", "video": "143497-Snapshot23_010411_LettingDoctorKnowYoureAfraid.30.flv", "description": "Dr. Lara Fakunle explains how she shares information with her diabetes patients when they are worried. " }
    // 32
                , { "image": "/Images/Videos/video_32.jpg", "thumbenail": "/Images/Videos/thumbenail/video_32.jpg", "title": "Tackling diabetes can be an inspiration (0:25 min.)", "video": "143527-Snapshot24_010411_TacklingDiabetes_Inspiration.31.flv", "description": "Micheleʼs husband speaks about how Micheleʼs diabetes drives her to achieve more." }
    // 33
                , { "image": "/Images/Videos/video_33.jpg", "thumbenail": "/Images/Videos/thumbenail/video_33.jpg", "title": "Times have changed for the better (0:27 min.)", "video": "143511-Snapshot9_010411_TimesHaveChanges_Better.32.flv", "description": "Rudy recalls the way his motherʼs diabetes was treated compared to how diabetes is treated today. " }
    // 34
                , { "image": "/Images/Videos/video_34.jpg", "thumbenail": "/Images/Videos/thumbenail/video_34.jpg", "title": "Keep your goals in focus (0:19 min.) ", "video": "143517-Snapshot14_010411_KeepYourGoalInFocus.33.flv", "description": "Rudy shares his strategy for staying focused on his diabetes goal. " }
    // 35
                , { "image": "/Images/Videos/video_35.jpg", "thumbenail": "/Images/Videos/thumbenail/video_35.jpg", "title": "Charlie Kimballʼs story (0:00 min.) ", "video": "143517-Snapshot14_010411_KeepYourGoalInFocus.33.flv", "description": "Charlie Kimball is a professional race car driver with diabetes. " }
    //    // 35 equl to 6           
    // 36              
                , { "image": "/Images/Videos/video_06.jpg", "thumbenail": "/Images/Videos/thumbenail/video_06.jpg", "title": "Levemir® mechanism of action (5:24 min.)", "video": "143546_Levemir MOA Animation_Patient.flv", "description": "An animation that shows the science behind how Levemir® works." }
            ],
    "PlayVideo": function () {
        var videoList = Levemir.App.Videos;
        var index = -1;
        if (null != Interstitial) {
            var index = Interstitial.pop();
            if (Levemir.Util.IsPlusInteger(index.toString())) {
                index = parseInt(index);
            }
            else {
                Interstitial.push(index);
                return;
            }
        }
        if (index <= -1) {
            //TINY.box.hide();
        }
        else {
            flowplayer("playerInMediaPlayer", { src: "/Documents/flowplayer-3.2.7.swf", wmode: 'transparent' },
                    {
                        //key: '#@ef5e1980938915e6d9a', 
                        clip: { autoPlay: true, autoBuffering: true },
                        playlist: ["/Documents/Videos/" + videoList[index].video],
                        plugins: {
                            controls: { playlist: false, url: '/Documents/flowplayer.controls-3.2.5.swf' }
                        }
                    });

            $("#video_title").html(videoList[index].title);
            $("#video_description").html(videoList[index].description);
        }
    }, //end PlayVideo
    "ClearVideo": function () {
        //alert(0);
    },
    "PopupVideo": function (index) {
        Interstitial.push(index);
        TINY.box.show('/Interstitial/MediaPlayer.aspx', 1, 1000, 700, 1);
    },
    "SetCookie": function (key, value) {
        var exdate = new Date();
        exdate.setDate(exdate.getDate() + 1);
        document.cookie = key + "=" + escape(value) +
            ((1 == null) ? "" : ";expires=" + exdate.toGMTString());
    },
    "GetCookie": function (key) {
        if (document.cookie.length > 0) {
            c_start = document.cookie.indexOf(key + "=");
            if (c_start != -1) {
                c_start = c_start + key.length + 1;
                c_end = document.cookie.indexOf(";", c_start);
                if (c_end == -1) c_end = document.cookie.length;
                return unescape(document.cookie.substring(c_start, c_end));
            }
        }
        return "";
    },
    "SendEmailToFriend": function () {
        var obj = $("#SendEmailToFriend");
        var x = (($(document).width()) / 2 - (parseInt(obj.width()) / 2)) + "px";
        var y = ($(document).scrollTop() + (($(window).height()) / 2 - (parseInt(obj.height()) / 2))) + "px";
        obj.css("left", x);
        obj.css("top", y);
        obj.show();
    }
};
