/**
* Print our popup warning box if the user has not been to this site before.
*
* @param object $ Our jQuery object
*/
function warning($) {

	$("#debug").hide();
	var box = $("<div/>");
	box.attr("id", "popup_warning");
	box.addClass("jqmWindow");
	$("body").prepend(box);

	//
	// This is fired when the window is closed, such as by clicking the
	// "I Agree" button. The over_18 cookie is set to true so the user
	// is not asked again.
	//
	var close = function(h) {
		$.cookie("over_18", true, { expires: 365, path: "/" });
	};
	//
	// Make our warning window poppable.
	//

	box.jqm({
		modal: true,
		ajax: popup_warning,
		onHide: close
		});

	//
	// This is called when a button forward is clicked on.  The handler
	// that sets this is in the popup_warning.php script.
	// The reason we are using this handler in this way is because the
	// documentation for jqModal doesn't seem to be entirely accurate.
	// It says that the h.t variable contains the DOM item that triggered
	// the handler to run, but I haven't gotten it to work.  Hence this
	// approach.
	//
	close_target = function() {

		var id = $(this).attr("id");

		if (id == "popup_warning_gay") {
			target = popup_warning_gay;

		} else if (id == "popup_warning_straight") {
			target = popup_warning_straight;

		} else if (id == "popup_warning_fetish") {
			target = popup_warning_fetish;

		} else if (id == "popup_warning_all") {
			target = popup_warning_all;

		} else {

			target = popup_warning_default;

		}

		window.location = target;
	};




	//
	// Only show the window if a cookie has not been previously set.
	//
	if (!$.cookie("over_18") && -1 == location.href.toLowerCase().indexOf('https://secure.clips.com')) {
		box.jqmShow();
	}

} // End of warning()