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 check_subs_form() {
	
	if (MM_findObj('first_name').value.length<2)	{
		window.alert('First Name left blank.');
		return(false);
	}
	if (MM_findObj('last_name').value.length<2)	{
		window.alert('Last Name left blank.');
		return(false);
	}
	if (MM_findObj('job_title').value.length<2)	{
		window.alert('Job Title left blank.');
		return(false);
	}
	if (MM_findObj('company').value.length<2)	{
		window.alert('Company left blank.');
		return(false);
	}
	if (MM_findObj('address').value.length<2)	{
		window.alert('Address left blank.');
		return(false);
	}
	if (MM_findObj('code').value.length<2)	{
		window.alert('Post Code left blank.');
		return(false);
	}
	if (MM_findObj('telephone').value.length<2)	{
		window.alert('Telephone left blank.');
		return(false);
	}
	if (MM_findObj('fax').value.length<2)	{
		window.alert('Fax left blank.');
		return(false);
	}
	if (MM_findObj('email').value.length<2)	{
		window.alert('Email left blank.');
		return(false);
	}

	return true;
}

