/* вырезание пробелов */
if ('undefined' == typeof String.prototype.trim)
{
  String.prototype.trim = function() {
    return this.replace(/^\s+/, '').replace(/\s+$/, '');
  }
}

/* перечисление всех свойств любого объекта */
Object.prototype.properties = function()
{
	var s = "";
	for(var i in this){
		s += i + ': <font color="#006600">' + this[i] + '</font><br />';
	}

	var props_window = window.open('','props_window','top=0, left=20,scrollbars=1, menubar=0, toolbar=0, location=0, directories=0, status=1, resizable=1,width=800,height=600');
	props_window.focus();

	props_window.document.write('<small style="font-family: Tahoma; font-size: 10px;">'+s+'</small> <hr />');
}

/* обработка HTML-мнемоник */
if ('undefined' == typeof String.prototype.mnemonicToChar)
{
  String.prototype.mnemonicToChar = function()
  {
  	var str = this;
	var pat = new Array (/&lt;/,/&gt;/,/&quot;/);
	var rep = new Array ('<','>','"');
	var count = pat.length; 
	for (var i=0; i<count; i++)
	{
		while (str.search(pat[i]) != -1) str = str.replace(pat[i],rep[i]);
	}
    return str;
  }
}

function PopUp(script_name,x,y,width,height)
{
	popup = window.open(script_name,'popup','top=' + y + ', left=' + x + ',scrollbars=1, menubar=0, toolbar=0, location=0, directories=0, status=1, resizable=1,width=' + width + ',height=' + height);
	popup.focus();
}

function BrowserDetect() {
   var ua = navigator.userAgent.toLowerCase(); 
   // browser name
   this.isIE = ( (ua.indexOf('msie') != -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1));
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   // correct version number
   if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat(ua.substring( ua.indexOf('msie ') + 5 ));
   }
   this.versionMajor = parseInt(this.versionMinor); 
   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
}
var browser = new BrowserDetect();

/* является ли числом */
function isNumeric(event)
{
	var keyASCII = event.which ? event.which : event.keyCode;
	
	if (isNaN(String.fromCharCode(keyASCII)) && keyASCII != 17 && keyASCII !=8) return false;
	else return true;
}

/* переход по адресу */
function moveTo(url)
{
	window.location.href = url;
}

/* предзагрузка картинок */
function preloadImg(img_src) {
	if (document.images) {
	 rslt = new Image();
	 rslt.src = img_src;
	 return rslt;
	}
}


