function getXmlHttp() {
  var xmlhttp;
  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
      xmlhttp = false;
    }
  }
 
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}

function light_on(obj,color) {
	obj.style.backgroundColor="#cccccc";
}

function light_off(obj) {
	obj.style.backgroundColor="transparent";
}

var ns6=document.getElementById&&!document.all?1:0 
var head="display:''" 
var folder='' 
function expandit(curobj){ 
	folder=ns6?curobj.nextSibling.nextSibling.style:document.all[curobj.sourceIndex+1].style 
		if (folder.display=="none") {
			folder.display="" 
		}else {
			folder.display="none" 
		}
}
function show_hide_text(divObj) {
    var div = divObj.parentNode.getElementsByTagName('div')[1];
    if (div.style.display == 'none') {
        div.style.display = 'block';
    } else {
        div.style.display = 'none';
    }
} 

function wo(url,w,h){
width = screen.width;
height = screen.height;
window.open(url+"&w="+w+"&h="+h, 'showpicture','width='+(w)+',height='+(h)+',left='+((width-w)/2)+',top=0,fullscreen=0,location=0,menubar=0,scrollbars=no,status=0,toolbar=0,resizable=yes');
}




var ie=document.all?1:0;
var ns=document.getElementById&&!document.all?1:0;

function InsertSmile(SmileId)
{
    if(ie)
    {
    document.all.text.focus();
    document.all.text.value+=" "+SmileId+" ";
    }

    else if(ns)
    {

    document.forms['reply'].elements['text'].focus();
    document.forms['reply'].elements['text'].value+=" "+SmileId+" ";
    }

    else
    alert("Ваш браузер не поддерживается!");
}




function v_korziny(id,name,price,img,article) {

  var korzina = document.getElementById("korzina");
  korzina.style.display = 'block';

  var xmlHttp;
  xmlHttp = getXmlHttp();
 
  var httpParams = "v_korziny=1&id="+ id +"&name="+ name +"&price="+ price +"&img="+ img +"&article="+ article;

  xmlHttp.onreadystatechange = function()  {
    if (xmlHttp.readyState == 4)
    {
      var response = xmlHttp.responseText;
      if (response.substring(0,3) == "200")
      {
        korzina.innerHTML = "" + response.substring(3);
      }
      else
      {
      }
    }
  }
 
  xmlHttp.open('POST', 'ajax.php', true);
  xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded;');
  xmlHttp.setRequestHeader('Content-length', httpParams.length);
  xmlHttp.setRequestHeader('Connection','close');
  xmlHttp.send(httpParams);  
}

function clear_korzina() {

  var korzina = document.getElementById("korzina");
  korzina.style.display = 'block';
  korzina.innerHTML = "&nbsp";

  var xmlHttp;
  xmlHttp = getXmlHttp();
 
  var httpParams = "clear=1";
 
  xmlHttp.onreadystatechange = function()  {
    if (xmlHttp.readyState == 4)
    {
      var response = xmlHttp.responseText;
      if (response.substring(0,3) == "200")
      {
        korzina.innerHTML = "<div class=\"t\">закладок нету</div>";
		  loading_end();
      }
      else
      {
        korzina.innerHTML = "no data";
		  loading_end();
      }
    }
  }
 
  xmlHttp.open('POST', 'ajax.php', true);
  xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded;');
  xmlHttp.setRequestHeader('Content-length', httpParams.length);
  xmlHttp.setRequestHeader('Connection','close');
  xmlHttp.send(httpParams);  
}

function del_from(i) {

  var korzina = document.getElementById("korzina");
  korzina.style.display = 'block';
  korzina.innerHTML = "&nbsp";

  var xmlHttp;
  xmlHttp = getXmlHttp();
 
  var httpParams = "del_from="+i;
 
  xmlHttp.onreadystatechange = function()  {
    if (xmlHttp.readyState == 4)
    {
      var response = xmlHttp.responseText;
      if (response.substring(0,3) == "200")
      {
        korzina.innerHTML = "" + response.substring(3);
		  loading_end();
      }
      else
      {
		  loading_end();
      }
    }
  }
 
  xmlHttp.open('POST', 'ajax.php', true);
  xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded;');
  xmlHttp.setRequestHeader('Content-length', httpParams.length);
  xmlHttp.setRequestHeader('Connection','close');
  xmlHttp.send(httpParams);  
}

function tov(i) {

  var xmlHttp;
  xmlHttp = getXmlHttp();
 
  var httpParams = "tov="+ i;
 
  xmlHttp.onreadystatechange = function()  {
    if (xmlHttp.readyState == 4)
    {
      var response = xmlHttp.responseText;
      if (response.substring(0,3) == "200")
      {
        korzina.innerHTML = "" + response.substring(3);
		  loading_end();
      }
      else
      {
		  loading_end();
      }
    }
  }
 
  xmlHttp.open('POST', 'ajax.php', true);
  xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded;');
  xmlHttp.setRequestHeader('Content-length', httpParams.length);
  xmlHttp.setRequestHeader('Connection','close');
  xmlHttp.send(httpParams);  
}


//////////////////////
////////////////////// Регистрация
//////////////////////
//////////////////////

function load_form(mm) {
  	var form = document.getElementById("load_form");
	var targ = document.getElementById("target_buy");

  var xmlHttp;
  xmlHttp = getXmlHttp();
 
  var httpParams = "load_form=" + mm;
 
  xmlHttp.onreadystatechange = function()  {
    if (xmlHttp.readyState == 4)
    {
      var response = xmlHttp.responseText;
      if (response.substring(0,3) == "200")
      {
		targ.style.display = 'none';
        form.style.display = 'block';
        form.innerHTML = "" + response.substring(3);
      }
      else
      {
      	 form.style.display = 'block';
         form.innerHTML = "" + response.substring(3);
      }
    }
  }

  xmlHttp.open('POST', 'ajax.php', true);
  xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=windows-1251');
  xmlHttp.setRequestHeader('Content-length', httpParams.length);
  xmlHttp.setRequestHeader('Connection','close');
  xmlHttp.send(httpParams);  
}

function check_user() {
  var sUsername = document.getElementById("user").value;
 
  var user_ = document.getElementById("user_");
  var error = document.getElementById("error");
  error.style.display = 'block';
  error.innerHTML = "&nbsp";
 
  var xmlHttp;
  xmlHttp = getXmlHttp();
 
  var httpParams = "check_user=" + sUsername;
 
  xmlHttp.onreadystatechange = function()  {
    if (xmlHttp.readyState == 4)
    {
      var response = xmlHttp.responseText;
      if (response.substring(0,3) == "200")
      {
        user_.innerHTML = "" + response.substring(3);
      }
      else
      {
        user_.innerHTML = "" + response.substring(3);
        error.innerHTML = "Такой пользователь уже существует";
      }
    }
  }

  xmlHttp.open('POST', 'ajax.php', true);
  xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=windows-1251');
  xmlHttp.setRequestHeader('Content-length', httpParams.length);
  xmlHttp.setRequestHeader('Connection','close');
  xmlHttp.send(httpParams);  
}

function check_pass() {
  var sPass = document.getElementById("pass").value;
 
  var pass_ = document.getElementById("pass_");
 
  var error = document.getElementById("error");
  error.style.display = 'block';
  error.innerHTML = "&nbsp";
 
  var xmlHttp;
  xmlHttp = getXmlHttp();
 
  var httpParams = "check_pass=" + sPass;
 
  xmlHttp.onreadystatechange = function()  {
    if (xmlHttp.readyState == 4)
    {
      var response = xmlHttp.responseText;
      if (response.substring(0,3) == "200")
      {
        pass_.innerHTML = "" + response.substring(3);
      }
      else
      {
        pass_.innerHTML = "" + response.substring(3);
        error.innerHTML = "Пароль должен быть более 5 символов";
      }
    }
  }
 
  xmlHttp.open('POST', 'ajax.php', true);
  xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=windows-1251');
  xmlHttp.setRequestHeader('Content-length', httpParams.length);
  xmlHttp.setRequestHeader('Connection','close');
  xmlHttp.send(httpParams);  
}


function check_confirm() {
  var sPass = document.getElementById("pass").value;
  var sPass_confirm = document.getElementById("pass_confirm").value; 

  var pass_confirm_ = document.getElementById("pass_confirm_");
 
  var error = document.getElementById("error");
  error.style.display = 'block';
  error.innerHTML = "&nbsp";
 
  var xmlHttp;
  xmlHttp = getXmlHttp();
 
  var httpParams = "check_confirm=" + sPass + "&confirm=" + sPass_confirm;
 
  xmlHttp.onreadystatechange = function()  {
    if (xmlHttp.readyState == 4)
    {
      var response = xmlHttp.responseText;
      if (response.substring(0,3) == "200")
      {
        pass_confirm_.innerHTML = "" + response.substring(3);
      }
      else
      {
        pass_confirm_.innerHTML = "" + response.substring(3);
        error.innerHTML = "Пароль должен быть более 5 символов";
      }
    }
  }
 
  xmlHttp.open('POST', 'ajax.php', true);
  xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=windows-1251');
  xmlHttp.setRequestHeader('Content-length', httpParams.length);
  xmlHttp.setRequestHeader('Connection','close');
  xmlHttp.send(httpParams);  
}

function check_mail() {
  var sMail = document.getElementById("mail").value;

  var mail_ = document.getElementById("mail_");
 
  var error = document.getElementById("error");
  error.style.display = 'block';
  error.innerHTML = "&nbsp";
 
  var xmlHttp;
  xmlHttp = getXmlHttp();
 
  var httpParams = "check_mail=" + sMail;
 
  xmlHttp.onreadystatechange = function()  {
    if (xmlHttp.readyState == 4)
    {
      var response = xmlHttp.responseText;
      if (response.substring(0,3) == "200")
      {
        mail_.innerHTML = "" + response.substring(3);
      }
      else if(response.substring(0,3) == "501")
      {
        mail_.innerHTML = "" + response.substring(3);
        error.innerHTML = "Такой e-mail уже есть в базе";
      }
	  else 
      {
        mail_.innerHTML = "" + response.substring(3);
        error.innerHTML = "Неправильный формат e-mail";
      }
    }
  }
 
  xmlHttp.open('POST', 'ajax.php', true);
  xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=windows-1251');
  xmlHttp.setRequestHeader('Content-length', httpParams.length);
  xmlHttp.setRequestHeader('Connection','close');
  xmlHttp.send(httpParams);  
}


//////////////
//////////////
//////////////
//////////////

