// define new String.ucFirst() method
String.prototype.ucFirst = function() {
	return this.charAt(0).toUpperCase() + this.substr(1);
};

$(function() {
	// menu tabs
	$("#tabs > ul").tabs();	

	// login dialog
	initLoginDialog();
});

function initLoginDialog()
{
	if (!$("#login").length) {
		return false;
	}
	$("#login").dialog({
        autoOpen: false,
        modal: true,
        resizable: false,
        title: "You are not a member",
        closeText: "",
        open: function() {
            $("#login").show();
        },
        close: function() {
            $("#login").hide();
        },
        buttons: {
            "Cancel": function() {
                $(this).dialog("close");
            }
        }
    });
	return true;
}

function initUsc2257Dialog()
{
	if (!$("div#usc2257").length) {
		return false;
	}
	$("div#usc2257").dialog({
        autoOpen: false,
        modal: true,
        resizable: false,
        title: "18 U.S.C. 2257 Record-Keeping Requirements Compliance Statement",
        closeText: "",
        width: "640px",
        open: function() {
            $(this).show();
        },
        close: function() {
            $(this).hide();
        },
        buttons: {
            "Ok": function() {
                $(this).dialog("close");
            }
        }
    });
	return true;	
}

var isImageCycleInitilalized = false;

function initImageCycle(containerClass)
{	
	if (isImageCycleInitilalized) {
		return false;
	}
	
	$('.' + containerClass + " a").css("display", "block");
	$('.' + containerClass).cycle({
        fx:     "fade",
        speed:   300,
        timeout: 1000,
        pause:   1,
        height:  132
    });
    $('.' + containerClass).cycle("pause");
    $('.' + containerClass).hover(
        function() { $(this).cycle("resume"); },
        function() { $(this).cycle("pause"); }
    );
    isImageCycleInitialized = true;
}

function url_search(search, search_type)
{
	if ("" == search) {
		return false;
	}
	window.location = "/" + escape(search_type) + "/search/" + escape(search.replace(/\s/g, "-"));
	return false;
}