var pic;
pic=0;
var resuest;
function createRequest() {
	try {
		request = new XMLHttpRequest();
	} catch (trymicrosoft) {
		try {
			request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (othermicrosoft) {
		try {
			request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (failed) {
			request = false;
		}
		}
	}

	if (!request)
		alert("Error initializing XMLHttpRequest!");
}

/*function getServerStatus(url){
	createRequest();
    //var url = "/auctions/torg/" +id+'?'+'nnn='+Math.floor(Math.random()*1000000);
    //alert(url);
    request.open("GET", url, true);
    request.onreadystatechange = Requeststatus;
    request.send(null);
}*/

function showTooltip(helpObj, helpName, e){
	if(helpObj.loaded){
		Tip(helpObj.loadedText, FIX, [helpObj.loadedX + 14, helpObj.loadedY + 8], CLOSEBTN, true);
		return;
	}
	x=e.clientX ;
	y=e.clientY + document.body.scrollTop;
	showLoading(e);
	url='/ajax/show_help.php';
	data='help_name='+helpName;
	var myAjax = new Ajax.Request(
			url,
			{method: 'post',
				parameters: data,
				onComplete: function(request){
						if(request.responseText){
							text=request.responseText;
						}else{
							text="Для данного раздела текст помощи не установлен";
						}
						helpObj.loadedText=text;
						helpObj.loaded=true;
						helpObj.loadedX=x;
						helpObj.loadedY=y;
						Tip(text, FIX, [x + 14, y + 8], CLOSEBTN, true, WIDTH, 500);
					}
			}
		);
}

function showLoading(e){
	Tip('Подождите, идет загрузка', CLOSEBTN, false);
}

function changeRegion(obj, cityObjId){
    cityObj=$(cityObjId);
	if(obj.value==0){
		cityObj.innerHTML='';
		return;
	}else{
		cityObj.innerHTML='Идет загрузка...';
		cityObj.style.display='block';
	}
	url='/ajax/change_region.php';
	data='region='+obj.value;
	var myAjax = new Ajax.Request(
			url,
			{method: 'post',
				parameters: data,
				onComplete: function(request){
					cityObj.style.display='block';
					cityObj.innerHTML=request.responseText;
				}
			}
	);

}

function sogl(uid,type,otz_id){
	if (uid){
		if (type=='1'){
			txt='Вы уверены что согласны с отзывом?';
			url='/ajax/soglnesogl.php?sogl=1&otz='+otz_id;
		}
		if (type=='2'){
			txt='Вы уверены что не согласны с отзывом?';
			url='/ajax/soglnesogl.php?sogl=2&otz='+otz_id;
		}
		if (type=='3'){
			txt='Вы уверены что отзыв некорректный?';
			url='/ajax/soglnesogl.php?sogl=3&otz='+otz_id;
		}
		if (confirm(txt)){
			createRequest();
			request.open("GET", url, true);
			//request.onreadystatechange = Requeststatus;
			request.send(null);
		var sgl=document.getElementById('kolvsogl'+otz_id).innerHTML-0;
		var nesgl=document.getElementById('kolvnesogl'+otz_id).innerHTML-0;
	if (type==1) sgl=sgl-0+1;
	if (type==2) nesgl=nesgl-0+1;
		 document.getElementById('soglunsogl'+otz_id).innerHTML='<span style="color:#000000;">Согласны</span>'+sgl+' / <span style="color:#000000;">Не согласны'+nesgl+'<span>';
		}
	}else{
		alert('Авторизуйтесь или зарегистрируйтесь!');
	}
}

