var Error1="Введенное значение содержит недопустимые символы";
function check(input) {
  var ok = true, a=check.arguments;
  for (var i = 0; i < input.length; i++) {
    var chr = input.charAt(i);
    var found = false;
    for (var j = 1; j < a.length; j++) {
      if (chr == a[j]) found = true;
    }
    if (!found) ok = false;
  }
  return ok;
}
function SpecVisible(fid,sid)
{
	a=document.getElementById(sid);
	b=document.getElementById(fid);
	if (b.value>0)
	{
		a.style.display='none';
	}
	else {a.style.display='block';}
}
function CheckTime(input) {
  var ok = true, a=check.arguments;
  chr = input.charAt(0); 
  if  (input.charAt(1)!=":") 
  {
  	chr=chr+input.charAt(1); 
	if  (input.charAt(2)!=":") return false;  
	else i=3;
	}
  else 
  {
  	i=2;	
  }
  if (chr>23) return false;
  
  chr="";
  for (var j= i; j < input.length; j++) {
  chr=chr+input.charAt(j)
  }
  if (chr.length>2) {chr1=chr1+chr.charAt(0)+chr.charAt(1); }
  if (chr1>59) return false; else 
  return true;
}

function IsNumber(input) {
 return check(input, "1", "2", "3", "4",
        "5", "6", "7", "8", "9", "0");
}
function IsHex(input) {
 return check(input, "1", "2", "3", "4",
        "5", "6", "7", "8", "9", "0", "a", "b", "c", "d", "e", "f", "A", "B", "C", "D", "E", "F");
}


function aOver(id){
	a=document.getElementById(id);
	if (a.tagName=="A"){
//		a.style.textDecoration='underline';	
	a.className='under';}
}
function aOut(id){
	a=document.getElementById(id);
	if (a.tagName=="A"){
//		a.style.textDecoration='none';
	a.className='button';}
}
function Edited(id){
	a=document.getElementById(id);
	if (a.tagName=="INPUT"){
	if (!IsNumber(a.value)){alert(Error1+" :"+a.value+":");a.value=1;}
	else {a.className='basket_edited';}
	}
}
function sort_tbl(form,fname) { 
 var d=document;
	 if (d.getElementById(form).cart_order.value==fname)
	 {
		if (d.getElementById(form).ord_to.value=="asc") d.getElementById(form).ord_to.value="desc";
		else d.getElementById(form).ord_to.value="asc";
	 }
	 else
	 {
		d.getElementById(form).cart_order.value=fname;
		d.getElementById(form).ord_to.value="asc";
	 }
	 d.getElementById(form).submit();
}
//funkzii uslojnennogo submita
function sel_stat(form) { 
 	 var d=document;
	d.getElementById(form).sel_year.value=d.getElementById(form).sel_god.value;
	d.getElementById(form).submit();
}
//funkzii udalenia=============================
function del_tbl(message,form,fname) { 
 	 var d=document;
	 if(confirm(message))
	 {
	    CreateDates('filter');
	 	d.getElementById(form).del_id.value=fname;
	 	d.getElementById(form).submit();
	 }
}

function del_prod(message,form,pname) { 
 	 var d=document;
	 if(confirm(message))
	 {
	 	d.getElementById(form).del.value=1;
		d.getElementById(form).product.value=pname;
	 	d.getElementById(form).submit();
	 }
}

function del_cust(message,form,cid) { 
 	 var d=document;
	 if(confirm(message))
	 {
		d.getElementById(form).delete_id.value=cid;
	 	d.getElementById(form).submit();
	 }
}
//=====================================================

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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 MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//=====================================================

function ChangeColor(box_id,selObj){
	d=document.getElementById(box_id);
	if (d.tagName=="DIV"){
		d.style.backgroundColor=selObj.options[selObj.selectedIndex].value;	
		}
}
function SetValue(box_id,color){
	var d=document.getElementById(box_id);
	if (d.tagName=="DIV"){
		if (color.length==6 && IsHex(color)) {d.style.backgroundColor=color;}
		}
}

function SelectColor(box_id,combo_id,color,num){
	var d=document.getElementById(box_id);
	if (d.tagName=="DIV"){
		d.style.backgroundColor=color;
		}
	d=document.getElementById(combo_id);
	if (d.tagName=="SELECT"){
		d.selectedIndex=num-1;	
		}
}
function SetColor(box_id,field_id,color,ked,prim){
	var d=document.getElementById(box_id);
	var f=document.getElementById(field_id);
	var f1=document.getElementById(field_id+'1');
	var clr="000000";
	var cl_="000000";
	var sm=0;
	var g="";
	sym=new Array("0","1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f");
	//vosstanovlenie na meste starogo ukazatelia
	if (ked!=-1)
	{
	document.getElementById("c"+ked+"_"+f.value.substring(ked*2,ked*2+2)).style.backgroundColor='#'+f.value;
	f.value=f.value.substring(0,2*ked)+color.substring(2*ked,2*ked+2)+f.value.substring(2*ked+2,6);
	}
	else 
	{f.value=color;}
	f1.value=f.value;

	d.style.backgroundColor='#'+f.value;
	//pererisovka linee spectrov
		for (var k=0;k<3;k++)
		{
		  if (k!=ked)
		  {
		    clr=f.value;
			document.getElementById("cg"+k+"_00").style.backgroundColor='#'+clr.substring(0,2*k)+'00'+clr.substring(2*k+2,6);
			document.getElementById("cg"+k+"_FF").style.backgroundColor='#'+clr.substring(0,2*k)+'FF'+clr.substring(2*k+2,6);
			for (var i=0;i<16;i++)
			{ 
			    //clr.substring(k*2,k*2+1)=sym[i];
				for (var j=0;j<16;j++)
				{
					document.getElementById("c"+k+"_"+sym[i]+sym[j]).style.backgroundColor='#'+clr.substring(0,2*k)+sym[i]+sym[j]+clr.substring(2*k+2,6);//clr;
				}	
			}
		  }
		  gg=f.value.substring(k*2,k*2+1).toLowerCase();
		  for (var i=0;i<16;i++)
		  {
		  	if (sym[i]==gg)
			{
				sm+=(i+0.5)*16;
				break;
			} 
		  }	
		}	
		if (sm<240) {cl_='BBBBBB';} else {cl_='000000';}
		for (var k=0;k<3;k++)
		{
			document.getElementById("c"+k+"_"+f.value.substring(k*2,k*2+2)).style.backgroundColor='#'+cl_;
		}
}
// 2use popup() function: <a href="javascript:;" onClick="javascript:popup('name', '#link', 0, 0, 300, 150, 0, 0, 1, 1, 1); return false;"></a>
function popup(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable){
	var wint = (screen.height - height) / 2;
	var winl = (screen.width - width) / 2;
	toolbar_str = toolbar ? 'yes' : 'no';
	menubar_str = menubar ? 'yes' : 'no';
	statusbar_str = statusbar ? 'yes' : 'no';
	scrollbar_str = scrollbar ? 'yes' : 'no';
	resizable_str = resizable ? 'yes' : 'no';
	window.open(url, name, 'left='+winl+',top='+wint+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}
function CreateDates(forma){
    if ((document.getElementById(forma).start_date.value!=document.getElementById(forma).start_date1.value) || (document.getElementById(forma).end_date.value!=document.getElementById(forma).end_date1.value) )
			{document.getElementById(forma).period.selectedIndex=0; }
	document.getElementById(forma).start_date.value=document.getElementById(forma).start_date1.value;
	document.getElementById(forma).end_date.value=document.getElementById(forma).end_date1.value;
}

function PageNum(forma,val){
 document.getElementById(forma).page.value=val;
 document.getElementById(forma).submit();
}

function ClearPeriod(forma){
 document.getElementById(forma).period.selectedIndex=0;
 document.getElementById(forma).submit();
}

function Refresh()
{
  register.flag.value = 1; 
  register.submit();
}
function RefreshGB()
{
  gb.flag.value = 1; 
  gb.submit();
}
function SubmitRegister(){
 if (register.flag.value != "0") {return true;}
 if  (register.reg_login.value=="") {alert("Пожалуйста, введите логин");register.reg_login.focus(); return false;}
 else if  (register.reg_login.value.length>="20") {alert("Логин должен содержать менее 20 символов");register.reg_login.focus(); return false;}
 else if  (register.password.value!=register.pwd_confirm.value) {alert("Повторно введенный пароль не соответствует первичному");register.pwd_confirm.focus(); return false;}
 else if  (register.client_type.selectedIndex==0 && register.company.value=="") {alert("Пожалуйста, введите название компании");register.company.focus(); return false;}
 else if  (register.client_type.selectedIndex==0 && register.email.value!="" && echeck(register.email.value)== false) {alert("Неправильный  E-mail компании");register.email.focus(); return false;}
 else if  (register.surname.value=="") {alert("Пожалуйста, введите фимилию контактного лица");register.surname.focus(); return false;}
 else if  (register.name.value=="") {alert("Пожалуйста, введите имя контактного лица");register.name.focus(); return false;}
 else if  (register.contact_phone.value=="") {alert("Пожалуйста, введите телефон контактного лица");register.contact_phone.focus(); return false;}
 else if  (register.contact_email.value=="") {alert("Пожалуйста, введите E-mail контактного лица");register.contact_email.focus(); return false;}
 else if (echeck(register.contact_email.value)== false) {alert("Неправильный  E-mail контактного лица");register.contact_email.focus(); return false;}
 else if  (register.company.value=="тов" || register.company.value=="ТОВ" || register.company.value=="ооо" || register.company.value=="ООО") {alert("Пожалуйста, введите полное название фирмы. Пример: ООО 'АлиС-Плюс'");register.company.focus(); return false;}
  else if  (register.captcha_value.value=="") {alert("Отсутствует код подтверждения безопасности");register.captcha_value.focus(); return false;}

 else return true; 
}
function SubmitRegister1(){
if (SubmitRegister()) {document.register.submit();}
}

function RetrievePwd(){
 if  (retrieve.login.value=="") {alert("Не введен логин");retrieve.login.focus(); return false;}
 else if  (retrieve.email.value=="") {alert("Не введен адрес электронной почты");retrieve.email.focus(); return false;}
   else if (echeck(retrieve.email.value)== false) {alert("Неправильный  E-mail");retrieve.email.focus(); return false;}
 else return true;
}
function RetrievePwd1(){
if (RetrievePwd()) document.retrieve.submit();
}

function LogIn(){
 if  (member_area.login.value=="") {alert("Не введен логин");member_area.login.focus(); return false;}
// else if  (member_area.password.value=="") {alert("Не введен пароль");member_area.password.focus(); }
 else return true;
}
function LogIn1(){
if (LogIn()) document.member_area.submit();
}

function ClientLogIn(){
 if  (client_area.login.value=="") {alert("Не введен логин");client_area.login.focus(); return false;}
// else if  (member_area.password.value=="") {alert("Не введен пароль");member_area.password.focus(); }
 else return true;
}
function ClientLogIn1(){
if (ClientLogIn()) {document.client_area.submit();}
}

function LogAdmin(){
 if  (member_area.user.value=="") {alert("Не введен логин");member_area.user.focus(); return false;}
// else if  (member_area.password.value=="") {alert("Не введен пароль");member_area.password.focus(); }
 else return true;
}
function LogAdmin1(){
if (LogAdmin1()) document.member_area.submit();
}

function SubmitContactForm(){
 if  (contact.email.value=="") {alert("Не введен адрес электронной почты");contact.email.focus(); return false;}
   else if (echeck(contact.email.value)== false) {alert("Неправильный  E-mail");contact.email.focus(); return false;}
 else if  (contact.question.value=="") {alert("Не введен вопрос");contact.question.focus(); return false;}
 else return true;
}
function SubmitContactForm1(){
if (SubmitContactForm()) {document.contact.submit();}
}

function SubmitChangePwd(){
 if  (pwd.password.value=="") {alert("Пароль не может быть пустой строкой");pwd.password.focus();return false; }
 else if  (pwd.password.value!=pwd.pwd_confirm.value) {alert("Повторно введенный пароль не соответствует первичному");pwd.pwd_confirm.focus();return false;}
 else return true;
}
function SubmitChangePwd1(){
 if  (SubmitChangePwd()) {document.pwd.submit();}
}

function SubmitChangeValue(){
 if  (register.client_type.value==10 && register.company.value=="") {alert("Пожалуйста, введите название компании");register.company.focus(); return false;}
 else if (register.client_type.value==10 && register.email.value!="" && echeck(register.email.value)== false) {alert("Неправильный  E-mail компании");register.email.focus(); return false;}
 else if  (register.surname.value=="") {alert("Пожалуйста, введите фимилию контактного лица");register.surname.focus(); return false;}
 else if  (register.name.value=="") {alert("Пожалуйста, введите имя контактного лица");register.name.focus(); return false;}
 else if  (register.contact_phone.value=="") {alert("Пожалуйста, введите телефон контактного лица");register.contact_phone.focus(); return false;}
 else if  (register.contact_email.value=="") {alert("Пожалуйста, введите E-mail контактного лица");register.contact_email.focus(); return false;}
 else if (echeck(register.contact_email.value)== false) {alert("Неправильный  E-mail контактного лица");register.contact_email.focus(); return false;}
 else return true;
}
function SubmitChangeValue1(){
if (SubmitChangeValue()) {document.register.submit();}
}

function SubmitGB(){
 if (gb.flag.value != "0") {return true;}
 if  (gb.email.value!="" && echeck(gb.email.value)== false) {alert("Неправильный  E-mail контактного лица");gb.email.focus(); return false;}
 else if  (gb.question.value=="") {alert("Не введен вопрос");gb.question.focus(); return false;}
 else if  (gb.captcha_value.value=="") {alert("Отсутствует код подтверждения безопасности");gb.captcha_value.focus(); return false;}
 else return true;
}
function SubmitGB1(){
if (SubmitGB()) {document.gb.submit();}
}

function SubmitOrder(){
 if (register.flag.value == 1) {return true;}
 if  (register.hclient_type.value==0) 
 { 
   if (register.company.value=="") {alert("Пожалуйста, введите название компании");register.company.focus(); return false;};
   if (register.license.value=="") {alert("Отсутствует номер свидетельства компании");register.license.focus(); return false;};   
   if (register.tax_no.value=="") {alert("Отсутствует индивидуальный налоговый номер компании");register.tax_no.focus(); return false;};
   if (register.address.value=="") {alert("Отсутствует юридический адрес компании");register.address.focus(); return false;};
   if (register.captcha_value.value=="") {alert("Отсутствует код подтверждения безопасности");register.captcha_value.focus(); return false;};
 } 
 else if (register.hclient_type.value==1 && register.passport.value=="") {alert("Пожалуйста, введите паспортные данные");register.passport.focus(); return false;}

 if (register.surname.value=="") {alert("Пожалуйста, введите фимилию контактного лица");register.surname.focus(); return false;}
 else if  (register.name.value=="") {alert("Пожалуйста, введите имя контактного лица");register.name.focus(); return false;}
 else if  (register.contact_phone.value=="") {alert("Пожалуйста, введите телефон контактного лица");register.contact_phone.focus(); return false;}
 else if  (register.contact_email.value=="") {alert("Пожалуйста, введите E-mail контактного лица");register.contact_email.focus(); return false;}
 else if  (echeck(register.contact_email.value)== false) {alert("Неправильный  E-mail контактного лица");register.contact_email.focus(); return false;}
 else if  (register.delivery.selectedIndex==0 && register.delivery_street.value=="") {alert("Пожалуйста, введите улицу  адреса доставки");register.delivery_street.focus(); return false;}
 else if  (register.delivery.selectedIndex==0 && register.delivery_house.value=="") {alert("Пожалуйста, введите номер дома  адреса доставки");register.delivery_house.focus(); return false;}
 else if  (register.captcha_value.value=="") {alert("Отсутствует код подтверждения безопасности");register.captcha_value.focus(); return false;}
 else return true;
}

function SubmitOrder1(){
if (SubmitOrder()) {document.register.submit();}
}

function DeliveryControl(){
var ar=DeliveryControl.arguments;combo_id=ar[0];
	d=document.getElementsByName(combo_id)[0];
	if (d.tagName=="SELECT"){
		for (var i = 1; i < ar.length; i++) {
			el=document.getElementsByName(ar[i])[0];
			if (el.tagName=="INPUT"){el.disabled=(d.selectedIndex==1);}
		}	
		}
}
function SearchSubmit(){
 if  (search.search.value=="") {alert("Отсутствует строка поиска");search.search.focus(); return false;}
 else return true;
}


//=====================admin===========================
	function MM_openBrWindow(theURL,winName,features) {
		window.open(theURL,winName,features);
	}
	function decision(message, url){
		if(confirm(message)) location.href = url;
	}
	function DeleteAttachment(message, id){
		if(confirm(message)) {
		send_email.attach_id.value=id;
		document.send_email.submit();
		}
		
	}

	
function AddProductSubmit(){
 if  (add_product.cat_id.selectedIndex==0) {alert("Не выбрана категория");add_product.cat_id.focus(); return false;}
 else if  (add_product.articul.value=="" && !add_product.no_articul.checked) {alert("Не введен артикул");add_product.articul.focus(); return false;}
 else if  (add_product.title.value=="") {alert("Не введено наименование товара");add_product.title.focus(); return false;}
 else if  (add_product.price.value=="") {alert("Не введена цена товара");add_product.price.focus(); return false;} 
 else return true;
}
function EditProductSubmit(){
// if  (edit_product.cat_id.selectedIndex==0) {alert("Не выбрана категория");edit_product.cat_id.focus(); return false;}
 if  (edit_product.articul.value=="" && !edit_product.no_articul.checked) {alert("Не введен артикул");edit_product.articul.focus(); return false;}
 else if  (edit_product.title.value=="") {alert("Не введено наименование товара");edit_product.title.focus(); return false;}
 else if  (edit_product.price.value=="") {alert("Не введена цена товара");edit_product.price.focus(); return false;} 
 else {
 	if (edit_product.no_articul.checked) {edit_product.articul.value="";}
 	return true;
	}
}
function AddCategorySubmit(){
 if  (add_category.cat_name.value=="") {alert("Отсутствует название категории");add_category.cat_name.focus(); return false;}
 else return true;
}
function EditCategorySubmit(){
 if  (edit_category.cat_name.value=="") {alert("Отсутствует название категории");edit_category.cat_name.focus(); return false;}
// if  (edit_category.category.selectedIndex==0) {alert("Не выбрана категория");edit_category.category.focus(); return false;}
 else return true;
}

function AddNews(){
 if  (add_news.title.value=="") {alert("Не введен заголовок новости");add_news.title.focus(); return false;}
 else if  (add_news.full.value=="") {alert("Не введено содержание новости");add_news.full.focus(); return false;}
 else return true;
}
function AddICQ(){
 if  (add_icq.icq_no.value=="") {alert("Не введен номер ICQ");add_icq.icq_no.focus(); return false;}
 else if  (add_icq.fio.value=="") {alert("Не введено ФИО");add_icq.fio.focus(); return false;}
 else return true;
}

function AddAction(){
 if  (add_action.action_name.value=="") {alert("Отсутствует название акции");add_action.action_name.focus(); return false;}
 else if  (add_action.action_desc.value=="") {alert("Отсутствует краткое описание акции");add_action.action_desc.focus(); return false;}
 else if  (add_action.full_desc.value=="") {alert("Отсутствует полное описание акции");add_action.full_desc.focus(); return false;} 
 else return true;
}
function EditAction(){
 if  (add_action.title.value=="") {alert("Отсутствует название акции");add_action.title.focus(); return false;}
 else if  (add_action.description.value=="") {alert("Отсутствует краткое описание акции");add_action.description.focus(); return false;}
 else if  (add_action.full_desc.value=="") {alert("Отсутствует полное описание акции");add_action.full_desc.focus(); return false;} 
 else return true;
}
function AddPartner(){
 if  (add_partner.name.value=="") {alert("Отсутствует название");add_partner.name.focus(); return false;}
 else return true;
}
function EditPartner(){
 if  (edit_partner.name.value=="") {alert("Отсутствует название");edit_partner.name.focus(); return false;}
 else return true;
}
function AddProducer(){
 if  (add_producer.producer_name.value=="") {alert("Отсутствует название");add_producer.producer_name.focus(); return false;}
 else if  (add_producer.producer_desc.value=="") {alert("Отсутствует краткое описание");add_producer.producer_desc.focus(); return false;}
 else if  (add_producer.full_desc.value=="") {alert("Отсутствует полное описание");add_producer.full_desc.focus(); return false;} 
 else return true;
}
function EditProducer(){
 if  (edit_producer.title.value=="") {alert("Отсутствует название");edit_producer.title.focus(); return false;}
 else if  (edit_producer.description.value=="") {alert("Отсутствует краткое описание");edit_producer.description.focus(); return false;}
 else if  (edit_producer.full_desc.value=="") {alert("Отсутствует полное описание");edit_producer.full_desc.focus(); return false;} 
 else return true;
}
function AddVacancy(){
 if  (add_vacancy.post.value=="") {alert("Отсутствует должность");add_vacancy.post.focus(); return false;}
}
function EditVacancy(){
 if  (add_vacancy.post.value=="") {alert("Отсутствует должность");add_vacancy.post.focus(); return false;}
 else return true;
}
function EditClient(){
 if  (edit_client.login.value=="") {alert("Пожалуйста, введите логин");edit_client.login.focus(); return false;}
 else if  (edit_client.login.value.length>="20") {alert("Логин должен содержать менее 20 символов");edit_client.login.focus(); return false;}
// else if  (edit_client.password.value!=edit_client.pwd_confirm.value) {alert("Повторно введенный пароль не соответствует первичному");edit_client.pwd_confirm.focus(); return false;}
 else if  (edit_client.client_type.value=="u" && edit_client.company.value=="") {alert("Пожалуйста, введите название компании");edit_client.company.focus(); return false;}
 else if  (edit_client.client_type.value=="u" && edit_client.email.value!="" && echeck(edit_client.email.value)== false) {alert("Неправильный  E-mail компании");edit_client.email.focus(); return false;}
 else if  (edit_client.surname.value=="") {alert("Пожалуйста, введите фимилию контактного лица");edit_client.surname.focus(); return false;}
 else if  (edit_client.name.value=="") {alert("Пожалуйста, введите имя контактного лица");edit_client.name.focus(); return false;}
 else if  (edit_client.contact_phone.value=="") {alert("Пожалуйста, введите телефон контактного лица");edit_client.contact_phone.focus(); return false;}
 else if  (edit_client.contact_email.value=="") {alert("Пожалуйста, введите E-mail контактного лица");edit_client.contact_email.focus(); return false;}
 else if (echeck(edit_client.contact_email.value)== false) {alert("Неправильный  E-mail контактного лица");edit_client.contact_email.focus(); return false;}
 else return true;
}
function AddClient(){
 if  (edit_client.login.value=="") {alert("Пожалуйста, введите логин");edit_client.login.focus(); return false;}
 else if  (edit_client.login.value.length>="20") {alert("Логин должен содержать менее 20 символов");edit_client.login.focus(); return false;}
 else if  (edit_client.password.value!=edit_client.password_rep.value) {alert("Повторно введенный пароль не соответствует первичному");edit_client.password_rep.focus(); return false;}
 else if  (edit_client.client_type.value=="u" && edit_client.company.value=="") {alert("Пожалуйста, введите название компании");edit_client.company.focus(); return false;}
 else if  (edit_client.client_type.value=="u" && edit_client.email.value!="" && echeck(edit_client.email.value)== false) {alert("Неправильный  E-mail компании");edit_client.email.focus(); return false;}
 else if  (edit_client.surname.value=="") {alert("Пожалуйста, введите фимилию контактного лица");edit_client.surname.focus(); return false;}
 else if  (edit_client.name.value=="") {alert("Пожалуйста, введите имя контактного лица");edit_client.name.focus(); return false;}
 else if  (edit_client.contact_phone.value=="") {alert("Пожалуйста, введите телефон контактного лица");edit_client.contact_phone.focus(); return false;}
 else if  (edit_client.contact_email.value=="") {alert("Пожалуйста, введите E-mail контактного лица");edit_client.contact_email.focus(); return false;}
 else if (echeck(edit_client.contact_email.value)== false) {alert("Неправильный  E-mail контактного лица");edit_client.contact_email.focus(); return false;}
 else return true;
}
function AddGCat(){
 if  (add_cat.name.value=="") {alert("Отсутствует название раздела");add_cat.name.focus(); return false;}
  else if  ((add_cat.priority.value=="")||(!(IsNumber(add_cat.priority.value)))) {alert("Отсутствует или некорректно записан приоритет раздела");add_cat.priority.focus(); return false;}
 else return true;
}
function EditGCat(){
 if  (edit_cat.name.value=="") {alert("Отсутствует название раздела");edit_cat.name.focus(); return false;}
 else if  ((edit_cat.priority.value=="")||(!(IsNumber(edit_cat.priority.value)))) {alert("Отсутствует или некорректно записан приоритет раздела");edit_cat.priority.focus(); return false;}
 else return true;
}
function AddImage(){
 if  (add_new.name.value=="") {alert("Укажите название");add_new.name.focus(); return false;}
else if  (add_new.priority.value=="") {alert("Укажите приоритет!");add_new.priority.focus(); return false;}
 else return true;
}
function PostComment(){
 if  (admin_message.comment.value=="") {alert("Отсутствует коментарий");admin_message.comment.focus(); return false;}
 else if  (admin_message.begin.value=="") {alert("Отсутствует дата");admin_message.begin.focus(); return false;}
 else if  (admin_message.ins_time.value=="") {alert("Отсутствует время");admin_message.ins_time.focus(); return false;}
 else if  (!CheckTime(admin_message.ins_time.value)) {alert("Неправильный  формат времени. Ожидаемый формат 16:30");admin_message.ins_time.focus(); return false;}
 
 else return true;
}

function ClearFilter(){
 filter.state.selectedIndex=0;
 filter.period.selectedIndex=2;
 filter.ddlimit.selectedIndex=2;
 filter.start_date.value="";
 filter.end_date.value="";
 filter.searchStr.value="";
 filter.submit();
}
function AddGCat(){
 if  (add_cat.name.value=="") {alert("Отсутствует название раздела");add_cat.name.focus(); return false;}
  else if  ((add_cat.priority.value=="")||(!(IsNumber(add_cat.priority.value)))) {alert("Отсутствует или некорректно записан приоритет раздела");add_cat.priority.focus(); return false;}
 else return true;
}
function EditGCat(){
 if  (edit_cat.name.value=="") {alert("Отсутствует название раздела");edit_cat.name.focus(); return false;}
 else if  ((edit_cat.priority.value=="")||(!(IsNumber(edit_cat.priority.value)))) {alert("Отсутствует или некорректно записан приоритет раздела");edit_cat.priority.focus(); return false;}
 else return true;
}
function AddImage(){
 if  (add_new.name.value=="") {alert("Укажите название");add_new.name.focus(); return false;}
else if  (add_new.priority.value=="") {alert("Укажите приоритет!");add_new.priority.focus(); return false;}
 else return true;
}
function CheckAllDelete(obj, val)
{
	var obj_len=obj.length;
	for (i=0; i<obj_len; i++) {
		if(obj.elements[i].type=='checkbox') {
			obj.elements[i].checked=val;
		}
	}
}
function decision_mass_del(form_name)
{
  var d=document;
  
  if (form_name=="dictcats") {con='Вы хотите удалить выбранные записи? Вместе с ними будут удалены все содержимое справочников!!! Нажмите OK для подтверждения';}
  else if (form_name=="cats") {con='Вы хотите удалить выбранные записи? Вместе с ними будут удалены все прикрепленные услуги!!! Нажмите OK для подтверждения';}
  else {con='Вы хотите удалить выбранные записи? Нажмите OK для подтверждения';}
  if(confirm(con))
  {
    d.getElementById(form_name).submit();
    return true;
  }
  else
  {
    return false;
  } 
}
//-----------	MENU POPUP	------------//
var moz = (navigator.appName=="Netscape") ? true : false;
function showPopUp(event,id)
{
	var popUpDiv = document.getElementById(id);
	/*alert(event.srcElement.tagName);
	if (event.srcElement.tagName=="DIV"){*/
	 if(moz)
		{evn_x=event.pageX; evn_y=event.pageY;}
	 else 
		{evn_x=event.x+document.body.scrollLeft; evn_y=event.y+document.body.scrollTop;}
			popUpDiv.style.left = 190;

	popUpDiv.style.top = evn_y;
	popUpDiv.style.display="block";


	 
	return true;
}

function hidePopUp(id)
{
	var popUpDiv = document.getElementById(id);
	
	
	popUpDiv.style.display="none";
	
	return true;
}