function popup(l,n,w,h){
	s = screen;	
	win = window.open(l,n,'width='+w+',height='+h);	
	win.focus(); 
	win.moveTo(Math.ceil(s.width/2 - w/2),Math.ceil(s.height/2 - h/2 - 20));
	return false;
}

function checkValidForm(){
	with(document.forms['postform']){
		r_email = new RegExp("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$","ig");
		arr = r_email.exec(contact_email.value);
		error = "";
		if(contact_name.value.replace(/ /g,"")==""){error += 'Не указано имя\n';}
		if(arr==null){error += 'Неправильно указан Email\n';}
		if(contact_subject.value.replace(/ /g,"")==""){error += 'Не указана тема сообщения\n';}
		if(contact_content.value.replace(/ /g,"")==""){error += 'Пустое тело письма\n';}
		if(error!=''){error = 'Письмо не может быть отправлено по следующим причинам:\n-------------------------------------------------------------------------------\n' + error + '-------------------------------------------------------------------------------';alert(error);return false;}
		submit();
	}
}
function checkValidForm_price(){
	with(document.forms['price_post']){
		r_email = new RegExp("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$","ig");
		arr = r_email.exec(email.value);
		error = "";
		if(LastName.value.replace(/ /g,"")==""){error += 'Не указана фамилия\n';}
		if(FirstName.value.replace(/ /g,"")==""){error += 'Не указано имя\n';}
		if(CompanyName.value.replace(/ /g,"")==""){error += 'Не указано имя компании\n';}
		if(City.value.replace(/ /g,"")==""){error += 'Не указан город\n';}
		if(Phone.value.replace(/ /g,"")==""){error += 'Не указан контактный телефон\n';}
		if(arr==null){error += 'Неправильно указан Email\n';}
		if(error!=''){error = 'Прайс-лист не может быть загружен:\n-------------------------------------------------------------------------------\n' + error + '-------------------------------------------------------------------------------';alert(error);return false;}
		submit();
	}
}

function changeAddress(){
	with(document.forms['postform']){
		a = document.getElementById('em_adress');text = recipient.options[recipient.selectedIndex].value;
		a.innerHTML = 'Письмо: <a href="mailto:' + text + '" class="lmenub">' + text + '</a>';
	}
}

  var toggledDisplay = new Object();
      toggledDisplay['sub1'] = false;
      toggledDisplay['sub2'] = false;
      toggledDisplay['sub3'] = false;
      toggledDisplay['sub4'] = false;
      toggledDisplay['sub5'] = false;

  function toggleDisplay(bDisplayed)
  {
    if(!document.getElementById || toggleDisplay.arguments.length < 2) return;
    var displayed = new Object();
        displayed['true'] = 'block';
        displayed['false'] = 'none';
    for(var i = 1; i < toggleDisplay.arguments.length; i++)
    {
      oDisplay = document.getElementById(toggleDisplay.arguments[i]);
      if(oDisplay)
      {
        oDisplay.style.display = displayed[bDisplayed];
        // mozilla is the only browser out of the lot that can't get this right.  so, if we're
        // setting an object's display style to block, we gotta reload any images contained
        // within that block.  mozilla won't do it for you like every other browser that
        // supports the functionality of changing the display style dynamically.
        // being crap browser hack
        if(bDisplayed)
        {
          oImages = oDisplay.getElementsByTagName('IMG');
          for(var j = 0; j < oImages.length; j++)
            oImages[j].src = oImages[j].src;
        }
        // end mozilla, err, crap browser hack
         if(typeof toggledDisplay[toggleDisplay.arguments[i]] != 'undefined')
          toggledDisplay[toggleDisplay.arguments[i]] = !bDisplayed;
      }
    }
  }

  function toggleDiv(id){
	itm = document.getElementById(id);
	if(itm.style.display == 'none'){
		itm.style.display = 'block';
		document.getElementById(id + "_icon").src = "img/minus.gif";
	}
	else {
		itm.style.display = 'none';
		document.getElementById(id + "_icon").src = "img/plus.gif";
	}
	return false;
}
