﻿FixIE_search = function() {
    var boolIsMSIE = false;
    if (navigator.appName) {
        var strUserAgent = navigator.appName;
        boolIsMSIE = (strUserAgent != null && strUserAgent.indexOf("Microsoft") != -1);
    }
    if (document.getElementById && boolIsMSIE) {
        var ptrInput = document.getElementById("sa");
        ptrInput.onmouseover = function() {
            this.style.backgroundImage = "url(/resources/img/button_search_go_on.gif)";
        }
        ptrInput.onmouseout = function() {
            this.style.backgroundImage = "url(/resources/img/button_search_go.gif)";
        }
    }
}



function sIFR_onload() {
    if (typeof sIFR == "function" && !sIFR.UA.bIsIEMac) {
        sIFR.setup();
        sIFR_replace();
        sIFR();
    };
}

function sIFR_resize() {
    if (typeof sIFR == "function" && !sIFR.UA.bIsIEMac) {
        try { sIFR.rollback(); } catch (e) { }
        sIFR_replace();
        sIFR();
    };
}

function sIFR_replace() {
    // Put sIFR.replaceElement calls here.
    sIFR.replaceElement(".sifr_replace", named({ sFlashSrc: "/resources/swf/metaplusbook-roman.swf", sColor: "#8d0b0b", sWmode: "transparent" }));
    sIFR.replaceElement("div.layout_callout h3", named({ sFlashSrc: "/resources/swf/metaplusbook-roman.swf", sColor: "#8d0b0b", sWmode: "transparent", nPaddingBottom: "5" }));
    sIFR.replaceElement("div#callout_content h3", named({ sFlashSrc: "/resources/swf/metaplusbook-roman.swf", sColor: "#8d0b0b", sWmode: "transparent" }));
    sIFR.replaceElement("div#column_content h3", named({ sFlashSrc: "/resources/swf/metaplusbook-roman.swf", sColor: "#8d0b0b", sWmode: "transparent" }));
    sIFR.replaceElement("div#home_white_sifr h3", named({ sFlashSrc: "/resources/swf/metaplusbook-roman.swf", sColor: "#ffffff", sWmode: "transparent" }));
    sIFR.replaceElement("div.home_content h3", named({ sFlashSrc: "/resources/swf/metaplusbook-roman.swf", sColor: "#8d0b0b", sWmode: "transparent" }));

    sIFR.replaceElement("div.layout_callout span", named({ sFlashSrc: "/resources/swf/metaplusbook-roman.swf", sColor: "#8d0b0b", sWmode: "transparent", nPaddingBottom: "5" }));
    //  sIFR.replaceElement("div#callout_content span", named({ sFlashSrc: "/resources/swf/metaplusbook-roman.swf", sColor: "#8d0b0b", sWmode: "transparent" }));
    //  sIFR.replaceElement("div#column_content span", named({ sFlashSrc: "/resources/swf/metaplusbook-roman.swf", sColor: "#8d0b0b", sWmode: "transparent" }));
    //  sIFR.replaceElement("div#home_white_sifr span", named({ sFlashSrc: "/resources/swf/metaplusbook-roman.swf", sColor: "#ffffff", sWmode: "transparent" }));
    //  sIFR.replaceElement("div.home_content span", named({ sFlashSrc: "/resources/swf/metaplusbook-roman.swf", sColor: "#8d0b0b", sWmode: "transparent" }));
}
function CMS_onload() {
}
function do_onload() {
}

function onloads() {
    //FixIE_mainnav();
    // FixIE_search();
    CMS_onload();
    do_onload();
}

window.onload = onloads;

function ChangeFontSize(ptrItem) {
    var strOldTitle = document.title;
    var strSize = ptrItem.id;
    if (document.getElementsByTagName) {
        var ptrBody = document.getElementsByTagName("body");
        var ptrSmall = document.getElementById("small");
        var ptrMedium = document.getElementById("medium");
        var ptrLarge = document.getElementById("large");
        if (strSize == "large") {
            ptrBody[0].style.fontSize = "0.8em";
            ptrLarge.style.backgroundImage = "url(/resources/img/textenlarger_btn_square_on.gif)";
            ptrSmall.style.backgroundImage = "url(/resources/img/textenlarger_btn_rounded.gif)";
            ptrMedium.style.backgroundImage = "url(/resources/img/textenlarger_btn_square.gif)";
            sIFR_resize();
        }
        if (strSize == "medium") {
            ptrBody[0].style.fontSize = "0.7em";
            ptrMedium.style.backgroundImage = "url(/resources/img/textenlarger_btn_square_on.gif)";
            ptrSmall.style.backgroundImage = "url(/resources/img/textenlarger_btn_rounded.gif)";
            ptrLarge.style.backgroundImage = "url(/resources/img/textenlarger_btn_square.gif)";
            sIFR_resize();
        }
        if (strSize == "small") {
            ptrBody[0].style.fontSize = "0.6em";
            ptrSmall.style.backgroundImage = "url(/resources/img/textenlarger_btn_rounded_on.gif)";
            ptrMedium.style.backgroundImage = "url(/resources/img/textenlarger_btn_square.gif)";
            ptrLarge.style.backgroundImage = "url(/resources/img/textenlarger_btn_square.gif)";
            sIFR_resize();
        }
        document.title = strOldTitle;
        return false;
    }
}



function CheckKeyCode(e) {

    try {
        if (navigator.appName == "Microsoft Internet Explorer") {
            if ((e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode == 8))
            { return true; }
            else
            { return false; }
        }
        else {
            if ((e.charCode >= 48 && e.charCode <= 57) || (e.charCode == 0))
            { return true; }
            else
            { return false; }
        }
    }
    catch (e) { }
}




var phone_field_length = 0;
function TabNext(obj, event, len, next_field) {
    try {

        obj.setAttribute('autocomplete', 'off');
        next_field.setAttribute('autocomplete', 'off');

        if (event == "down") {
            phone_field_length = obj.value.length;
        }
        else if (event == "up") {
            if (obj.value.length != phone_field_length) {
                phone_field_length = obj.value.length;
                if (phone_field_length == len) {

                    try {


                        next_field.focus();
                    }
                    catch (e) { }
                }
            }
        }
    }
    catch (e) { }
}

$(document).ready(
    function() {
        //alert('wtf')
        // install flowplayer into container
        if ($('#audio').length) {
            $f("audio", "http://releases.flowplayer.org/swf/flowplayer-3.1.5.swf", {

                // fullscreen button not needed here 
                plugins: {
                    controls: {
                        fullscreen: false,
                        height: 30
                    }
                },

                clip: {
                    autoPlay: false,

                    // optional: when playback starts close the first audio playback 
                    onBeforeBegin: function() {
                        $f("audio").close();
                    }
                }

            });
        }
    }
);

