function isgood(p, id)
{
	//alert(p)
	//alert(id)
	doLoad("tree", "isgood", id, p, "")

}
function toOrder()
{
	/*if(isIt(document.getElementById('company').value, "empty"))
	{
		alert("Заполните поле 'Компания'")	
		document.getElementById('company').focus()
		return false;
	}*/
	if(isIt(document.getElementById('mail').value, "empty"))
	{
		alert("Заполните поле 'E-mail'")	
		document.getElementById('mail').focus()
		return false;
	}

	if(isIt(document.getElementById('needs').value, "empty"))
	{
		alert("Заполните поле 'Вам требуется'")	
		document.getElementById('needs').focus()
		return false;
	}
	
	doLoad("qwest", "order", document.getElementById('form_order'), "", "")
}
function toguest()
{
	
	if(isIt(document.getElementById('qwest').value, "empty"))
	{
		alert("Заполните поле 'Заказ'")	
		document.getElementById('qwest').focus()
		return false;
	}
	if(isIt(document.getElementById('company').value, "empty"))
	{
		alert("Заполните поле 'Компания'")	
		document.getElementById('company').focus()
		return false;
	}
	if(isIt(document.getElementById('name').value, "empty"))
	{
		alert("Заполните поле 'ФИО'")	
		document.getElementById('name').focus()
		return false;
	}
	if(isIt(document.getElementById('contact').value, "empty"))
	{
		alert("Заполните поле 'Контакты'")	
		document.getElementById('contact').focus()
		return false;
	}
	
	doLoad("qwest", "guest", document.getElementById('form_guest'), "", "")
}
function toask()
{
	if(isIt(document.getElementById('qwest').value, "empty"))
	{
		alert("Заполните поле 'Вопрос'")	
		document.getElementById('qwest').focus()
		return false;
	}
	if(isIt(document.getElementById('company').value, "empty"))
	{
		alert("Заполните поле 'Компания'")	
		document.getElementById('company').focus()
		return false;
	}
	if(isIt(document.getElementById('name').value, "empty"))
	{
		alert("Заполните поле 'ФИО'")	
		document.getElementById('name').focus()
		return false;
	}
	if(isIt(document.getElementById('contact').value, "empty"))
	{
		alert("Заполните поле 'Контакты'")	
		document.getElementById('contact').focus()
		return false;
	}
	doLoad("qwest", "ask", document.getElementById('form_qwest'), "", "")
}
function toDivs(str)
{
	
  var divs=str.split("%;%")
  var name=divs[0].split("%,%")
  var data=divs[1].split("%,%")
  for(var i=0;i<name.length; i++)
  {
		document.getElementById(name[i]).innerHTML = data[i]
//	alert(name[i] + document.getElementById(name[i]).innerHTML)
  }
}
function doLoad(sender, command, param1, param2, param3)
{
	
     JsHttpRequest.query(
            '/load.php', // backend
            {
               sender : sender,
               command : command, 
               param1 : param1,
               param2 : param2,
               param3 : param3 
            },
            // Function is called when an answer arrives. 
            function(result, errors) 
           {
           	
           	 if (result['todivs']!=null && result['todivs']!="" )
			 {
			   toDivs(result['todivs'])
			 }
			 	   
			 if (result['message']!=null&&result['message']!="")
			 {    
				 alert(result['message'])
			 }
			 		 
            },
          true
        );
}
