function tr(obj){
	s=obj.value;
	re=/^\s+/; s=s.replace(re, '');
	re=/\s+$/; s=s.replace(re, '');
	obj.value=s;
	return s;
}
function ve(e){
ind=e.indexOf('\@');return (ind>0 && ind<s.length-1?true:false);
}
function validate(f){
p='Введите ';
if (tr(f.email)==''||!ve(f.email.value)) {alert(p+'правильный email!'); return false;}
return true;
}

function setdiv(div, HTML) {
	if(document.all) {document.all(div).innerHTML = HTML}

	else if(document.layers) {
		with(document.layers[div].document) {
			open ("text/html")
			write (HTML)
			close ()
		}
	}
	else if(document.getElementById) {document.getElementById(div).innerHTML = HTML;}

}

function setVisibility(div,type)
{
if(document.getElementById) document.getElementById(div).style.visibility=type
else if(document.all) document.all(div).style.visibility=type
}

function pop(url,wd,hg,name)
{
width=wd;height=hg;
if (parseInt (navigator.appVersion) >= 4 )
{
X=(screen.width  - width )/2;
Y=(screen.height - height)/2-40;
}
var extra='width='+width+',height='+height+',top='+Y+',left='+X+',resizable=1,scrollbars=1,location=no,directories=no,status=no,menubar=no,toolbar=no';
window.open(url,name,extra);
} 

function isNumber(elem,nm) {
    var str = elem.value;
    var re = /^\d*(\.|\,)?\d*$/;
    str = str.toString( );
    if (!str.match(re)) {        
        alert('Поле '+nm+' должно быть представлено числовым значением!');
        elem.focus();
        return false;
    }
    return true;
}
