function extend_string()
{
	if ('undefined' == typeof String.prototype.ltrim)
	{
	  String.prototype.ltrim = function() {
	    return this.replace(/^\s+/, '');
	  }
	}
	
	if ('undefined' == typeof String.prototype.rtrim)
	{
	  String.prototype.rtrim = function() {
	    return this.replace(/\s+$/, '');
	  }
	}
	
	if ('undefined' == typeof String.prototype.trim)
	{
	  String.prototype.trim = function() {
	    return this.replace(/^\s+/, '').replace(/\s+$/, '');
	  }
	}		
}

function strHasData(s, minLength)
{
	if(s == null)
		return false;
	
	extend_string();
	s = s.trim();
	return s.length >= minLength;
}

function checkEmail(s)
{
	if( ! strHasData(s, 5)  )
		return false;
	var i = s.indexOf('@');
	var i2 = s.indexOf('.');
	return (i >= 0) && (i2 >= 0);		
}

// !!!  в name нельзя пробелы и лучше только латиница, т.к. это имя, а не заголовок
function popupWin(name, uri, wdt, hgt)
{
	var posCode = ''
	if ( (screen.height < 481) && (hgt > 400) )
		{ hgt = 400 }
	var posX = Math.round((screen.width - wdt) / 2)
	var posY = Math.round((screen.height - hgt) / 2) - 35
	posCode = ",left="+posX+",top="+posY
//	var popupedWin = window.open(uri, name, "status=yes,menubar=yes,toolbar=yes,resizable=yes,scrollbars=yes,location=yes,width="+wdt+",height="+hgt+posCode)
	var popupedWin = window.open(uri, name, "status=yes,menubar=no,toolbar=no,resizable=yes,scrollbars=yes,location=no,width="+wdt+",height="+hgt+posCode)
	popupedWin.focus()
}

function showWin(name, uri, left, top, wdt, hgt)
{
	var posCode = ",left="+left+",top="+top;
	var popupedWin = window.open(uri, name, "status=yes,menubar=yes,toolbar=yes,resizable=yes,scrollbars=yes,location=no,width="+wdt+",height="+hgt+posCode)
	popupedWin.focus()
}

// if state exist then define that need to do (show or hide) 
// state = 1 -> show, state = 0 -> hide, state = undefined -> switch visibility
function showHide(elId, state)
{
	var el = document.getElementById(elId);
	if (el == null)
	{
		//alert("Элемент не найден - " + elId);
		return;
	}
	
	if( state != null)
	{
		if(state)
			el.style.display = "block";
		else
			el.style.display = "none";
	}
	else
	{
		if(el.style.display == "none")
			el.style.display = "block";
		else
			el.style.display = "none";
	}
}
