// define the _param(value, default, type) function
function _param(v, d, t){
	// if no default value is present, use an empty string
	if( typeof d == "undefined" ) d = "";
	// if no type value is present, use "string"
	if( typeof t == "undefined" ) t = "string";
	// get the value to return, if the v param is not equal to the type, use default value
	var value = (typeof v != "undefined" && typeof v == t.toLowerCase()) ? v : d;
	return value;
}

function include(sTemplate){
	return document.write("<script language=\"JavaScript\" type=\"text/javascript\" src=\"" + sTemplate + "\"></script>");
}

// pop up a new window
function popUpWindow(URL, _width, _height, _windowName, _resizable, _scrollbars){
	var defaultWidth = 600, defaultHeight = 350;
	var width = (!!_width) ? parseInt(_width, 10) : defaultWidth;
	var height = (!!_height) ? parseInt(_height, 10) : defaultHeight;
	var windowName = (!!_windowName) ? _windowName : "popUpWindow";
	var resizable = (!!_resizable) ? _resizable : "yes";
	var scrollbars = (!!_scrollbars) ? _scrollbars : "yes";
	if( width < 1 ) width = defaultWidth;
	if( height < 1 ) height = defaultHeight;
	
	// calculate the center of the screen for positioning window there	
	var xPos = Math.round( (screen.width/2) - (width/2) );
	var yPos = Math.round( (screen.height/2) - (height/2) );

	// create a new window that should appear centered in the screen
	var w = window.open(URL,windowName,"status=yes,location=no,menubar=no,toolbar=no,resizable=" + resizable + ",scrollbars=" + scrollbars + ",width=" + width + ",height=" + height + ",left=" + xPos + ",top=" + yPos + ",screenX=" + xPos + ",screenY=" + yPos, true);
	w.focus();
}

