﻿// Copyright (c) 2005 Emagine bvba. All rights reserved.

function emagiCdotNet_Popup(url) {
    top.oMyWins['popupWindow'] = window.open(url, "doc", "resizable=1,toolbar=0,border=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,copyhistory=0,width=600,height=400");
    setTimeout('setWindowFocus(top.oMyWins["popupWindow"])', 500);
}

function emagiCdotNet_QuickSelect(url) {
    top.oMyWins['quickSelect'] = window.open(url, "doc", "resizable=1,toolbar=0,border=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,copyhistory=0,width=250,height=250");
    setTimeout('setWindowFocus(top.oMyWins["quickSelect"])', 500);
}

function setWindowFocus(win) {
    try {win.focus()}
    catch(e) {}
}

function scrollTop() {
	_body.scrollTop = 0;
}

function mouseUpDown(oImg, state) {
	if (oImg) {
		if (state == 'up') oImg.src = oImg.src.replace(/_down/, '_up');
		else oImg.src = oImg.src.replace(/_up/, '_down');
	}
}

function isObject(o) {
	return (typeof(o) == 'object');
}

function isEmpty(s) {
	// isEmpty(s) returns true if s == '' or s == null
	if (s == null) return true;
	s = s.toString();
	return s == '';
}

function isInteger(s){
    var i;
    for (i=0; i<s.length; i++) {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (c < '0' || c > '9') return false;
    }
    // All characters are numbers.
    return true;
}

function isTrue(s) {
	// isTrue(s) returns true if s == True or s == "true"
	return s != null && (s.toString() == "True" || s.toString() == "true");
}

function RTrim(str) {
	var i, j, letter;
	j = -1;
	for (i=str.length-1; i>=0; --i) {
		letter = str.charAt(i);
		if (letter != ' ') { j = i; break; }
	}
	if (j != -1) return str.substring(0,j+1);
	else return '';
}
	
function LTrim(str) {
	var i, j, letter;
	j = -1;
	for (i=0; i<str.length; ++i) {
		letter = str.charAt(i);
		if (letter != ' ') { j = i; break; }
	}
	if (j != -1) return str.substring(j,str.length);
	else return '';
}

function Len(str) {
    return str.length;
}

function Trim(str) {
	return RTrim(LTrim(str));
}

function UCase(str) {
	return str.toUpperCase();
}

function LCase(str) {
	return str.toLowerCase();
}

function Left(str, n) {
    var len = str.length
    if (len <= n) return str;
    return str.substr(0, n);
}

function Right(str, n) {
    var len = str.length
    if (len <= n) return str;
    return str.substr(len - n, n);
}


