var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1
var ns6=document.getElementById&&!document.all
var ns4=document.layers


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function isValidEmail(emailStr) {
	// checks if the e-mail address is valid
	var emailPat = /^(\".*\"|[A-Za-z0-9\.\-_]*)@(\[\d{1,3}(\.\d{1,3}){3}]|[\-A-Za-z_\-]*(\.[A-Za-z\-_]*)+)$/;		//	"
	var matchArray = emailStr.match(emailPat);
	if (matchArray == null) {
		//alert("Your email address seems incorrect.  Please try again (check the '@' and '.'s in the email address)");
		return false;
	}
	return true;
}

function NumbersOnly() {
	if (window.event) code=event.keyCode;
	else code=event.charCode;
	//else code= e.which;
	//alert(e.which);	
	//if (event.keyCode<48||event.keyCode>57) return false;
	if ((code<48||code>57)&&(code!=46)) return false;
	else return true;
}

function get_radio_value(object_name)	{
//	достает значение radiobutton'a,  если не выбрано - вернет undefined
	tmp_value = 'undefined';
	my_object=MM_findObj(object_name);
	num = my_object.length;
	for( var i = 0; i < num; i++ ) {
		if( my_object[ i ].checked == '1' ) {
			tmp_value = my_object[ i ].value;
		}
	}
return(tmp_value);
}


function open_img(path)	{
	add_w = window.open('show_photo.php?id='+path,'ch','left=150,top=150,width=830,height=640,scrollbars=1,status=0,resizeable=0');
	add_w.focus(); if (add_w.opener == null) { add_w.opener = window; }
}




function show_nl(news_id)        {
        tmpobj = MM_findObj('ndata_'+news_id);
        if (tmpobj != null)        tmpobj.style.display=        'inline';

        tmpobj = MM_findObj('hide_'+news_id);
        if (tmpobj != null)        tmpobj.style.display        =        'inline';

        tmpobj = MM_findObj('more_'+news_id);
        if (tmpobj != null)        tmpobj.style.display        =        'none';
        return false;
}

function hide_nl(news_id)        {
        tmpobj = MM_findObj('ndata_'+news_id);
        if (tmpobj != null)        tmpobj.style.display=        'none';

        tmpobj = MM_findObj('hide_'+news_id);
        if (tmpobj != null)        tmpobj.style.display        =        'none';

        tmpobj = MM_findObj('more_'+news_id);
        if (tmpobj != null)        tmpobj.style.display        =        'inline';
return false;
}



function show_block(block_name)        {
        tmpobj = MM_findObj(block_name);
        if (tmpobj != null)        tmpobj.style.display=        'inline';
        return false;
}

function hide_block(block_name)        {
        tmpobj = MM_findObj(block_name);
        if (tmpobj != null)        tmpobj.style.display=        'none';
return false;
}


function set_text(obj_name, txt){
	tmpobj = MM_findObj(obj_name);
	tmpobj.innerHTML = txt;
}



function judges_open_panel(url)	{
	w = 900;
	h = 670;
	
	atr = '';
	atr = atr + 'scrollbars=yes,';
	atr = atr + 'location=yes,';
	atr = atr + 'status=yes,';
	atr = atr + 'statusbar=yes,';
	atr = atr + 'menubar=yes,';
	atr = atr + 'resizable=yes,';
	atr = atr + 'toolbar=yes,';
	atr = atr + 'width='+w+',';
	atr = atr + 'height='+h+',';

	atr = atr + ' left=40'+', top=40';
	new_window=window.open(url, '_blank', atr);
	new_window.focus();
	
	return (false);
}



function img_popup(img)	{
	atr = '';
	atr = atr + 'scrollbars=no,';
	atr = atr + 'location=no,';
	atr = atr + 'statusbar=yes,';
	atr = atr + 'menubar=no,';
	atr = atr + 'status=yes,';
	atr = atr + 'toolbar=no,';
	atr = atr + 'resizable=no,';
	atr = atr + 'width=300,';
	atr = atr + 'height=300,';
	atr = atr + ' left=150, top=150';

	html = '<html><head><title></title></head><body style="margin:0 0 0 0;" bgcolor="#FFFFFF"><script>function fit_img(w,h,img){ window.resizeTo(w+10,h+49);window.status=" ";}</script><div id="r1"><img src="'+img+'" alt="закрыть окно" border=0 onClick="window.close(self)" style="cursor:hand;" id="img" onload="fit_img(this.width, this.height, this);"></div></body></html>';

	win=window.open('','',atr);
	win.document.write(html);
	win.focus();
	return(false);
}



function img_popup_src(img_obj,path)	{
//	взять имя рисунка из картинки, вырезать все лишнее и открыть новую фотку с укзанаием пути path
	var reg=/([^\/]+)$/;
	var file_main=reg.exec(img_obj.src);
	var img=path+file_main[0];

	atr = '';
	atr = atr + 'scrollbars=no,';
	atr = atr + 'location=no,';
	atr = atr + 'statusbar=yes,';
	atr = atr + 'menubar=no,';
	atr = atr + 'status=yes,';
	atr = atr + 'toolbar=no,';
	atr = atr + 'resizable=no,';
	atr = atr + 'width=300,';
	atr = atr + 'height=300,';
	atr = atr + ' left=150, top=150';

	html = '<html><head><title></title></head><body style="margin:0 0 0 0;" bgcolor="#FFFFFF"><script>function fit_img(w,h,img){ window.resizeTo(w+10,h+49);window.status=" ";}</script><div id="r1"><img src="'+img+'" alt="закрыть окно" border=0 onClick="window.close(self)" style="cursor:hand;" id="img" onload="fit_img(this.width, this.height, this);"></div></body></html>';

	win=window.open('','',atr);
	win.document.write(html);
	win.focus();
	return(false);
}



function popup_page(url, w, h)	{
	atr = '';
	atr = atr + 'scrollbars=yes,';
	atr = atr + 'location=no,';
	atr = atr + 'status=no,';
	atr = atr + 'statusbar=no,';
	atr = atr + 'menubar=no,';
	atr = atr + 'resizable=no,';
	atr = atr + 'toolbar=no,';
	atr = atr + 'width='+w+',';
	atr = atr + 'height='+h+',';

	atr = atr + ' left=40'+', top=40';
	new_window=window.open(url, '_blank', atr);
	new_window.focus();

	return (false);
}


function popup(url,w,h,sb)
{
    atr = '';
    atr = atr + 'toolbar=no,';
    if (sb)
    {
	atr = atr + 'scrollbars=no,';
    }
    else
    {
	atr = atr + 'scrollbars=yes,';
    }
    atr = atr + 'location=no,';
    atr = atr + 'statusbar=no,';
    atr = atr + 'menubar=no,';
    atr = atr + 'resizable=no,';
    atr = atr + 'status=no,';
    atr = atr + 'toolbar=no,';
    atr = atr + 'menubar=no,';
    if (w) {
    atr = atr + 'width='+w+',';
    atr = atr + 'height='+h+',';
    }
    else{
    atr = atr + 'width=700,';
    atr = atr + 'height=700,';
    }
    atr = atr + ' left='+String((screen.width-w)/2)+', top='+String((screen.height-h)/2);
    new_window=window.open(url,'_blank',atr);
    new_window.focus();
}

