/**
 * Popup window offers a standard popup with default options.
 * @author NOSE
 *
 * @requires jquery.js 
 * @example jQuery("#alink").popupWindow("somefile.html", {width:"1024", height:"740",left:"50",top:"50"});
 * @before  
	<a href="#" id="alink">some text</a>
 *
 * @param url	The url of the popup content.
 * 
 * @option width 		The width.
 * @option height 		The height
 * @option left 		The left position.
 * @option top 			The top position.
 * @option mousevent 	The trigger event.
 * @option target 		The target.
 * @option resizable 	Component visible (yes|no).
 * @option menubar 		Component visible (yes|no).
 * @option toolbar 		Component visible (yes|no).
 * @option status 		Component visible (yes|no).
 * @option location 	Component visible (yes|no).
 * @option scrollbars 	Component visible (yes|no).
 * @option dependent 	Dependent (yes|no).
 * @option focus 		Set focus to window (true|false).
 * 
 * @version 1.0.0	initial version
 */
jQuery.fn.popupWindow = function(url,op) {
   			// defaults
			var defaults =  {	
				bind:false,
				mousevent: "click",
				target: "_blank",			
				resizable: "no",
				menubar: "no",
				toolbar: "no",	
				status: "no",	
				location: "no",
				scrollbars: "no",
				dependent: "yes",
				width: "100",
				height: "100",
				left: "100",
				top:"100",
				focus: true				
			};
			jQuery.extend(defaults, op);
			
			// init
			var options = "resizable="+defaults.resizable+",menubar="+defaults.menubar+",toolbar="+defaults.toolbar+",status="+defaults.status+",location="+defaults.location+",scrollbars="+defaults.scrollbars+",dependent="+defaults.dependent+",left="+defaults.left+",top="+defaults.top+",width="+defaults.width+",height="+defaults.height;
			
			// event
			if (defaults.bind) {
				jQuery(this).bind(defaults.mousevent, openPopupWindow);
			}
			else {
				openPopupWindow();
			}
			
			
			/*
			 * Opens the window.
			 */
			 function openPopupWindow() {			 	
			 	var w = window.open(url, defaults.target, options);
				if (defaults.focus) {
					w.window.focus();
				}
			 }
			
}
