//plain new window
$(document).ready(function() {
	$("a.newWindow").attr({target: "_blank"});
});
 
 // usual javascript popups
 $.fn.PopUpWindow = function(config){
	return this.each(function(){
		// configuration
		this.myConfig = {
			// valid address you want to open
			address: config && config.address ? config.address : null,
			// name for the new window. Used when refering to the new windows later
			name: config && config.name ? config.name : "PopUpWindow",
			// width of the window
			width: config && config.width ? Number(config.width) : 100,
			// height of the window
			height: config && config.height ? Number(config.height) : 100,
			// additional parameters for the window configuration like showing the toolbar or scrollbars
			params: config && config.params ? config.params : null
		}
		// for "A" tags. if they didn't provide an address for us, then we will
		// try to grab the link for the tag and use that
		if(this.nodeName.toLowerCase() == "a") {
			// see if they gave us an address
			if(!this.myConfig.address) {
				// try to grab the href link and use that
				this.myConfig.address = $(this).attr("href");
			}
			// disable the hrefs on a tag
			$(this).attr("href","#");
		}
		// add the popup code to the tag's click event
		$(this).click(function() {
			// build parameters
			var params = "width=" + this.myConfig.width + ",height=" + this.myConfig.height;
			if(this.myConfig.params != null) {
				params += "," + this.myConfig.params;
			}
	    window.open(this.myConfig.address, this.myConfig.name, params).focus();;
		});
	});
}

$(function(){
	$(".popUpPlain").PopUpWindow({width:500,height:400,params:"toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes"});
	$(".popUp").PopUpWindow({width:500,height:300,top:1,left:25,params:"toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes"});
});