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
//	was
//	var emailPat = /^(\".*\"|[A-Za-z0-9]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;		//	"
	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 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 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 update_journal(object_name){
//	function for subscribe for impressmedia
	value1 = MM_findObj(object_name).checked;
	if (value1)	value2=false; else value2=true;
	//	window.alert(object_name);
	//	window.alert(value);

	MM_findObj(object_name+'_month').disabled = value2;
	MM_findObj(object_name+'_year').disabled = value2;
	MM_findObj(object_name+'_period').disabled = value2;

	num = MM_findObj(object_name+'_count').value;
	for (i=1; i<=num; i++ )	{
		MM_findObj(object_name+'_special['+i+']').disabled = value2;
	//	window.alert(MM_findObj(object_name+'_special['+i+']').checked);
	}
}




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();
}


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';
}

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';
}


function project_img (img, align) {
	if (align=='right')	{
		align='right';
		margin = 'left';
	}
	else	{
		align='left';
		margin = 'right';
	}
	document.write('<img onclick="project_popup(\''+img+'\')" src="/site_upload/projects_img/thumbs/'+img+'" border="0" align="'+align+'" style="cursor:hand; margin-bottom:5px;margin-'+margin+':8px;margin-top:3px;">');
}













function project_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='+String((screen.width-w)/2)+', top='+String((screen.height-h)/2);
	atr = atr + ' left=150, top=150';

//	defaultStatus
//	window.status

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

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

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



function catalogue_popup(img,w,h)	{
	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="/site_upload/catalogue/'+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(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);
}


