// general interface function for the page

function addZebraTables() {
    $(".zebra").each(function() {
        $(this).children().children("tr:even").addClass("alt");
    });
}

function launchPopupBox() {
    $(".iMail").click(function() {
        $(".popupBox").fadeIn("slow");
        docTop = document.documentElement.scrollTop + 200 + "px";
        docMid = (document.documentElement.scrollWidth / 2) - 130 + "px";
        $(".popupBox").css("top", docTop);
        $(".popupBox").css("left", docMid);
        return false;
    });
}

function closePopupBox() {
    $(".popupSubmit").click(function() {
        $(".popupBox").fadeOut("slow");
        return false;
    });
}

function submitGoogleSearch() {
    var searchQuery = document.getElementById("SiteSearch").value;
    document.location = "/Search.aspx?search=" + searchQuery + "&s=" + window.location.host;
}

/* Add interface functions */
$(document).ready(function() {

    // add zebra tables
    addZebraTables();

    // add tabbed navigation
    addTabs();

    // initiate popup box
    launchPopupBox();

//    $("#raceDatePicker").datepicker({
//        showOn: "both",
//        buttonImageOnly: true,
//        buttonImage: "/Portals/0/css/calendar-blue.gif",
//        dateFormat: "yymmdd",
//        altField: "#alField",
//        altFormat: "dd-mm",
//        hideIfNoPrevNext: true,
//        
//        //limit to 2 days in future, and 1/Jun/2009
//        maxDate: '+2d',
//        minDate: new Date(2009, 5, 1),

//        onSelect: function(dateText, inst) {
//            var x = $("#raceDatePickerRedirectURL");
//            var url = x.val().replace('[replace_date]', dateText);
//            window.location = url;
//        }

//    });

    /* video datepicker scroll pane */
//    $(".newsFeature .tabs li").click(function() {
//        var meetingbar = $(".tab:visible .meetingContainer");
//        var offset = meetingbar.height() - $(".tab:visible .meetingWrapper").height() + $(".tab:visible .meetingWrapper .controls").height();
//        var wrapTop = $(".tab:visible .meetingWrapper").scrollTop();

//        $(".newsFeature .controls a.vNext").mousedown(function(e) {
//            meetingbar.animate({ top: (wrapTop - offset) }, 500);
//            e.preventDefault();
//        });

//        $(".newsFeature .controls a.vPrev").mousedown(function(e) {
//            meetingbar.animate({ top: 0 }, 500);
//            e.preventDefault();
//        });

//        $(".newsFeature .controls a").mouseup(function(e) {
//            meetingbar.stop();
//            e.preventDefault();
//        });
//    });

});


/* Bigpond Unmetered */
$(document).ready(function() {
    $("#navwrap .unmetered a").hover(
		function() {
		    if (!$("#bp-unmetered-hover").size()) {
		        $("body").append("<div id='bp-unmetered-hover' class='pngbg'>BigPond Sport, Movies, Music and Games downloads, video streams and editorial content are unmetered for most BigPond Broadband members.</div>");
		        var left = $("#navwrap .unmetered").offset().left;
		        var top = $("#navwrap .unmetered").offset().top;
		        $("#bp-unmetered-hover").css("left", left - 120);
		        $("#bp-unmetered-hover").css("top", top + 26);
		    }
		    else {
		        $("#bp-unmetered-hover").css("display", "block");
		    }
		},
		function() {
		    if ($("#bp-unmetered-hover").size()) {
		        $("#bp-unmetered-hover").css("display", "none");
		    }
		});
});