﻿var pagebody = document.getElementById('page-body');
var bodybg = document.getElementById('body-bg');
if (pagebody != null && bodybg != null) {
    if (window.outerWidth == null) {
        //alert('IE');
        if (document.documentElement.clientWidth < 1010) {
            document.body.style.width = "1010px";
            document.getElementById('page-body').style.width = "1010px";
            document.getElementById('body-bg').style.width = "1010px";
        }
    }
    else {
        //alert('FF');
        if (window.outerWidth < 1010) {
            document.body.style.width = "1010px";
            document.getElementById('page-body').style.width = "1010px";
            document.getElementById('body-bg').style.width = "1010px";
        }
    }
}

window.onresize = function() {
    var pagebody = document.getElementById('page-body');
    var bodybg = document.getElementById('body-bg');
    if (pagebody != null && bodybg != null) {
        if (window.outerWidth == null) {
            //alert('IE');
            if (document.documentElement.clientWidth < 1010) {
                document.body.style.width = "1010px";
                document.getElementById('page-body').style.width = "1010px";
                document.getElementById('body-bg').style.width = "1010px";

            }
            else {
                document.body.style.width = "100%";
                document.getElementById('page-body').style.width = "100%";
                document.getElementById('body-bg').style.width = "100%";
            }
        }
        else {
            //alert('FF');
            if (window.outerWidth < 1010) {
                document.body.style.width = "1010px";
                document.getElementById('page-body').style.width = "1010px";
                document.getElementById('body-bg').style.width = "1010px";

            } else {
                document.body.style.width = "100%";
                document.getElementById('page-body').style.width = "100%";
                document.getElementById('body-bg').style.width = "100%";
            }
        }
    }
};


var safe_jquery = jQuery.noConflict();
(function($) {
    var search_verathon = function() {
        var search_box = $('#dnn_dnnSearch_txtSearch');

        //Modified by Shrikant
        var search_text = $('#dnn_dnnSearch_cmdSearch').html();
        //var overlay = $('<div id="sb-overlay">Search Verathon<sup>&copy;</sup></div>');
        var overlay = $('<div id="sb-overlay" style="padding-top:3px;">' + search_text + '</div>');
        //EndModified by Shrikant

        search_box_offset = search_box.position();
        overlay.css({ 'top': search_box_offset.top + 3, 'left': search_box_offset.left + 10 }).appendTo(search_box.parent());
        overlay.bind('click', function() {
            overlay.hide();
            search_box.trigger('focus');
        });
        search_box.bind('focusout', function() {
            var value = search_box.attr('value');
            if (!value) {
                overlay.show();
            }
        });
        search_box.bind('focusin', function() {
            overlay.trigger('click');
        });

        // Added by Shrikant
        if ($.trim(search_box.val()) != '') {
            overlay.hide();
        }
    }

    //Modified by Shrikant
    var localize = function() {
        var print = $('#dnn_Print');
        print.attr('title', $('#hdnPrint').val());

        var smalltext = $('#TextSizeWidget_smalltext');
        smalltext.attr('title', $('#hdnSmall').val());

        var mediumtext = $('#TextSizeWidget_mediumtext');
        mediumtext.attr('title', $('#hdnMedium').val());

        var largetext = $('#TextSizeWidget_largetext');
        largetext.attr('title', $('#hdnLarge').val());
    }

    //Contact us page toggle
    var contactus_toggle = function() {
        jQuery(".contact-us-content").hide();
        jQuery(".contact-us-heading").children(".contact-us-country").addClass('down-bullet');

        //Show the desired coutry content
        var pageName = ('' + window.location).split("/region/");
        var country = '';
        
        if (pageName.length > 1) {
            var countryName = pageName[1].split(".aspx");
            if (countryName.length > 1) {                
                country = countryName[0];
            }
        }
                
        //if ((getQueryVariable("region") != null) && ($("#" + getQueryVariable("region")).length != 0)) {
        if ((country != '') && ($("#" + country).length != 0)) {
            //var country = '' + getQueryVariable("region");            
            $("#" + country).next(".contact-us-content").show();
            $("#" + country).children(".contact-us-country").removeClass('down-bullet');
            $("#" + country).children(".contact-us-country").addClass('up-bullet');
            var position = $("#" + country).position().top;
            scrollTo(0, position);
        }
        else {
            //Show first country cotent
            $("#Canada").next(".contact-us-content").show();
            $("#Canada").children(".contact-us-country").removeClass('down-bullet');
            $("#Canada").children(".contact-us-country").addClass('up-bullet');
        }

        //toggle the country content
        jQuery(".contact-us-heading").click(function() {
            jQuery(this).next(".contact-us-content").slideToggle(500);
            if (jQuery(this).children(".contact-us-country").is('.down-bullet')) {
                jQuery(this).children(".contact-us-country").removeClass('down-bullet');
                jQuery(this).children(".contact-us-country").addClass('up-bullet');
            }
            else {
                jQuery(this).children(".contact-us-country").removeClass('up-bullet');
                jQuery(this).children(".contact-us-country").addClass('down-bullet');
            }
        });

        function getQueryVariable(variable) {
            var query = window.location.search.substring(1);
            var vars = query.split("&");
            for (var i = 0; i < vars.length; i++) {
                var pair = vars[i].split("=");
                if (pair[0] == variable) {
                    return pair[1];
                }
            }
        }
    }
    //End: Modified by Shrikant

    $(document).ready(function() {
        search_verathon();

        //Modified by Shrikant
        $('#body-top').mouseover(function() {
            localize();
        });

        contactus_toggle();
        //End: Modified by Shrikant
    })
})(safe_jquery);





