/*Script form */
//Script labzy )))
var scrH;
var scrW;
var form;
var shad;
var textArea;
var timer;
var load;
function showForm()
{
  

	// alert(scrH+'////'+scrW);
	 scrH = (screen.availHeight-600)/2;
	 scrW = (screen.availWidth-600)/2;
	  form = document.getElementById('quest');
	  shad = document.getElementById('shadow');
	  shad.style.display='block';
	    form.style.top = scrH+'px';
		 form.style.left = scrW+'px';
	      form.style.display = 'block';
		  textArea = document.shd.text.value;
 
}
function closeForm()
{
      var shad = document.getElementById('shadow');

     shad.style.display='';
     form.style.display = '';

}
function checkForm ()
{
//alert(document.shd.text.value.length)
  if((document.shd.text.value.length-1)!=0 && document.shd.email.value.length!=0 && (document.shd.text.value)!=textArea)
  {
   	var xmlHttp = createXmlHttpRequestObject();
	   xmlHttp.open('post', 'post_mail.php' , true ); 
	   xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); 
	   var name = document.shd.nick.value;
	   var email = document.shd.email.value;
	   var tel = document.shd.tel.value;
	   var cat = document.shd.sel.value;
	   var txt = document.shd.text.value;
	   var query = 'name='+name+'&email='+email+'&tel='+tel+'&cat='+cat+'&txt='+txt;
	   xmlHttp.send(query);
	      var f = document.getElementById('form_question');
         f.style.display='none';
	   //timer = setInterval(cross,2000);
           load = document.createElement('img');
		  load.setAttribute('src','/templates/labaz/images/load.gif');
		  load.style.paddingLeft='150px';
		   form.appendChild(load);
		   setTimeout(than,5000);

	
  }else
  {
    if(document.shd.email.value.length==0)
	{
	    alert("Введите ICQ или Почту");
	}
     if((document.shd.text.value.length-1) == 0 || (document.shd.text.value)==textArea)
	 {
	     alert("Введите Ваш вопрос");
	 }
  }
   

}
function than()
{
  load.parentNode.removeChild(load);
   form.style.height=200+'px';
    form.style.backgroundImage="url(/templates/labaz/images/fon_form_small.png)";
	var y = document.getElementById('em');
	  y.style.display='none';
  y = document.getElementById('senk');
  y.style.display='block';
  setTimeout(closeForm,6000);
 }
function createXmlHttpRequestObject()
{
  var xmlHttp;
  if(window.ActiveXObject) 
    {
			try
			{
			  xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
			}
			catch(e)
			{
			  xmlHttp = false;
			
			}
    
  
    }else
    {
		 try 
		 {
		 xmlHttp = new XMLHttpRequest();
		  }
			catch(e)
			{	  
			   xmlHttp = false;
			}
		
    }
 

   if(!xmlHttp)
   {
     alert('Извините ошибка !!! Попробуйте через 1 мин.');
   }else
     {return xmlHttp;}

}

