function go(act){
 document.fM.act.value=act;
 document.fM.submit();
}
function goID(act,id){
 document.fM.act.value=act;
 document.fM.id.value=id;
 document.fM.submit();
}

function checkD(evt){
 evt=(evt)?evt:event;
 var charCode=(evt.charCode)?evt.charCode:((evt.keyCode)?evt.keyCode:((evt.which)?evt.which:0));
 var result=((charCode>47)&&(charCode<58))||(37 == charCode) || (39 == charCode) || (8 == charCode) || (46 == charCode);
 return result;
}

function formatNumber(num,pl){
 num=parseFloat(num);
 var str=""+Math.round(eval(num)*Math.pow(10,pl));
 if(str.indexOf("e") != -1){return "Out of Range";}
 while(str.length<=pl){str="0"+str;}
 var point=str.length-pl;
 return str.substring(0,point)+"."+str.substring(point,str.length);
}
function convert(){
 if(!isNaN(document.frmCalculator.sum.value)){
  var result = document.frmCalculator.c1.value / document.frmCalculator.c2.value;
  result=result*document.frmCalculator.sum.value;
  document.getElementById('output').firstChild.data = formatNumber(result,3);
 }else{document.frmCalculator.sum.focus();}
}
function hImg(id){
 document.getElementById(id).style.visibility='hidden';
}
function sImg(id){
 if(action!=id){document.getElementById(id).style.visibility='visible';}
}
function selSum(){
	if (document.frmCalculator.sum.value=='0'){
		document.frmCalculator.sum.select();
	}
}
function search(){
	var filter=/^[K|P]N\d{6}$/;
	if(document.frmSearch.search.value==''){
		document.frmSearch.search.focus();
		alert('Моля въведете Каталожен N');
	}else if(!filter.test(document.frmSearch.search.value)){
		document.frmSearch.search.focus();
		alert('Каталожния N, който сте въвели е невалиден!');
	}else{
		document.frmSearch.submit();
	}
}

function checkMail(str){
 var filter=/^([a-zA-Z0-9_\.\-])+@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
 return (filter.test(str));
}

function tellFriend(){
 var email = document.getElementById('mail').value;
 if (checkMail(email)){
  document.fM.id.value = email;
  document.fM.act.value = 'n_friend';
  document.fM.submit();
 }else{
  document.getElementById('mail').value = email;
  document.getElementById('mail').focus();
  alert('Въведеният e-mail е невалиден!');
 }
}