/*
 * OKC.js
 * 5339 - Oklahoma Jobs Landing Page
 *
 * CONTENTS:
 * - Omniture click tracking (throughout)
 *
 * BEHAVIOR DEPENDENCIES (see resources/jslib):
 * ncnu-global-national.js
 * PRESENTATION DEPENDENCIES:
 * None
 *
 * Created: 2009-07-24
 * Created By: Dave Wolfe
 * Last Updated: 2009-07-24
 * Last Updated By: Dave Wolfe
 */



// Create a namespace for our utilities
var UTIL = UTIL || {};
UTIL.popup = UTIL.popup || {};

/**
 * Open popup window
 *
 * Opens a popup window using as little as a URL. An optional params object can
 * be passed.
 *
 * @param {String} href
 * @param {Object} params
 * @return {WindowObjectReference}
 */
UTIL.popup.open = function (href, params)
{
 // Defaults (don't leave it to the browser)
 var defaultParams = {
 "width": "800", // Window width
 "height": "600", // Window height
 "top": "0", // Y offset (in pixels) from top of screen
 "left": "0", // X offset (in pixels) from left side of screen
 "directories": "no", // Show directories/Links bar?
 "location": "no", // Show location/address bar?
 "resizeable": "yes", // Make the window resizable?
 "menubar": "no", // Show the menu bar?
 "toolbar": "no", // Show the tool (Back button etc.) bar?
 "scrollbars": "yes", // Show scrollbars?
 "status": "no" // Show the status bar?
 };

 var windowName = params["windowName"] || "new_window";

 var i, useParams = "";

 // Override defaults with custom values while we construct the params string
 for (i in defaultParams)
 {
 useParams += (useParams === "") ? "" : ",";
 useParams += i + "=";
 useParams += params[i] || defaultParams[i];
 }

 return window.open(href, windowName, useParams);
};


/* *** Initialize/execute on pageload *** */
jQuery(document).ready(function(){

	$("a#popup_benefits").data("popup", {width:600,height:370});

	$("a.popup").each(function (i){
		$(this).click(function(event) {
			event.preventDefault();
			var params = $(this).data("popup") || {};
			if ($(this).attr("target")) {
				params.windowName = $(this).attr("target");
			}
			var windowObject = UTIL.popup.open(this.href, params);
			$(this).data("windowObject", windowObject);
		});
	});

});

