/* Open URL in a new window */
function openNewWindow(url, name, width, height, center, options ) {
	var win;
	var l;
	var t;
	// Strip % symbol
	if(width.charAt(width.length-1) == "%") {
		width  = parseInt(width.replace("%",""));
		height = parseInt(height.replace("%",""));
	}
	
	// Convert percent to users screen width in px equivalent
	width = (width/100) * screen.availWidth;
	height = (height/100) * screen.availHeight;
	
	// Center window
	if(center){
		l = (screen.width-width)/2;
		t = (screen.height-height)/2;
	} else {
		l = 0;
		t = 0;
	}
	
	var settings = "height=" + height + ", width=" + width + ", top=" + t + ", left=" + l + ", " + options;
	win = window.open(url,name,settings);
	win.focus();
}

/* Trim whitespace from a string */ 
function trim(str) {
    return str.replace(/^\s+/g,'').replace(/\s+$/g,'')
}
