/**
 * [jsl/_jsl.js]
 * ==========================================================================================================
 * 
 */

(function (parent) {

	parent.jsl = {

		// FUNCTION initialize( element )
		// ==================================================================================================
		/**
		 *
		 *
		 *
		 */
		initialize : function ( element ) {

			// If element is undefined, then search for jsl elements from the document body.
			//
			$("*[jsl]", $("object" === typeof element ? element : document)).each(
				function ( i ) {

					var attr = this.getAttribute("jsl");
					if ("$." === attr.slice(0, 2)) {

						// The developer used the "$" char instead of the string "jQuery", switch this.
						//
						attr = "jQuery" + attr.slice(1);

					} else if ("jsl." === attr.slice(0, 4)) {

						// The developer named the jsl module, but did not include "$" or "jQuery"
						//
						attr = "jQuery." + attr;

					} else if ("jQuery.jsl." !== attr.slice(0, 11)) {

						// The module name did not include the 'jQuery.jsl.' top module.  Add this module now.
						// In the event that jsl begins "::", then just append the jsl module as the top level
						// module is being referenced directly.
						//
						attr = "jQuery.jsl" + ("::" === attr.slice(0, 2) ? "" : ".") + attr;

					}

					// Parse the jsl string to get the parameter list and the function name.
					//
					var PARAMS = attr.split("(", 2);
					var OBJECTS = PARAMS[0].split("::");

					// Invoke the function to be called with the proper parameter list.
					//
					eval(
						OBJECTS[0] +
						(OBJECTS.length > 1
							?	"." + OBJECTS[1]
							:	".initialize") +
						(PARAMS.length > 1
							?	"(this, " + PARAMS[1]
							:	"(this)")
					);

				}
			);

		}

	};

})(jQuery);

// Now, we set up our initialization to occur on the load of the html document, using jquery.
//
$(document).ready(jQuery.jsl.initialize);

// [jsl/contact/]_contact.js
// ==========================================================================================================
/**
 *
 *
 */

(function (parent) {

	// FUNCTION initialize( element )
	// ======================================================================================================
	/**
	 *
	 * @param DomObject element
	 */
	function initialize( element ) {

		$(element).submit(onSubmit);

	}

	// FUNCTION onSubmit( e )
	// ======================================================================================================
	/**
	 *
	 *
	 *
	 */
	function onSubmit( e ) {

		var message = "";
		if ($("input[name='contact-name']", this).val().match(/^\s*$/)) {

			message += "    * The value of the Name field is empty.\n";

		}
		if (-1 === $("input[name='contact-phone']", this).val().search(/^\s*\d{3}-?\d{3}-?\d{4}\s*$/)) {

			message += "    * The value of the Phone field is not in the for XXX-XXX-XXXX.\n";

		}
		if ($("textarea", this).val().match(/^\s*$/)) {

			message += "    * The body of the Message is empty.\n";

		}
		if (message) {

			alert("The following errors have occurred:\n\n" + message);
			return false;

		}
		return true;

	}

	parent.contact = {
		initialize		: initialize
	}

})(jQuery.jsl);

// [jsl/]panedContent.js
// ==========================================================================================================
/**
 *
 *
 */

(function (parent) {

	var DEFAULT_INTERVAL = 10000;

	// FUNCTION initialize( element, interval )
	// ======================================================================================================
	/**
	 * Since there can be more than one instance of the panedContent plugin on a page, all support functions
	 * must be defined within the closure of the initialize function.  Why?  Because each instance must have
	 * its own timeout id variable.  Otherwise, only one instance will be pausable on a page.
	 *
	 * @param DomObject element
	 */
	function initialize( element, interval ) {

		var intervalID = undefined;
		var items = $(".jsl-paned-content-item", element);
		var controls = $(".jsl-paned-content-control", element);
		var count = items.length;
		var current = 0;

		function change( ) {

			items.css({ display:"none" });
			items.eq(current).css({ display:"block" });

		}
		function next( ) {

			current = (current + 1) % count;
			change();

		}
		function pause( ) {

			if (undefined !== intervalID) {

				window.clearTimeout(intervalID);
				intervalID = undefined;
				controls.eq(2).css({ display:"none" });
				controls.eq(1).css({ display:"block" });

			}

		}
		function play( ) {

			if (undefined === intervalID) {

				intervalID = window.setInterval(next, interval);
				controls.eq(1).css({ display:"none" });
				controls.eq(2).css({ display:"block" });

			}

		}
		function previous( ) {

			current = (0 === current ? count : current) - 1;
			change();

		}

		if (items.length > 1) {

			if (undefined === interval) {

				interval = DEFAULT_INTERVAL;

			}
			controls.eq(0).click(function( e ) { pause(); previous(); });
			controls.eq(1).click(function( e ) { play(); });
			controls.eq(2).click(function( e ) { pause(); });
			controls.eq(3).click(function( e ) { pause(); next(); });
			play( );

		}

	}

	parent.panedContent = {
		initialize		: initialize
	}

})(jQuery.jsl);

