/* Change width of banner due to width of content div */
$(document).ready(function(){
	var content=$("#content")
	var w=content.css("width")
	$("#banner").width(w)
	$("#banner").show();
});



function checkMsg()
{
  var alerttext="Заполните, пожалуйста, все обязательные поля";
  var nc=true;
	if (document.msender.specialist.selectedIndex<1) {
	  document.msender.specialist.style.color="red";
      document.getElementById('alert').innerHTML=alerttext;
	  nc=false;
	}
	if (isEmpty(document.msender.name)) {
      document.getElementById('alert').innerHTML=alerttext;
	  nc=false;
	}
	if (isEmpty(document.msender.telephon)) {
      document.getElementById('alert').innerHTML=alerttext;
	  nc=false;
	}
	if (!nc) {
	  return nc;
	}
	document.msender.submit();
}

function checkMsgCustom()
{
  var alerttext="Заполните, пожалуйста, все обязательные поля";
  var nc=true;
	if (isEmpty(document.msender.name)) {
      document.getElementById('alert').innerHTML=alerttext;
	  nc=false;
	}
	if (isEmpty(document.msender.telephon)) {
      document.getElementById('alert').innerHTML=alerttext;
	  nc=false;
	}
	if (!nc) {
	  return nc;
	}
	document.msender.submit();
}

// переключаем видимость элемента
function toggle(mnid) {
        var elem = document.getElementById(mnid);
	if (elem) {
	  if (elem.style.display == 'none') {
		elem.style.display = 'block';
        } else {
		elem.style.display = 'none';
        }
	  
	}
	
}


function tbTestFocus(o){
  if (o.firstTime) {
   return;
  }
  o.firstTime = true;
  o.savedValue = o.value;
  o.value = "";
}

function tbTestBlur(o) {
  if (o.firstTime && o.value == "") {
    o.value = o.savedValue;
	o.firstTime = false;
	o.savedValue = "";
  }
}

function isEmpty(aTextField) {
   if ((aTextField.value.length==0) ||
   (aTextField.value==null) || aTextField.savedValue == "" ||  aTextField.savedValue==null) {
	  aTextField.style.color="red";
      return true;
   }
   else { return false; }
}
