var xmlHttp;

	try {
		xmlHttp=new XMLHttpRequest();


	}
	catch(e) {
		var XmlHttpVersions=new Array('MSXML2.XMLHTTP.6.0', 'MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP');
		
		for(var i=0; i<XmlHttpVersions.length && !xmlHttp; i++) {
			try {
				xmlHttp = new ActiveXObject(XmlHttpVersions[i]);

			
			}
			catch(e) {}
		}
	}

	if(!xmlHttp) alert("Ошибка создания объекта XMLHttpRequest.");
	
	
	//Проверяем правильность введенного кода
function ochko() {
	
//	alert(entry.value);
	
	var gaga=document.getElementById('intext').value;
	
	zapros="fuck="+gaga;
	
	if(xmlHttp) {	
	//showtimer();
	if(xmlHttp.readyState==4 || xmlHttp.readyState==0) {
		xmlHttp.open("POST", "/ok_code.php", true);
		xmlHttp.onreadystatechange=handleServerResponse37;
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.send(zapros);	
	}
	else setTimeout('ochko()', 1000);
			}
}
function handleServerResponse37() {
if(xmlHttp.readyState==4) {
		if(xmlHttp.status==200) {
			response = xmlHttp.responseText;
		document.getElementById('outcode').value=response;
	//hidetimer();
	}
		else setTimeout('handleServerResponse37()', 500);
	}
}


//Функция к-ва оставшихся символов
function checkin(entry) {
	
	var doss=entry.value.length;
	
		var cifra=250-doss;
	
	if(entry.value.length>250) document.getElementById('provided_services_input_counter').innerHTML=0;
	else document.getElementById('provided_services_input_counter').innerHTML=cifra;
	
	
}


function chekdomen(entry) {
    
 
    
    
    
    zapros="fuck="+entry;
	
   // alert(zapros);
    
	if(xmlHttp) {	
	//showtimer();
	if(xmlHttp.readyState==4 || xmlHttp.readyState==0) {
		xmlHttp.open("POST", "/checkdomen.php", true);
		xmlHttp.onreadystatechange=handleServerResponse47;
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.send(zapros);	
	}
	else setTimeout('chekdomen("'+entry+'")', 1000);
			}
    
}

function handleServerResponse47() {
if(xmlHttp.readyState==4) {
		if(xmlHttp.status==200) {
			response = xmlHttp.responseText;
		document.getElementById('zver').innerHTML=response;
	//hidetimer();
	}
		else setTimeout('handleServerResponse47()', 500);
	}
}




//Функция добавления группы товаров
function koni(entry) {
	
	if(entry.value==0) {
		
		var answer=prompt("Название группы:");
		if(answer) {
			
		//	var gaga=document.getElementById('intext').value;
	
	zapros="name="+answer;
	
	if(xmlHttp) {	
	//showtimer();
	if(xmlHttp.readyState==4 || xmlHttp.readyState==0) {
		xmlHttp.open("POST", "addgrup.php", true);
		xmlHttp.onreadystatechange=handleServerResponse371;
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.send(zapros);	
	}
	else setTimeout('koni('+entry+')', 1000);
			}
		}
		
		
	}
	
}


function handleServerResponse371() {
if(xmlHttp.readyState==4) {
		if(xmlHttp.status==200) {
			response = xmlHttp.responseText;
		document.getElementById('falos').innerHTML=response;
	//hidetimer();
	}
		else setTimeout('handleServerResponse371()', 500);
	}
}



function zont(page) {
    
    
    var ids=parseInt(document.getElementById('group_input').value);
    
    if(ids>0) location.href='/index.php?page='+page+'&del_grup='+ids;
    
    
}


//Функция выбора подкатегории
function categorySelected(entry, level) {
	

			
		//	var gaga=document.getElementById('intext').value;
	
	zapros="id="+entry.value+"&level="+level;
	
	if(xmlHttp) {	
	//showtimer();
	if(xmlHttp.readyState==4 || xmlHttp.readyState==0) {
		xmlHttp.open("POST", "selectcategory.php", true);
		xmlHttp.onreadystatechange=handleServerResponse372;
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.send(zapros);	
	}
	else setTimeout('categorySelected('+entry+', '+level+')', 1000);
			}
		
		
		
	}
	



function handleServerResponse372() {
if(xmlHttp.readyState==4) {
		if(xmlHttp.status==200) {
			response = xmlHttp.responseText;
		document.getElementById('koza1').innerHTML=response;
	//hidetimer();
	}
		else setTimeout('handleServerResponse372()', 500);
	}
}

























function categorySelected1(entry, level) {
	

			
		//	var gaga=document.getElementById('intext').value;
	
	zapros="id="+entry.value+"&level="+level;
	
	if(xmlHttp) {	
	//showtimer();
	if(xmlHttp.readyState==4 || xmlHttp.readyState==0) {
		xmlHttp.open("POST", "selectcategory1.php", true);
		xmlHttp.onreadystatechange=handleServerResponse373;
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.send(zapros);	
	}
	else setTimeout('categorySelected1('+entry+', '+level+')', 1000);
			}
		
		
		
	}
	



function handleServerResponse373() {
if(xmlHttp.readyState==4) {
		if(xmlHttp.status==200) {
			response = xmlHttp.responseText;
		document.getElementById('koza2').innerHTML=response;
	//hidetimer();
	}
		else setTimeout('handleServerResponse373()', 500);
	}
}

















function categorySelected2(entry, level) {
	

			
		//	var gaga=document.getElementById('intext').value;
	
	zapros="id="+entry.value+"&level="+level;
	
	if(xmlHttp) {	
	//showtimer();
	if(xmlHttp.readyState==4 || xmlHttp.readyState==0) {
		xmlHttp.open("POST", "selectcategory2.php", true);
		xmlHttp.onreadystatechange=handleServerResponse374;
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.send(zapros);	
	}
	else setTimeout('categorySelected2('+entry+', '+level+')', 1000);
			}
		
		
		
	}
	



function handleServerResponse374() {
if(xmlHttp.readyState==4) {
		if(xmlHttp.status==200) {
			response = xmlHttp.responseText;
		document.getElementById('koza3').innerHTML=response;
	//hidetimer();
	}
		else setTimeout('handleServerResponse374()', 500);
	}
}











function golos(vote,ids) {
	

	

	
	zapros="id="+ids+"&vote="+vote;
	
	if(xmlHttp) {	
	//showtimer();
	if(xmlHttp.readyState==4 || xmlHttp.readyState==0) {
		xmlHttp.open("POST", "/golos.php", true);
		xmlHttp.onreadystatechange=handleServerResponse671;
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.send(zapros);	
	}
	else setTimeout('golos('+vote+','+ids+')', 1000);
			}
}
function handleServerResponse671() {
if(xmlHttp.readyState==4) {
		if(xmlHttp.status==200) {
			response = xmlHttp.responseText;
		if(response=='ok') {}
        else alert("Вы проголосовали за это фото");
	//hidetimer();
	}
		else setTimeout('handleServerResponse671()', 500);
	}
}

















//Сохранение к-ва
function savesum(entry, ids) {
	

			
			var kvo=document.getElementById('shtyk'+entry).value;
	
	zapros="kvo="+kvo+"&ids="+ids;
	
	if(xmlHttp) {	
	//showtimer();
	if(xmlHttp.readyState==4 || xmlHttp.readyState==0) {
		xmlHttp.open("POST", "/savesum.php", true);
		xmlHttp.onreadystatechange=handleServerResponse672;
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.send(zapros);	
	}
	else setTimeout('savesum('+entry+', '+ids+')', 1000);
			}
		
		
		
	}
	
function handleServerResponse672() {
if(xmlHttp.readyState==4) {
		if(xmlHttp.status==200) {
			response = xmlHttp.responseText;
	
	//hidetimer();
	}
		else setTimeout('handleServerResponse672()', 500);
	}
}



//Выбор городов по области
function reple12(entry) {
	
//	alert(entry.value);
	

	
	zapros="id="+entry.value;
	
	if(xmlHttp) {	
	//showtimer();
	if(xmlHttp.readyState==4 || xmlHttp.readyState==0) {
		xmlHttp.open("POST", "/goroda.php", true);
		xmlHttp.onreadystatechange=handleServerResponse3742;
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.send(zapros);	
	}
	else setTimeout('reple12('+entry+')', 1000);
			}
			
			
}
function handleServerResponse3742() {
if(xmlHttp.readyState==4) {
		if(xmlHttp.status==200) {
			response = xmlHttp.responseText;
		document.getElementById('mmmm12').innerHTML=response;
	//hidetimer();
	}
		else setTimeout('handleServerResponse3742()', 500);
	}
}

function ptp(form) {
    if(form.message.value=='' || form.message.value=='Текст сообщения' || form.email.value=='' || form.email.value=='Введите Ваш e-mail') {alert('Заполните поля'); return false;}
    else return true;
}

function napis(email) {
    
    document.getElementById('truba').innerHTML='<form method="post" id="rudik"><input type="hidden" name="komu" value="'+email+'" /><p><textarea name="message" rows="6" style="width:100%">Текст сообщения</textarea></p><p><input type="text" name="email" value="Введите Ваш e-mail" /></p><input type="button" value="Отправить" onclick="if(ptp(this.form)) {document.getElementById(\'rudik\').submit();}" /></form>';
    document.getElementById('truba').style.display='';
    document.getElementById('napis').style.display='none';  
}
