function browserCheck()
{
	this.ns4 = (document.layers)? true:false;
	this.ie = (document.all&&(!window.opera))? true:false;
	this.dom = (document.getElementById)? true:false;
	this.ns6 = (window.sidebar)? true:false;
	this.moz = (window.sidebar||navigator.userAgent.indexOf('Gecko')!=-1)? true:false;
	this.opera = (window.opera)? true:false;
	this.mac = (navigator.userAgent.indexOf('Mac')!=-1)? true:false;
}


function getObjectName(nameOfObject)
{

	Obj = null;

	if (is.ie) Obj = document.all[nameOfObject];
	else if (is.dom) Obj = document.getElementById(nameOfObject);
	else if (is.ns4) findLayer(window,nameOfObject);

	if (!Obj || ( is.ns4 && Obj == window ) ) Obj = null;

	return Obj;
}

function getObjectStyle(nameOfObject)
{

	Obj = null;

	if (is.ie) Obj = document.all[nameOfObject].style;
	else if (is.dom) Obj = document.getElementById(nameOfObject).style;
	else if (is.ns4) findLayer(window,nameOfObject);

	return Obj;
}

is = new browserCheck();

function isArray(obj)
{
   if (obj.constructor.toString().indexOf("Array") == -1)
	  return false;
   else
	  return true;
}
String.prototype.trim = function()
{
	var x = this;
	x = x.replace(/^\s*(.*)/, "$1");
	x = x.replace(/(.*?)\s*$/, "$1");
	return x;
}

function isEmpty(str)
{
	str = str + "";
	str = str.trim();
	if (str == "undefined" || str == "null" || str == "") return true;
	else return false;
}

function isFunction(a) {
	return typeof a == 'function';
}

function isNull(a) {
	return typeof a == 'object' && !a;
}

function isNumber(a) {
	return typeof a == 'number' && isFinite(a);
}

function isObject(a) {
	return (a && typeof a == 'object') || isFunction(a);
}

function isString(a) {
	return typeof a == 'string';
}

function isUndefined(a) {
	return typeof a == 'undefined';
}

    
if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
{ //IE 6+ in 'standards compliant mode'
	var myWidth = document.documentElement.clientWidth;
	var myHeight = document.documentElement.clientHeight;
}
	else
{
	if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{ //IE 4 compatible
		var myWidth = document.body.clientWidth;
		var myHeight = document.body.clientHeight;
	}
}


var newWindow;
function OpenThumb(src, width, height)
{

	if (newWindow)
		newWindow.close();

	var properties = "width="+width+", height="+height+", toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=no, top="+(parseInt((myHeight-height)/2))+", left="+(parseInt((myWidth-width)/2));
	newWindow = window.open(src, "PhotoWindow", properties);
	newWindow.document.write("<html>");
	newWindow.document.write("<head>");
	newWindow.document.write("<title>Sonex</title>");
	newWindow.document.write("<meta http-equiv=\"imagetoolbar\" content=\"no\" />");
	newWindow.document.write("</head>");
	newWindow.document.write("<body topmargin=\"0\" bottommargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" marginheight=\"0\" marginwidth=\"0\" >");
	newWindow.document.write("<img src=\""+src+"\" border=\"0\" alt=\"\" width=\""+width+"\" height=\""+height+"\" />");
	newWindow.document.write("</body>");
	newWindow.document.write("</html>");
	newWindow.focus();
	newWindow.document.close();

	return true;
}

function submitForm(name)
{
	var obj = getObjectName(name);
	if (isObject(obj))
	{
		obj.submit();
		return true;
	}
	return false;
}


function notEmptyElementCount(ar)
{
	var sk = 0;
	var max = ar.length;
	for(var i=0; i<max; i++)
		if (!isEmpty(ar[i])) sk++;
	return (sk > 0)?sk:false;
}

function URLEncode(argtext)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = ""+argtext;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	//document.URLForm.F2.value = encoded;
	return encoded;
};[root@mamutas:/isp/sonex.lt/vhosts/sistemos/htdocs]# 
[root@mamutas:/isp/sonex.lt/vhosts/sistemos/htdocs]# 
[root@mamutas:/isp/sonex.lt/vhosts/sistemos/htdocs]# 
[root@mamutas:/isp/sonex.lt/vhosts/sistemos/htdocs]# cat .js | echo

[root@mamutas:/isp/sonex.lt/vhosts/sistemos/htdocs]# cat .js ; echo
function browserCheck()
{
	this.ns4 = (document.layers)? true:false;
	this.ie = (document.all&&(!window.opera))? true:false;
	this.dom = (document.getElementById)? true:false;
	this.ns6 = (window.sidebar)? true:false;
	this.moz = (window.sidebar||navigator.userAgent.indexOf('Gecko')!=-1)? true:false;
	this.opera = (window.opera)? true:false;
	this.mac = (navigator.userAgent.indexOf('Mac')!=-1)? true:false;
}


function getObjectName(nameOfObject)
{

	Obj = null;

	if (is.ie) Obj = document.all[nameOfObject];
	else if (is.dom) Obj = document.getElementById(nameOfObject);
	else if (is.ns4) findLayer(window,nameOfObject);

	if (!Obj || ( is.ns4 && Obj == window ) ) Obj = null;

	return Obj;
}

function getObjectStyle(nameOfObject)
{

	Obj = null;

	if (is.ie) Obj = document.all[nameOfObject].style;
	else if (is.dom) Obj = document.getElementById(nameOfObject).style;
	else if (is.ns4) findLayer(window,nameOfObject);

	return Obj;
}

is = new browserCheck();

function isArray(obj)
{
   if (obj.constructor.toString().indexOf("Array") == -1)
	  return false;
   else
	  return true;
}
String.prototype.trim = function()
{
	var x = this;
	x = x.replace(/^\s*(.*)/, "$1");
	x = x.replace(/(.*?)\s*$/, "$1");
	return x;
}

function isEmpty(str)
{
	str = str + "";
	str = str.trim();
	if (str == "undefined" || str == "null" || str == "") return true;
	else return false;
}

function isFunction(a) {
	return typeof a == 'function';
}

function isNull(a) {
	return typeof a == 'object' && !a;
}

function isNumber(a) {
	return typeof a == 'number' && isFinite(a);
}

function isObject(a) {
	return (a && typeof a == 'object') || isFunction(a);
}

function isString(a) {
	return typeof a == 'string';
}

function isUndefined(a) {
	return typeof a == 'undefined';
}

    
if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
{ //IE 6+ in 'standards compliant mode'
	var myWidth = document.documentElement.clientWidth;
	var myHeight = document.documentElement.clientHeight;
}
	else
{
	if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{ //IE 4 compatible
		var myWidth = document.body.clientWidth;
		var myHeight = document.body.clientHeight;
	}
}


var newWindow;
function OpenThumb(src, width, height)
{

	if (newWindow)
		newWindow.close();

	var properties = "width="+width+", height="+height+", toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=no, top="+(parseInt((myHeight-height)/2))+", left="+(parseInt((myWidth-width)/2));
	newWindow = window.open(src, "PhotoWindow", properties);
	newWindow.document.write("<html>");
	newWindow.document.write("<head>");
	newWindow.document.write("<title>Sonex</title>");
	newWindow.document.write("<meta http-equiv=\"imagetoolbar\" content=\"no\" />");
	newWindow.document.write("</head>");
	newWindow.document.write("<body topmargin=\"0\" bottommargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" marginheight=\"0\" marginwidth=\"0\" >");
	newWindow.document.write("<img src=\""+src+"\" border=\"0\" alt=\"\" width=\""+width+"\" height=\""+height+"\" />");
	newWindow.document.write("</body>");
	newWindow.document.write("</html>");
	newWindow.focus();
	newWindow.document.close();

	return true;
}

function submitForm(name)
{
	var obj = getObjectName(name);
	if (isObject(obj))
	{
		obj.submit();
		return true;
	}
	return false;
}


function notEmptyElementCount(ar)
{
	var sk = 0;
	var max = ar.length;
	for(var i=0; i<max; i++)
		if (!isEmpty(ar[i])) sk++;
	return (sk > 0)?sk:false;
}

function URLEncode(argtext)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = ""+argtext;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	//document.URLForm.F2.value = encoded;
	return encoded;
};

