﻿Flex.Util.Namespace('Flex.App');

Flex.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;
    }
    */

    /*

    $("a[href^='http'][target!='_blank']").attr("href", function () {
    return "javascript: Interstitial.push('" + $(this).attr('href') + "');TINY.box.show('/Interstitial/LeaveWebsite.htm', 1, 664, 350, 1);";

    */


    "FixPng": function (className) {
        $(document).find("img[src$='png']").addClass(className);
    },  // end FIxPng
    "Interstitial": function (url) {
        Interstitial.push(url);
        TINY.box.show('/Interstitial/Interstitial.htm', 1, 574, 364, 1);
    },
    "Search": function (tb) {
        try {
            var value = $.trim(tb.val());
            if (value.length == 0) {
                tb.focus();
            }
            else {
                window.location.href = "/Search.aspx?search=" + escape(value);
            }
        }
        catch (e) { }
    },
    "LeaveWebsite": function (links) {
        //alert(links.length);
        links.each(function () {
            var $this = $(this);
            if ($this.attr('href').toLowerCase().indexOf("http://www.novo") >= 0
                || $this.attr('href').toLowerCase().indexOf("http://www.cornerstones4care.com") >= 0
                || $this.attr('href').toLowerCase().indexOf("http://www.levemir.com") >= 0
                || $this.attr('href').toLowerCase().indexOf("http://www.miflexpen.com") >= 0
                || $this.attr('href').toLowerCase().indexOf("http://www.drivetheswitch.com") >= 0
            ) {
                return;
            }
            $this.data("url", $this.attr('href'));
            $this.attr("href", "/Interstitial/LeaveWebsite.htm");
            $this.removeAttr("target");
            $this.fancybox({
                'autoScale': false
            });

            $this.click(function () {
                Interstitial.push($this.data("url"));
            });
        });
    },
    "EnterSearch": function (tb, btn, e) {
        e = (e) ? e : window.event;
        var code = (e.keyCode || e.which);
        if (code != 13) { // 13:enter. 32: blank.  && code != 32
            return true;
        }
        if ($("#" + tb).val().length > 0) {
            $("#" + btn).click();
            return false;
        }
    }
};
