
function strltrim() { return this.replace(/^\s+/,''); }
function strrtrim() { return this.replace(/\s+$/,''); }
function strtrim() { return this.replace(/^\s+/,'').replace(/\s+$/,''); }
String.prototype.ltrim = strltrim;
String.prototype.rtrim = strrtrim;
String.prototype.trim = strtrim;

function _calcWndIdent() {
	d = new Date();
	return "wnd" + d.getHours() + d.getMinutes() + d.getSeconds() + d.getMilliseconds();
}

function _centerWindow(wHandle, w, h) {
	posX = (screen.availWidth - w) / 2;
	posY = (screen.availHeight - h) / 2;
	wHandle.moveTo(posX, posY);
}

function openWnd(url, w, h, wndName, bNoScroll, bShowToolbar) {
	if(!w) w = 640;
	if(!h) h = 480;
	if(!wndName) wndName = _calcWndIdent();
	wnd = window.open(url,wndName,"toolbar=" + (bShowToolbar ? "yes" : "no") + ",location=no,directories=no,status=yes,menubar=no,scrollbars=" + (bNoScroll ? "no" : "yes") + ",resizable=yes,width="+w+",height="+h);
	if(wnd) {
		var posX = (screen.availWidth - w) / 2;
		var posY = (screen.availHeight - h) / 2;
		wnd.moveTo(posX, posY);	
	}
	return wnd;
}

function showImage(imId, w, h, hasCaption) {
	w += 20;
	h += 20;
	if(hasCaption) h += 60;
	openWnd("catalogue-image.php?id=" + imId, w, h, false, false, false);
}



// -------------------------


function openOrderWnd(e, lang) {
	if(!lang) lang = 1;
	var oFile = '/order-create-session.php'; /* e.ctrlKey && e.shiftKey ? '/order.php' : '/catalogue-order.php'; */
	openWnd(oFile + '?lang=' + lang, 660, 500, false, false, false);
	return false;
}
