// JavaScript Document




    function zeroPad(num, count) {
        var numZeropad = num + '';
        while (numZeropad.length < count) {
            numZeropad = "0" + numZeropad;
        }
        return numZeropad;
    }

    function checkEmail(email) {
        var emailReg = "^[\\w-_\.+]*[\\w-_\.]\@([\\w]+\\.)+[\\w]+[\\w]$";
        //var emailReg = "\\w+([-+.']\\w+)*@\\w+([-.]\w+)*\.\w+([-.]\w+)*";  // from ascx clientsscript validation used in BSC (modified and knackered)

        var regex = new RegExp(emailReg);
        return regex.test(email);
    }

    darknesslevel = .75;
    function SetupDarkLayer() {
        if ($.browser.msie && jQuery.browser.version == "6.0") {
            //$("#wholepage").fadeOut("slow");
        } else {
            // size background layer
            $("#blacklayer").width($(document).width());
            $("#blacklayer").height($(document).height());
            $("#blacklayer").css("visibility", "visible");

            // override z-index on menu navigation elements
            $(".udm a").css("z-index", -3);
            //$(".udm li a").css("z-index",-3); 
        }

    }
    $(document).ready(function() {

        if ($.cookie("FloaterDisabled") != null)
		{
		
		$("#floatingsignupdiv").remove();
		$("#blacklayer").remove();
		$("#nothanks").remove();
		 return;
		 }

        //size and fade in a dark layer above page content
        SetupDarkLayer();
        $("#blacklayer").fadeTo(1, darknesslevel);

        //show div with signup form above dark layer
        $("#floatingsignupdiv").css({ position: "absolute", marginLeft: 0, marginTop: 0, top: ($(window).height() - $("#floatingsignupdiv").height()) / 2, left: ($(window).width() - $("#floatingsignupdiv").width()) / 2 });
        $("#floatingsignupdiv").css("visibility", "visible");


        // scroll away the grass at the top odf this landing page so it looks right in the iframe
        $('#landingpage')[0].contentWindow.scrollBy(0, 10);

        $("#nothanks").css("visibility", "visible");
        $("#nothanks").css({ position: "absolute", marginLeft: 0, marginTop: 0, top: $("#floatingsignupdiv").offset().top + $("#floatingsignupdiv").height() + $("#nothanks").height() - 2, left: $("#floatingsignupdiv").width() + $("#floatingsignupdiv").offset().left - $("#nothanks").width() });

        if ($.browser.msie && jQuery.browser.version == "6.0")
            $("#wholepage").hide();
        else {
            $("#floatingsignupdiv").css("position", "fixed");
            $("#nothanks").css("position", "fixed");
        }


        $("#nothanks").bind("click", function(e) {

            $("#floatingsignupdiv").hide();
            if ($.browser.msie && jQuery.browser.version == "6.0") {
           	
			
		        $("#wholepage").show(); // not working in ie6 - no time to track down cause
              	$("#wholepage").css("visibility", "visible");
            }
            else {
                $("#blacklayer").hide();
                $(".udm a").css("z-index", 1090);
                //$(".udm li a").css("z-index",1080); 
            }

            $("#nothanks").hide();
            $.cookie('FloaterDisabled', 'true', { expires: 30 });

	         if ($.browser.msie && jQuery.browser.version == "6.0") window.location.reload()

        });

  


          


    });

    $(window).resize(function() {
        if ($.cookie("FloaterDisabled") != null) return;
        SetupDarkLayer();
        //centre signup form in window
        $("#floatingsignupdiv").css({ position: "absolute", marginLeft: 0, marginTop: 0, top: ($(window).height() - $("#floatingsignupdiv").height()) / 2, left: ($(window).width() - $("#floatingsignupdiv").width()) / 2 });


        // position 'no thanks' link
        $("#nothanks").css("visibility", "visible");
        $("#nothanks").css({ position: "absolute", marginLeft: 0, marginTop: 0, top: $("#floatingsignupdiv").offset().top + $("#floatingsignupdiv").height() + $("#nothanks").height() - 2, left: $("#floatingsignupdiv").width() + $("#floatingsignupdiv").offset().left - $("#nothanks").width() });


        //reassert its fixedness
        if ($.browser.msie && jQuery.browser.version == "6.0")
            $("#wholepage").hide();
        else {
            $("#floatingsignupdiv").css("position", "fixed");
            $("#nothanks").css("position", "fixed");
        }


    });

 


