$(document).ready(function () {
    $('a.navitem').hover( // nav
        function () { // ON
            var onsrc = $(this).children()[0];
            onsrc.src = onsrc.src.replace("_off", "_on");
        },
        function () {  // OFF
            var offsrc = $(this).children()[0];
            offsrc.src = offsrc.src.replace("_on", "_off");
        }
    ); // end nav


    $('img.det').hover( // nav
        function () { // ON
            this.src = this.src.replace("_on", "_off");
        },
        function () {  // OFF
            this.src = this.src.replace("_off", "_on");
        }
    ); // end nav

    // show hide main claim form
    //    $('#mainclaimForm').hide();
    //   $('a.showmainclaim').click(function () {
    //      $('#mainclaimForm').toggle();
    //       this.blur()
    //        $('#m_name_tb').focus();
    //        return false;
    //    });

    // show hide claim form
    $('#claimForm').hide();
    $('a.showclaim').click(function () {
        $('#claimForm').toggle();
        this.blur()
        $('#name_tb').focus();
        return false;
    });
    // main 
    var pop = function () {  // function for grey out and box
        $('#screen').css({ "display": "block", opacity: 0.7, "width": $(document).width(), "height": $(document).height() });
        $('body').css({ "overflow": "hidden" });
        if (navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod') {
            $('#mainclaimForm').css({ "position": "static" });
        };
        $('#mainclaimForm').css({ "display": "block" });
        $('#m_name_tb').focus();
        return false;
    }
    var shutit = function () {
        $('#mainclaimForm').css("display", "none");
        $('body').css({ "overflow": "scroll" });
        $('#screen').css("display", "none");
        return false;
    }

    $('#button').click(
            pop
    );

    $('#closebox').click(

            function () {
                shutit();
                $('#please').html('Please tell us what happened to you, and a fully qualified compensation lawyer will respond by phone or email, telling you exactly the strength of your claim, and what it may be worth. We do not charge for this service.');
            }
    );

    var showit = $('#sho').html();
    if (showit == "show") {
        pop();
    } else if (showit == "hide") {
        shutit();
   }
    //$('#closebox').click(function () {    // clodse the popupbox
    //    $('#mainclaimForm').css("display", "none");
    //    $('body').css({ "overflow": "scroll" });
    //    $('#screen').css("display", "none");
    //    return false;
    //})
    $(window).resize(function () {
        $('#mainclaimForm').css("display") == 'block' ? pop.call($('#button')) : "";
    });
    //  $(window).resize(pop);   // call again if window is resized 


});
