function addHintToInputs()
{
  var inputs = document.getElementsByTagName("input");
  for (var i = 0; i < inputs.length; i++)
  {
    if(inputs[i].title)
    {
      inputs[i].onfocus = hideInputHint;
      inputs[i].onblur = showInputHint;
      showInputHint(inputs[i]);
    }
  }
  var inputs = document.getElementsByTagName("textarea");
  for (var i = 0; i < inputs.length; i++)
  {
    if(inputs[i].title)
    {
      inputs[i].onfocus = hideInputHint;
      inputs[i].onblur = showInputHint;
      showInputHint(inputs[i]);
    }
  }

}

function showInputHint(e)
{
  var item;
  if(e && typeof(e.target) == "object")
    item = e.target;
  else if(typeof(e) == "object")
    item = e;
  else if(window.event && e.srcElement)
    item = e.srcElement;

  if(item && item.title && !item.value ) 
    item.style.backgroundImage = "url(/img/hint/" + item.title + ".png)";
  else if(item)
    hideInputHint(item);
}

function hideInputHint(e)
{
  var item;
  if(e && typeof(e.target) == "object")
    item = e.target;
  else if(typeof(e) == "object")
    item = e;
  else if(window.event && e.srcElement)
    item = e.srcElement;

  if(item)
    item.style.backgroundImage = "";
}

function cssAddClass(item, className){
    if(item)
        item.className += " " + className;
}
function cssRemoveClass(item, className){
    var reClass=new RegExp(className,"");
    if (item && item.className)
        item.className = item.className.replace(reClass,'');
}
function cssSetClass(item, className){
    if(item)
    {
        item.setAttribute('className',className);
        item.setAttribute('class', className);
    }
}
function enableElement(elem){
    elem.disabled = false;
    cssSetClass(elem, '');
}
function disableElement(elem){
    elem.disabled = true;
    cssSetClass(elem, 'disabled');
}


function page_feedback_send()
{
  if((document.feedbackForm.subject.value != 0)
     && document.feedbackForm.sender_name.value
     && document.feedbackForm.sender_email.value
     && document.feedbackForm.message.value)
  {
    document.getElementById("feedbackFormSubmit").style.backgroundImage = "url(/img/ajax.gif)";
    document.getElementById("feedbackFormSubmit").style.paddingRight = "20px";
    document.feedbackForm.submit();
  }
  else
  {
    alert("для отправки сообщения заполните все поля и выберите тему");
  }
}

function page_wizard_send()
{
    // step1
    if(document.wizardForm.step.value == "1")
        if(document.wizardForm.email.value)
            document.wizardForm.submit();
        else
            alert("введите адрес электронной почты");

    // step2
    if(document.wizardForm.step.value == "2")
        if(document.wizardForm.firstname.value && document.wizardForm.lastname.value && (document.wizardForm.status.value != 0))
            document.wizardForm.submit();
        else 
            alert("введите имя, фамилию и выберите свой статус");
      
    if(document.wizardForm.step.value == "3")
        if(document.wizardForm.phone.value && (document.wizardForm.code.value != 0))
            document.wizardForm.submit();
        else 
            alert("выберите код оператора и введите номер телефона");

    if(document.wizardForm.step.value == "4")
        if(document.wizardForm.password.value)
            document.wizardForm.submit();
        else
            alert("введите пароль");

}

function page_forgot_send()
{
  if(document.forgotForm.email.value)
  {
    document.getElementById("forgotFormSubmit").style.backgroundImage = "url(/img/ajax.gif)";
    document.getElementById("forgotFormSubmit").style.paddingRight = "20px";
    document.forgotForm.submit();
  }
  else
  {
    alert("для восстановления пароля введите e-mail");
  }
}

function isValueInArray(arr, val) {
    if(!arr) return false;
    for (i = 0; i < arr.length; i++)
        if (val == arr[i]) return true;
    return false;
}


