/* ********************************************************************************************************************
**
**	Name: 			bsPopup
**	
**	Version: 		0.1																			
** 	Author: 		Ben Sekulowicz
**
******************************************************************************************************************** */

var bsPopup = Class.create();

bsPopup.prototype = {	
   	initialize: function() {
		// On page load
		Event.observe(window, "load", this.onLoadWindow.bindAsEventListener(this));
	},
	
	/* ************************************************************************************************************* */
	
	onLoadWindow: function(e) {
		$$("a[rel='popup']").each(function(a) {
			Event.observe(a, "click", function(e) {				
				this.doIt(Event.findElement(e, "a").getAttribute("href"), Event.findElement(e, "a").getAttribute("puX"), Event.findElement(e, "a").getAttribute("puY"));
			}.bindAsEventListener(this));
			
			a.onclick = function() { return false; }
		}.bind(this));
	},
	
	/* ************************************************************************************************************* */
	
	doIt: function(url, x, y) {		
		window.open(
			url, 
			"sodaPicturesPopup", 
			"toolbar=0, scrollbars=1, location=0, statusbar=0, menubar=0, resizable=1, width=" + ((x == 0)? 600: x) + ", height=" + ((y == 0)? 400: y)
		);
	}

	/* *********************************************************************************************************************
	
	FIN
	
	********************************************************************************************************************* */
}