var GenericPopupWindow = Class.create();

GenericPopupWindow.default_width = 600;
GenericPopupWindow.default_height = 500;
GenericPopupWindow.scrolling = false;

GenericPopupWindow.prototype = {
	initialize: function( el ){
		this.el = el;
		this.winCount = 0;
		this.widthHeight = (this.el.hasAttribute('rel') ? this.el.attributes['rel'].value : String(GenericPopupWindow.default_width) + "x" + String(GenericPopupWindow.default_height)).split('x');
		this.width = ( this.el.hasAttribute('rel') ? this.widthHeight[0] : this.el.attributes['win_width'].value);
		this.height = ( this.el.hasAttribute('rel') ? this.widthHeight[0] : this.el.attributes['win_height'].value);
		this.scrolling = ( this.el.hasAttribute('scrolling') ? this.el.attributes['scrolling'].value : GenericPopupWindow.scrolling );
		Event.observe( this.el, 'click', this.clicked.bindAsEventListener( this ) );
	},
	clicked: function( event ){
		if(this.scrolling == '1'){
			window.open(this.el.href, "win"+this.winCount++, "width="+this.width+",height="+this.height+",resizable=1,scrollbars=1");
		} else {
			window.open(this.el.href, "win"+this.winCount++, "width="+this.width+",height="+this.height+",resizable=1");
		}
		try{
			Event.stop( event );
		}catch( e ){
			return false;
		}
	}
}

GenericPopupWindow.FindPopups = function(){
	$$( "a.PopupWin" ).each( function(el){ new GenericPopupWindow(el); } );
}

Event.observe( window, 'load', GenericPopupWindow.FindPopups );
