// Initialize object if it does not exist
var jspop = window.jspop || {};

// create new jspop object
window.jspop = function() {

	// private members go here (allowed with js closures)

	// public members
	return {

		// method for opening popups on the checkout pages
		checkout: function( url ) {
			var width = 650;
			var height = 450;
			var top = (screen.height/2) - (height/2);
			var left = (screen.width/2) - (width/2);
			var parms = "toolbar=no,scrollbars=yes,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left;
			var handle = "azwin"; /* allows popup window to be re-used */
			win = window.open( url, handle, parms );
			win.focus(); /* IE will lose focus if the popup window is re-used. */
			return false;
		}

		// create additional methods for other popup types here


	} // end return

}(); // self-invoking function - allows for closures in js




// When document is ready, iterate through all links looking for specific css class names.  Assign the poupup methods above
// to the onclick events for the appropriate links.
jQuery(document).ready(function() {

	// change all links that have the class "jspopup-checkout" to popup in a window using the checkout method above
	jQuery("div#site-shipping-billing a.jspop-checkout, div#site-order-summary a.jspop-checkout").each(function(i) {

		jQuery(this).bind('click', function() {
			jspop.checkout( '/autozone/common/framePopup.jsp?content=' + jQuery(this).attr("href") );
			return false; /* prevents href from being loaded in main window */
		});

	});

	// create additional selectors/classes for additional popup types

});

