﻿
// Removes leading whitespaces
function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}

function openWindow(windowName, url, title, width, height) 
{
    var leftVal = (screen.width - width) / 2;
    var topVal = (screen.height - height) / 2;
    var params = "width=" + width + ",height=" + height + ",left=" + leftVal + ",top=" + topVal + ",resizable=1";

    var newWindow = window.open(url, windowName, params);
    if (window.focus) {newWindow.focus();}
        
    return false;
}