var mangi=["выбирете", "наличные", "Webmoney", "PayPal", "Яндекс.Деньги", "AlertPay", "Contact", "C-Gold", "DeltaPay", "E-gold","EasyPay","ePassporte","EDram","Fethard","HandyBank","iMoney","InoCard","IntellectMoney","LiqPay","Liberty Reserve","MOBI.Деньги","MoneyMail","Moneta","Moneybookers","PayPlat","Pecunix","Perfect Money","RBK Money","Ukash","W1","WebCreds","Z-payment","иные"];
var region=["любой", "Беларусь", "Минск", "Брест", "Витебск", "Гомель", "Гродно", "Могилев","Украина","Вінниця","Дніпропетровськ","Донецьк","Житомир","Ужгород","Запорізьк","Івано-Франківськ","Київ","Кіровоград","Крим","Луганськ","Луцьк","Львів","Миколаїв","Одеса","Полтава","Рівне","Суми","Тернопіль","Харків","Херсон","Хмельницький","Черкаси","Чернівці","Чернігів"];
var razmer=["любой","до 100","до 300","до 500","до 1000"];
var city=[];
city[0]=["любой","Беларусь","Украіна","Россия","Армения","Azarbaycan","Грузия","Казакстан","Кыргызстан","Latvija","Lietuva", "Moldova","Ўзбекистон","Точикистон","Turkmenistan","Eesti","Другие"];
city[1]=['Минск', 'Брест', 'Витебск', 'Гомель', 'Гродно','Могилев'];
city[2]=['Вінниця','Дніпропетровськ','Донецьк','Житомир','Ужгород','Запорізьк','Івано-Франківськ','Київ','Кіровоград','Крим','Луганськ','Луцьк','Львів','Миколаїв','Одеса','Полтава','Рівне','Суми','Тернопіль','Харків','Херсон','Хмельницький','Черкаси','Чернівці','Чернігів'];
city[3]=["Абакан","Анапа","Архангельск","Астрахань","Барнаул","Белгород","Бийск","Благовещенск","Братск","Брянск","Владивосток", "Владикавказ","Владимир","Волгоград","Вологда","Воронеж","Выборг","Геленджик","Горно-Алтайск","Грозный","Домбай", "Екатеринбург","Ессентуки","Железноводск","Иваново","Ижевск","Иркутск","Йошкар-Ола","Казань","Калининград","Калуга","Кемерово","Киров","Кисловодск","Кострома","Краснодар","Красноярск","Курган","Курск", "Кызыл","Липецк","Магадан","Магнитогорск","Майкоп","Москва","Мурманск","Набережные Челны","Нальчик","Находка", "Нижневартовск","Нижний Новгород","Нижний Тагил","Новгород","Новокузнецк","Новороссийск","Новосибирск","Норильск", "Омск", "Орел","Оренбург","Пенза","Переславль-Залесский","Пермь","Петрозаводск","Петропавловск-Камчатский","Псков","Пятигорск", "Ростов-на-Дону","Рязань","Салехард","Самара","Санкт-Петербург","Саранск","Саратов","Смоленск","Сочи","Ставрополь","Суздаль", "Сургут","Сыктывкар","Тамбов","Тверь","Тольятти","Томск","Туапсе","Тула","Тюмень","Улан-Удэ","Ульяновск","Уфа","Хабаровск", "Ханты-Мансийск","Чебоксары","Челябинск","Чита","Южно-Сахалинск","Якутск","Ярославль"];
city[4]=[]; city[5]=[];city[6]=[];city[7]=[];city[8]=[];city[9]=[];city[10]=[];city[11]=[];city[12]=[];city[13]=[];city[14]=[];city[15]=[];city[16]=[];
var trM=[];
var tdM=[];
var txtM=[];
var imgM=[];
var aM=[];
var inputM=[];
var inputMm=[]; opt=[]; optTxt=[]; podopt=[];podoptTxt=[];


//------------------------------------------------------------------------------------------------------------------------------------------
/* Создание нового объекта XMLHttpRequest для общения с Web-сервером */
var xmlHttp = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp = false;
  }
}
@end @*/

if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}

//------------------------------------------------------------------------------------------------------------------------------------------
//проверка на ввод в поле логина
function chkLogin() {
pp = document.getElementById("ppLogin").value;
nick = document.getElementById("nick").value;
butn_login = document.getElementById("butn_login");
if ((nick.length>=3)&&(pp.length>=4)) {
	butn_login.removeAttribute("disabled");	}
else { butn_login.setAttribute("disabled","disabled");	}

}

function waitLoad() {
clearWorkspace();
tr=document.createElement("tr");
tr.setAttribute("align", "center");
LoadGr = document.createElement("img");
LoadGr.setAttribute("src","../img/LoadingGraphic.gif");
tr.appendChild(LoadGr);
sel.appendChild(tr);
}
//------------------------------------------------------------------------------------------------------------------------------------------
//вход
function login() {
var nick = document.getElementById("nick").value;
var pswd = document.getElementById("ppLogin").value;
var url = '../beer/login.php?nick=' + escape(nick)+'&pswd='+escape(pswd);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = loginOk;
xmlHttp.send(null);
}

function loginOk() {
if (xmlHttp.readyState < 4)	{ waitLoad();}
else {
var logged =xmlHttp.responseText.split("|");
if (logged[1]!=undefined) {
clearWorkspace();
NAME = logged[1];
ID = logged[0];
RE=logged[2]
ACC=logged[3];
MyACC=logged[4];
formLogin = document.getElementById("formlogin");
first = document.getElementById("first");
first.removeChild(formLogin);
TableNew = document.createElement("table");
TableNew.setAttribute("id", "TableNew");
tr = document.createElement("tr");
td = document.createElement("td");
user = document.createTextNode("Привет, "+NAME+" ");
	first.appendChild(TableNew);
	TableNew.appendChild(tr);
	td.appendChild(user);
	tr.appendChild(td);
TableNew.appendChild(tr);
buttonOut=document.createElement("input");
buttonOut.setAttribute("type", "button");
buttonOut.setAttribute("id", "buttonOut");
buttonOut.setAttribute("value", "Выход");
buttonOut.setAttribute("onclick", "logout()");
	td.appendChild(buttonOut);	
td2 = document.createElement("td");
tr2 =  document.createElement("tr");
	TableNew.appendChild(tr2);
	tr2.appendChild(td2);

menuTable = document.createElement("table");
menuTable.setAttribute("id", "menu");
	td2.appendChild(menuTable);
trDann = document.createElement("tr");
tdDann = document.createElement("td");
trDann.setAttribute("id", "dann");
tdNeedDann = document.createElement("td");
tdNeedDann.setAttribute("id", "needDann");
aNeedDann = document.createElement("a");
aNeedDann.setAttribute("href", "javascript:void(0)");
aNeedDann.setAttribute("onclick", "owait('1')");
txtNeedDann = document.createTextNode("Ждут оценки");
aDann = document.createElement("a");
aDann.setAttribute("href", "javascript:void(0)");
aDann.setAttribute("onclick", "myData(ID)");
txtDann = document.createTextNode("Мои данные");
	menuTable.appendChild(trDann);
	trDann.appendChild(tdDann);
	trDann.appendChild(tdNeedDann);
	aDann.appendChild(txtDann);
	tdDann.appendChild(aDann);
	aNeedDann.appendChild(txtNeedDann); tdNeedDann.appendChild(aNeedDann);
trZa = document.createElement("tr");
trZa.setAttribute("id", "Za");
tdZa = document.createElement("td");
aNeedKarma = document.createElement("a");
aNeedKarma.setAttribute("href", "javascript:void(0)");
aNeedKarma.setAttribute("onclick", "owait('0')");
tdNeedKarma = document.createElement("td");
tdNeedKarma.setAttribute("id", "needKarma");
txtNeedKarma = document.createTextNode("Принятыe");
aZa = document.createElement("a");
aZa.setAttribute("href", "javascript:void(0)");
aZa.setAttribute("onclick", "myAdv(ID)");
txtZa = document.createTextNode("Мои заявки");
	menuTable.appendChild(trZa);
	trZa.appendChild(tdZa);
	trZa.appendChild(tdNeedKarma);
	aNeedKarma.appendChild(txtNeedKarma); tdNeedKarma.appendChild(aNeedKarma);
	aZa.appendChild(txtZa);
	tdZa.appendChild(aZa);
trSetZa = document.createElement("tr");
trSetZa.setAttribute("id", "setZa");
tdSetZa = document.createElement("td");
aHaveReciep = document.createElement("a");
aHaveReciep.setAttribute("href", "javascript:void(0)");
aHaveReciep.setAttribute("onclick", "ls(ID)");
tdHaveReciep = document.createElement("td");
tdHaveReciep.setAttribute("id", "haveReciep");
txtHaveReciep = document.createTextNode("Cообщения");
aSetZa = document.createElement("a");
aSetZa.setAttribute("href", "javascript:void(0)");
aSetZa.setAttribute("onclick", "addAdv(ID,'0','0','0',RE,'0','0','4')");
aSetZa.setAttribute("alt", "Подать заявку");
txtSetZa = document.createTextNode("Подать заявку");
	menuTable.appendChild(trSetZa);
	trSetZa.appendChild(tdSetZa);
	trSetZa.appendChild(tdHaveReciep);
	aHaveReciep.appendChild(txtHaveReciep); tdHaveReciep.appendChild(aHaveReciep);
	aSetZa.appendChild(txtSetZa);
	tdSetZa.appendChild(aSetZa);

var res = document.getElementById("results");
if (document.getElementById("regynewuser")!=undefined) {tblOld=document.getElementById("resultTable"); res.removeChild(tblOld); }
	}

else if (xmlHttp.responseText==0) { 	tableLogin = document.getElementById("formlogin");
					first = document.getElementById("first");
					first.removeChild(tableLogin);
					TableNew = document.createElement("table");
					TableNew.setAttribute("id", "TableNew");
					tr = document.createElement("tr");
					td = document.createElement("td");
					user = document.createTextNode("Извините, Вы трижды не верно вводили данные при авторизации. Попробуйте проспаться либо обратитесь в суппорт за помощью.");
					first.appendChild(TableNew);
					TableNew.appendChild(tr);
					td.appendChild(user);
					tr.appendChild(td); }

else	{ onBr = document.getElementById("onBr");
		if (document.getElementById("divtxt")!=undefined) { divtxt=document.getElementById("divtxt");
									onBr.removeChild(divtxt); }
	onBr = document.getElementById("onBr");
	if (document.getElementById("forgotpin")!=undefined) {
			remem=document.getElementById("forgotpin");
			onBr.removeChild(remem); }
	remem = document.createElement("a");
	remem.setAttribute("id", "forgotpin");
	remem.setAttribute("href", "javascript:void(0)");
	remem.setAttribute("onclick", "remember()");
	txtColor = document.createElement("font");
	txtColor.setAttribute("color","#FF0000");
	rememTxt = document.createTextNode("Забыли PIN или Имя?");
	pop=3-xmlHttp.responseText;
	divtxt = document.createElement("div");
	divtxt.setAttribute("id", "divtxt");
	rememTxt2 = document.createTextNode("У Вас осталось попыток - "+pop);
	br = document.createElement("br");
	txtColor.appendChild(rememTxt);
	onBr.appendChild(divtxt);
	divtxt.appendChild(rememTxt2);
	remem.appendChild(txtColor);
	onBr.appendChild(remem); }
	}
}
//------------------------------------------------------------------------------------------------------------------------------------------
//меню пользователя - мои данные
function myData(idUsr) {
var url = '../beer/shuser.php?id=' + escape(idUsr);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = myDataOk;
xmlHttp.send(null);
}

function myDataOk() {
if (xmlHttp.readyState<4 ) {	waitLoad(); }
if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
var response=eval("("+xmlHttp.responseText+")");
if (response.resul[0]==null) { alert("No user"); }
else { UserID = response.resul[0].id;
	UseR = response.resul[0].user;
	tel1 = response.resul[0].tel1;
	tel2 = response.resul[0].tel2;
	icq = response.resul[0].icq;
	email = response.resul[0].email;
	citys = response.resul[0].city;
	clearWorkspace();
	tr = document.createElement("tr");
	td = document.createElement("td");
	td.setAttribute("colspan", "6");
	td.setAttribute("align", "center");
	txt = document.createTextNode("Мои данные");
		sel.appendChild(tr);
		tr.appendChild(td);
		td.appendChild(txt);
for(i=0; i<=6; i++) {
trM[i]=document.createElement("tr");
if (i==0) trM[i].setAttribute("id","trFirst");
		sel.appendChild(trM[i]);
  for(j=0; j<=4; j++) {
	tdM[j] = document.createElement("td");
	switch(j) { 	case 0: tdM[j].setAttribute("width","14%");
			break;
			case 1: tdM[j].setAttribute("width","25%");
			break;
			case 2: tdM[j].setAttribute("width","20%");
			break;
			case 3: tdM[j].setAttribute("width","25%");
				tdM[j].setAttribute("align","center");	
			break;
			default:tdM[j].setAttribute("width","15%");
			break;
		}
	trM[i].appendChild(tdM[j]);
   switch(i) {
	case 0: switch(j) { 
			case 2: txtM[j]=document.createTextNode("Новые значения");
				tdM[j].appendChild(txtM[j]);
			break;
			case 3: txtM[j]=document.createTextNode("PIN для подтверждения");
				tdM[j].appendChild(txtM[j]);
			break;
			case 4: txtM[j]=document.createTextNode("Изменить");
				tdM[j].appendChild(txtM[j]);
			break;
			}
	break;
	case 1: switch(j) { 
			case 0: txtM[j]=document.createTextNode("Телефон 1:");
				tdM[j].appendChild(txtM[j]);
			break;
			case 1: txtM[j]=document.createTextNode(tel1);
				tdM[j].appendChild(txtM[j]);
			break;
			case 2: inputM[j]=document.createElement("input");
				inputM[j].setAttribute("type", "text");
				inputM[j].setAttribute("size", "17");
				inputM[j].setAttribute("maxlength", "12");
				inputM[j].setAttribute("id", "newtel1");
				tdM[j].appendChild(inputM[j]);
			break;
			case 3: for (iii=1;iii<=3;iii++) {    inputMm[iii] = document.createElement("input");
							inputMm[iii].setAttribute("type","button");
							inputMm[iii].setAttribute("onclick", "pinChange(value)");
							inputMm[iii].setAttribute("value",iii); 	
							tdM[j].appendChild(inputMm[iii]);	}
			break;
			case 4: inputM[j]=document.createElement("input");
				inputM[j].setAttribute("type", "button");
				inputM[j].setAttribute("onclick", "updateUser(UserID,0)");
				inputM[j].setAttribute("value","Телефон 1");
				inputM[j].setAttribute("style","width:90px");
				tdM[j].appendChild(inputM[j]);
			break;
			}
	break;
	case 2:	 switch(j) { 
			case 0: txtM[j]=document.createTextNode("Телефон 2:");
				tdM[j].appendChild(txtM[j]);
			break;
			case 1: txtM[j]=document.createTextNode(tel2);
				tdM[j].appendChild(txtM[j]);
			break;
			case 2: inputM[j]=document.createElement("input");
				inputM[j].setAttribute("type", "text");
				inputM[j].setAttribute("size", "17");
				inputM[j].setAttribute("maxlength", "12");
				inputM[j].setAttribute("id", "newtel2");
				tdM[j].appendChild(inputM[j]);
			break;
			case 3: for (iii=4;iii<=6;iii++) {    inputMm[iii] = document.createElement("input");
							inputMm[iii].setAttribute("type","button");
							inputMm[iii].setAttribute("onclick", "pinChange(value)");
							inputMm[iii].setAttribute("value",iii); 	
							tdM[j].appendChild(inputMm[iii]);	}
			break;
			case 4: inputM[j]=document.createElement("input");
				inputM[j].setAttribute("type", "button");
				inputM[j].setAttribute("onclick", "updateUser(UserID,1)");
				inputM[j].setAttribute("value","Телефон 2");
				inputM[j].setAttribute("style","width:90px");
				tdM[j].appendChild(inputM[j]);
			break;
			}
	break;
	case 3:	 switch(j) { 
			case 0: txtM[j]=document.createTextNode("ICQ:");
				tdM[j].appendChild(txtM[j]);
			break;
			case 1: txtM[j]=document.createTextNode(icq);
				tdM[j].appendChild(txtM[j]);
			break;
			case 2: inputM[j]=document.createElement("input");
				inputM[j].setAttribute("type", "text");
				inputM[j].setAttribute("size", "17");
				inputM[j].setAttribute("maxlength", "9");
				inputM[j].setAttribute("id", "newicq");
				tdM[j].appendChild(inputM[j]);
			break;
			case 3: for (iii=7;iii<=9;iii++) {    inputMm[iii] = document.createElement("input");
							inputMm[iii].setAttribute("type","button");
							inputMm[iii].setAttribute("onclick", "pinChange(value)");
							inputMm[iii].setAttribute("value",iii); 	
							tdM[j].appendChild(inputMm[iii]);	}
			break;
			case 4: inputM[j]=document.createElement("input");
				inputM[j].setAttribute("type", "button");
				inputM[j].setAttribute("onclick", "updateUser(UserID,2)");
				inputM[j].setAttribute("value","ICQ");
				inputM[j].setAttribute("style","width:90px");
				tdM[j].appendChild(inputM[j]);
			break;
			}
	break;
	case 4:	 switch(j) { 
			case 0: txtM[j]=document.createTextNode("E-mail:");
				tdM[j].appendChild(txtM[j]);
			break;
			case 1: txtM[j]=document.createTextNode(email);
				tdM[j].appendChild(txtM[j]);
			break;
			case 2: inputM[j]=document.createElement("input");
				inputM[j].setAttribute("type", "text");
				inputM[j].setAttribute("size", "17");
				inputM[j].setAttribute("maxlength", "40");
				inputM[j].setAttribute("id", "newemail");
				tdM[j].appendChild(inputM[j]); 
			break;
			case 3: for (iii=-1;iii<=1;iii++) {    inputMm[iii] = document.createElement("input");
							inputMm[iii].setAttribute("type","button");
							inputMm[iii].setAttribute("onclick", "pinChange(value)");
							if (iii==0) {inputMm[iii].setAttribute("value",iii); }
							else {   inputMm[iii].setAttribute("value","--");
								inputMm[iii].setAttribute("disabled","disabled");}
							tdM[j].appendChild(inputMm[iii]);	}
			break;
			case 4: inputM[j]=document.createElement("input");
				inputM[j].setAttribute("type", "button");
				inputM[j].setAttribute("onclick", "updateUser(UserID,3)");
				inputM[j].setAttribute("value","E-mail");	
				inputM[j].setAttribute("style","width:90px");
				tdM[j].appendChild(inputM[j]);
			break;
			}
	break;
	case 5: switch(j) {
			case 0: txtM[j]=document.createTextNode("Ваш регион:");
				tdM[j].appendChild(txtM[j]);
			break;
			case 2:	 region3sel = document.createElement("select");
				region3sel.setAttribute("class","country");
				 region3sel.setAttribute("id","region3");
				tdM[j].appendChild(region3sel);

				 inputM[j] = document.createElement("select");
				inputM[j].setAttribute("class","country");
				inputM[j].setAttribute("onchange","chng(value,3)");
				for (co=0; co<=16; co++) {
							opt = document.createElement('option');
							optTxt=document.createTextNode(city[0][co]);
							opt.setAttribute('value',co);
					if ((citys>=1)&&(citys<=49)&&(co==1)) { opt.setAttribute("selected","selected"); selectRegion(citys,co,3);}
					if ((citys>=50)&&(citys<=99)&&(co==2)) { opt.setAttribute("selected","selected"); selectRegion(citys,co,3);}
					if ((citys>=100)&&(citys<=199)&&(co==3)) {opt.setAttribute("selected","selected"); selectRegion(citys,co,3);}
					if ((citys==0) && (co==0)) { opt.setAttribute("selected","selected");  selectRegion(citys,co,3);}
					if ((citys==200)&&(co==4)) { opt.setAttribute("selected","selected");  selectRegion(citys,co,3);}
					if ((citys==220)&&(co==5)) { opt.setAttribute("selected","selected");  selectRegion(citys,co,3);}
					if ((citys==240)&&(co==6)) { opt.setAttribute("selected","selected");  selectRegion(citys,co,3);}
					if ((citys==260)&&(co==7)) { opt.setAttribute("selected","selected");  selectRegion(citys,co,3);}
					if ((citys==280)&&(co==8)) { opt.setAttribute("selected","selected");  selectRegion(citys,co,3);}
					if ((citys==300)&&(co==9)) { opt.setAttribute("selected","selected");  selectRegion(citys,co,3);}
					if ((citys==320)&&(co==10)) { opt.setAttribute("selected","selected");  selectRegion(citys,co,3);}
					if ((citys==340)&&(co==11)) { opt.setAttribute("selected","selected");  selectRegion(citys,co,3);}
					if ((citys==360)&&(co==12)) { opt.setAttribute("selected","selected");  selectRegion(citys,co,3);}
					if ((citys==380)&&(co==13)) { opt.setAttribute("selected","selected");  selectRegion(citys,co,3);}
					if ((citys==400)&&(co==14)) { opt.setAttribute("selected","selected");  selectRegion(citys,co,3);}
					if ((citys==420)&&(co==15)) { opt.setAttribute("selected","selected");  selectRegion(citys,co,3);}
					if ((citys==440)&&(co==16)) { opt.setAttribute("selected","selected");  selectRegion(citys,co,3);}
						opt.appendChild(optTxt);
						inputM[j].appendChild(opt);
							}
				 tdM[j].appendChild(inputM[j]);

			break;
			case 3: inputM[j]=document.createElement("input");
				inputM[j].setAttribute("type", "text");
				inputM[j].setAttribute("readonly","readonly");
				inputM[j].setAttribute("value","");
				inputM[j].setAttribute("size","9");
				inputM[j].setAttribute("id", "ppChange");
				butCl = document.createElement("input");
				butCl.setAttribute("type","button");
				butCl.setAttribute("id","escChange");
				butCl.setAttribute("onclick","pinChange()");
				butCl.setAttribute("disabled","disabled");
				butCl.setAttribute("value","Esc");
				butCl.setAttribute("style","width:35px");
				tdM[j].appendChild(butCl);
				tdM[j].appendChild(inputM[j]);
			break;
			case 4: inputM[j]=document.createElement("input");
				inputM[j].setAttribute("type", "button");
				inputM[j].setAttribute("onclick", "updateUser(UserID,4)");
				inputM[j].setAttribute("value","Регион");	
				inputM[j].setAttribute("style","width:90px");
				tdM[j].appendChild(inputM[j]);
			break;
			}
	break;
	case 6: switch(j) {
			case 0: txtM[j]=document.createTextNode("Новый PIN:");
				tdM[j].appendChild(txtM[j]);
			break;
			case 1: for (iii=0;iii<=9;iii++) {    inputMm[iii] = document.createElement("input");
							inputMm[iii].setAttribute("type","button");
							inputMm[iii].setAttribute("onclick", "pinNew(value)");
							inputMm[iii].setAttribute("value",iii); 
							inputMm[iii].setAttribute("style","width:25px");
							if (iii==5) {perenos = document.createElement("br");
									tdM[j].appendChild(perenos); }
							tdM[j].appendChild(inputMm[iii]);	}
			break;
			case 2:ppNew=document.createElement("input");
				ppNew.setAttribute("type", "text");
				ppNew.setAttribute("readonly","readonly");
				ppNew.setAttribute("value","");
				ppNew.setAttribute("size","9");
				ppNew.setAttribute("id", "ppNew");
				butNew = document.createElement("input");
				butNew.setAttribute("type","button");
				butNew.setAttribute("id","escNew");
				butNew.setAttribute("onclick","pinNew()");
				butNew.setAttribute("disabled","disabled");
				butNew.setAttribute("value","Esc");
				tdM[j].appendChild(butNew);
				tdM[j].appendChild(ppNew);
			break;
			case 4: inputM[j]=document.createElement("input");
				inputM[j].setAttribute("type", "button");
				inputM[j].setAttribute("onclick", "updateUser(UserID,5)");
				inputM[j].setAttribute("value","PIN");
				inputM[j].setAttribute("style","width:90px");
				tdM[j].setAttribute("align","center");
				tdM[j].appendChild(inputM[j]);
			break;
			}
	break;
	}

    }

}
txt6 = document.createTextNode("что бы удалить значение оставьте поле нового значения пустым и подтвердите изменение PINом");
tr6= document.createElement("tr");
td6 = document.createElement("td");
td6.setAttribute("colspan","6");
		sel.appendChild(tr6);
		tr6.appendChild(td6);
		td6.appendChild(txt6);
		}
    }	}
}
//------------------------------------------------------------------------------------------------------------------------------------------
function selectRegion(citys,coChk,tup) {
regionSel = document.getElementById("region"+tup);
					if ((citys>=1) && (citys<=49)) iiVal=1;
					else if ((citys>=50) && (citys<=99)) iiVal=50;
					else if ((citys>=100) && (citys<=199)) iiVal=100;
					else if (citys==0) {iiVal=0; regionSel.setAttribute("disabled","disabled");}
					else iiVal=citys;
				optcity = document.createElement("option");
				optCityTxt=document.createTextNode("все регионы");
				optcity.setAttribute("value",iiVal);
				optcity.setAttribute("id","value0"+tup);
				optcity.appendChild(optCityTxt);
				regionSel.appendChild(optcity);
iiVal++;
for (iiReg=0;iiReg<=199;iiReg++) {
if(city[coChk][iiReg]!=undefined) {
	optcity = document.createElement("option");
	optCityTxt=document.createTextNode(city[coChk][iiReg]);
	optcity.setAttribute("value",iiVal);
	optcity.setAttribute("id","valueOld"+tup);
		if (citys==iiVal) { optcity.setAttribute("selected","selected"); }
	optcity.appendChild(optCityTxt);
	regionSel.appendChild(optcity);
	iiVal++;
	}
    }
}
//------------------------------------------------------------------------------------------------------------------------------------------
//обновление данных юзера
function updateUser(idUsr, type) {
var p = document.getElementById("ppChange").value;
switch (type) {	
	case 0:var newtel1 = document.getElementById("newtel1").value;
		sendd(idUsr, 0, newtel1, p);

	break;
	case 1:	var newtel2 = document.getElementById("newtel2").value;
		sendd(idUsr, 1, newtel2, p);
	break;
	case 2:	var newicq = document.getElementById("newicq").value;
		sendd(idUsr, 2, newicq, p);
	break;
	case 3:	var newemail = document.getElementById("newemail").value;
		sendd(idUsr, 3, newemail, p);
	break;
	case 4:	var newgorod = document.getElementById("region3").value;
		sendd(idUsr, 4, newgorod, p);
	break;
	case 5:	var newpin = document.getElementById("ppNew").value;
		sendd(idUsr, 5, newpin, p);
	break;

	default: alert("You typed something wrong here");
	}
}


function sendd(idUsr, type, valu, p) {
	var url = '../beer/updusr.php?nick=' + escape(idUsr)+'&pswd='+escape(p)+'&type='+escape(type)+'&valu='+escape(valu);
	waitLoad();
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = UserUpd;
	xmlHttp.send(null);
}

function UserUpd() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
var response =xmlHttp.responseText;
if (response!=0) { myData(response); }
else { alert("You typed something wrong");}
	clearWorkspace();
	}
     }
}
//------------------------------------------------------------------------------------------------------------------------------------------
//меню пользователя - мои заявки
function myAdv(idUsr) {
var url = '../beer/shusradv.php?id=' + escape(idUsr);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = myAdvOk;
xmlHttp.send(null);
}

function myAdvOk() {
if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
	clearWorkspace();
	tr = document.createElement("tr");
	td = document.createElement("td");
	td.setAttribute("colspan", "10");
	td.setAttribute("align", "center");
	txt = document.createTextNode("Мои заявки");
		td.appendChild(txt);
		tr.appendChild(td);
		sel.appendChild(tr);
tr2 = document.createElement("tr");
tr2.setAttribute("id","trFirst");
td2 = document.createElement("td");
text=document.createTextNode("Отдаете");
td21 = document.createElement("td");
text21=document.createTextNode("Получаете");
td22 = document.createElement("td");
text22=document.createTextNode("В регионе");
td221 = document.createElement("td");
text221=document.createTextNode("USD");
td23 = document.createElement("td");
td23.setAttribute("colspan", "2");
text23=document.createTextNode("Дополнительная информация");
td24= document.createElement("td");
text24=document.createTextNode("Гарант");
td25 = document.createElement("td");
td25.setAttribute("colspan","3");
text25=document.createTextNode("Действия");
	td25.appendChild(text25);
	td24.appendChild(text24);
	td23.appendChild(text23);
	td221.appendChild(text221);
	td22.appendChild(text22);
	td21.appendChild(text21);
	td2.appendChild(text);
	tr2.appendChild(td2);
	tr2.appendChild(td21);
	tr2.appendChild(td22);
	tr2.appendChild(td221);
	tr2.appendChild(td23);
	tr2.appendChild(td24);
	tr2.appendChild(td25);
	sel.appendChild(tr2);
		var respo=eval("("+xmlHttp.responseText+")");
			i=0;
				while(respo.resul[i]!=null) { 
						Info=respo.resul[i].addit;
						iddd = respo.resul[i].id;
						gr = respo.resul[i].gr;
						idUsr=respo.resul[i].user;
						give=respo.resul[i].give;
						get=respo.resul[i].get;
						regy=respo.resul[i].region;
						otd=respo.resul[i].otd;
						pol=respo.resul[i].pol;
						place=respo.resul[i].place;
						usd=respo.resul[i].usd;
						tr3 = document.createElement('tr');
						tr3.setAttribute("onmouseover","this.style.backgroundColor='#f3f4fb'");
						tr3.setAttribute("onmouseout","this.style.backgroundColor='#FFFFFF'");
						td1 = document.createElement('td');
						txt1=document.createTextNode(give);
						td2 = document.createElement('td');
						txt2=document.createTextNode(get);
						td3 = document.createElement('td');
						txt3=document.createTextNode(regy);
						td4 = document.createElement('td');
						td4.setAttribute("colspan","2");
						txt4=document.createTextNode(Info);
						td5 = document.createElement('td');
						td5.setAttribute("align","center");
						if (gr==1) { txt5=document.createElement("img"); txt5.setAttribute("src","../img/gr.gif"); 
								txt5.setAttribute("border","0"); txt5.setAttribute("width","16"); }
						else { txt5=document.createTextNode("-");}
						td6 = document.createElement('td');
						td7 = document.createElement('td');
						td8 = document.createElement('td');
						a61=document.createElement('a');
						a61.setAttribute("href","javascript:void(0)");
						a61.setAttribute("onclick","razmestit("+idUsr+",'2',"+iddd+",'0','0','0','0','0','0')");
						a61.setAttribute("title","Поднять");
						a61.setAttribute("onmouseover","Tip('Поднять')");
						a61.setAttribute("onmouseout","UnTip()");
						img61=document.createElement("img");
						img61.setAttribute("src","../img/upp.png");
						img61.setAttribute("width","16");
						img61.setAttribute("border","0");
						img61.setAttribute("height","16");
						a62=document.createElement('a');
						a62.setAttribute("href","javascript:void(0)");
						a62.setAttribute("onclick","javascript:addAdv("+idUsr+","+iddd+","+otd+","+pol+","+place+","+gr+",'"+Info+"',"+usd+")");
						a62.setAttribute("title","Изменить");
						a62.setAttribute("onmouseover","Tip('Изменить')");
						a62.setAttribute("onmouseout","UnTip()");
						img62=document.createElement("img");
						img62.setAttribute("src","../img/edit.png");
						img62.setAttribute("border","0");
						a63=document.createElement('a');
						a63.setAttribute("href","javascript:void(0)");
						a63.setAttribute("onclick","razmestit("+idUsr+",'3',"+iddd+",'0','0','0','0','0','0')");
						a63.setAttribute("title","Удалить");
						a63.setAttribute("onmouseover","Tip('Удалить')");
						a63.setAttribute("onmouseout","UnTip()");
						img63=document.createElement("img");
						img63.setAttribute("src","../img/drop.png");
						img63.setAttribute("border","0");
					if (usd==0) txt31=document.createTextNode("до 100");
					if (usd==1) txt31=document.createTextNode("до 300");
					if (usd==2) txt31=document.createTextNode("до 500");
					if (usd==3) txt31=document.createTextNode("до 1000");
					if (usd==4) txt31=document.createTextNode("любой");
						td31 = document.createElement('td');
						td1.appendChild(txt1);
						td2.appendChild(txt2);
						td3.appendChild(txt3);
						td31.appendChild(txt31);
						td4.appendChild(txt4);
						td5.appendChild(txt5);
						a61.appendChild(img61);
						a62.appendChild(img62);
						a63.appendChild(img63);
						td6.appendChild(a61);
						td7.appendChild(a62);
						td8.appendChild(a63);
						tr3.appendChild(td1);
						tr3.appendChild(td2);
						tr3.appendChild(td3);
						tr3.appendChild(td31);
						tr3.appendChild(td4);
						tr3.appendChild(td5);
						tr3.appendChild(td6);
						tr3.appendChild(td7);
						tr3.appendChild(td8);
						sel.appendChild(tr3);
						i++;  		}
				
	if (respo.resul[0]==null) { 		tr = document.createElement('tr');
						td = document.createElement('td');
						td.setAttribute("colspan", "10");
						text=document.createTextNode("Действующие предложения отсутствуют");
						td.appendChild(text);
						tr.appendChild(td);
						sel.appendChild(tr);
					}
//	}
}
}
}
//------------------------------------------------------------------------------------------------------------------------------------------
//меню пользователя - подать заявку
function addAdv(idUsr,iddd,otd,pol,place,gr,textob,usd) {
U=idUsr;
clearWorkspace();
trP = document.createElement("tr");
tdP = document.createElement("td");
	sel.appendChild(trP);
	trP.appendChild(tdP);
form = document.createElement("form");
	tdP.appendChild(form);
tableForm = document.createElement("table");
	form.appendChild(tableForm);
trF=document.createElement("tr");
	tableForm.appendChild(trF);
td1 = document.createElement("td");
txt1 = document.createTextNode("Я отдаю");
	trF.appendChild(td1);
	td1.appendChild(txt1);
td2 = document.createElement("td");
otdam = document.createElement("select");
otdam.setAttribute("id", "otdam");
	for(i=0; i<33; i++) {
	option=document.createElement("option");
	if ((iddd!=undefined)&&(iddd!=0)&&(otd==i))  { option.setAttribute("value", otd);
		option.setAttribute("selected", "selected")
		optionTxt = document.createTextNode(mangi[otd]);}
	else {option.setAttribute("value", i);
		optionTxt = document.createTextNode(mangi[i]);}
	option.appendChild(optionTxt);
	otdam.appendChild(option);
	}
	trF.appendChild(td2);
	td2.appendChild(otdam);
td3  = document.createElement("td");
txt3 = document.createTextNode(" хочу получить ");
	trF.appendChild(td3);
	td3.appendChild(txt3);
td4 =  document.createElement("td");
poluchu= document.createElement("select");
poluchu.setAttribute("id", "poluchu");
	for(i=0; i<33; i++) {
	option=document.createElement("option");
	if ((iddd!=undefined)&&(iddd!=0)&&(pol==i)) { option.setAttribute("value", pol);
		option.setAttribute("selected", "selected");
		optionTxt = document.createTextNode(mangi[pol]);}
	else {option.setAttribute("value", i);
		optionTxt = document.createTextNode(mangi[i]);}
	option.appendChild(optionTxt);
	poluchu.appendChild(option);
	}
	trF.appendChild(td4);
	td4.appendChild(poluchu);
td5 =  document.createElement("td");
txt5 =  document.createTextNode(" в регионе ");
	trF.appendChild(td5);
	td5.appendChild(txt5);

citys=place;
td92=document.createElement("td");
country4 = document.createElement("select");
country4.setAttribute("id","country4");
country4.setAttribute("onchange","chng(value,4)");
		trF.appendChild(td92);
		td92.appendChild(country4);
region4= document.createElement("select");
region4.setAttribute("name","region4");
region4.setAttribute("id","region4");
region4.setAttribute("class","country");
		td92.appendChild(region4);
for (i=0;i<=16;i++) {
	opt[i]= document.createElement("option");
	opt[i].setAttribute("value",i);
	if ((citys>=1)&&(citys<=49)&&(i==1)) { opt[i].setAttribute("selected","selected"); selectRegion(citys,i,4); }
	if ((citys>=50)&&(citys<=99)&&(i=2)) { opt[i].setAttribute("selected","selected"); selectRegion(citys,i,4);}
	if ((citys>=100)&&(citys<=199)&&(i==3)) {opt[i].setAttribute("selected","selected"); selectRegion(citys,i,4);}
	if ((citys==0) && (i==0)) { opt[i].setAttribute("selected","selected");  selectRegion(citys,i,4);}
	if ((citys==200)&&(i==4)) { opt[i].setAttribute("selected","selected");  selectRegion(citys,i,4);}
	if ((citys==220)&&(i==5)) { opt[i].setAttribute("selected","selected");  selectRegion(citys,i,4);}
	if ((citys==240)&&(i==6)) { opt[i].setAttribute("selected","selected");  selectRegion(citys,i,4);}
	if ((citys==260)&&(i==7)) { opt[i].setAttribute("selected","selected");  selectRegion(citys,i,4);}
	if ((citys==280)&&(i==8)) { opt[i].setAttribute("selected","selected");  selectRegion(citys,i,4);}
	if ((citys==300)&&(i==9)) { opt[i].setAttribute("selected","selected");  selectRegion(citys,i,4);}
	if ((citys==320)&&(i==10)) { opt[i].setAttribute("selected","selected");  selectRegion(citys,i,4);}
	if ((citys==340)&&(i==11)) { opt[i].setAttribute("selected","selected");  selectRegion(citys,i,4);}
	if ((citys==360)&&(i==12)) { opt[i].setAttribute("selected","selected");  selectRegion(citys,i,4);}
	if ((citys==380)&&(i==13)) { opt[i].setAttribute("selected","selected");  selectRegion(citys,i,4);}
	if ((citys==400)&&(i==14)) { opt[i].setAttribute("selected","selected");  selectRegion(citys,i,4);}
	if ((citys==420)&&(i==15)) { opt[i].setAttribute("selected","selected");  selectRegion(citys,i,4);}
	if ((citys==440)&&(i==16)) { opt[i].setAttribute("selected","selected");  selectRegion(citys,i,4);}
	optTxt[i] = document.createTextNode(city[0][i]);
		country4.appendChild(opt[i]);
		opt[i].appendChild(optTxt[i]);
	}
tr2=document.createElement("tr");
	tableForm.appendChild(tr2);
td21=document.createElement("td");
td21.setAttribute("colspan","2");
	tr2.appendChild(td21);
td21txt = document.createTextNode("Введите дополнительную информацию");
	td21.appendChild(td21txt);
td22 = document.createElement("td");
td22.setAttribute("colspan","4");
	tr2.appendChild(td22);
dopInfo=document.createElement("input");
dopInfo.setAttribute("id", "dopInfo");
dopInfo.setAttribute("type", "text");
dopInfo.setAttribute("maxlength", "50");
dopInfo.setAttribute("size", "58");
if ((iddd!=undefined)&&(iddd!=0)) { dopInfo.setAttribute("value", textob);}
	td22.appendChild(dopInfo);

tr3=document.createElement("tr");
	tableForm.appendChild(tr3);
tdTxtRadio = document.createElement("td");
tdTxtRadio.setAttribute("colspan","2");
mainTxt = document.createTextNode("cумма эквивалентна в USD: ");
	tdTxtRadio.appendChild(mainTxt);
	tr3.appendChild(tdTxtRadio);
tdradio=document.createElement("td");
tdradio.setAttribute("colspan","4");
	tr3.appendChild(tdradio);
formRadio = document.createElement("form");
formRadio.setAttribute("name","radioForm");
	tdradio.appendChild(formRadio);
oneone = document.createElement("input");
oneone.setAttribute("type","radio");
oneone.setAttribute("value","0");
oneone.setAttribute("name","topic1");
oneTxt = document.createTextNode("до 100 ");
twotwo = document.createElement("input");
twotwo.setAttribute("type","radio");
twotwo.setAttribute("name","topic1");
twotwo.setAttribute("value","1");
twoTxt = document.createTextNode("до 300 ");
thth = document.createElement("input");
thth.setAttribute("type","radio");
thth.setAttribute("name","topic1");
thth.setAttribute("value","2");
thTxt = document.createTextNode("до 500 ");
fofo = document.createElement("input");
fofo.setAttribute("type","radio");
fofo.setAttribute("name","topic1");
fofo.setAttribute("value","3");
foTxt = document.createTextNode("до 1000 ");
zzero = document.createElement("input");
zzero.setAttribute("type","radio");
zzero.setAttribute("name","topic1");
zzero.setAttribute("value","4");
zzeroTxt = document.createTextNode("больше 1000 ");

if ((iddd!=undefined)&&(iddd!=0)&&(usd>0)) { switch(usd) { case 1: twotwo.setAttribute("checked","checked");
								break;
								case 2: thth.setAttribute("checked","checked");
								break;
								case 3: fofo.setAttribute("checked","checked");
								break;	
								case 4: zzero.setAttribute("checked","checked");
								break;}
						}
else {oneone.setAttribute("checked","checked");}
	formRadio.appendChild(oneone);
	formRadio.appendChild(oneTxt);
	formRadio.appendChild(twotwo);
	formRadio.appendChild(twoTxt);
	formRadio.appendChild(thth);
	formRadio.appendChild(thTxt);
	formRadio.appendChild(fofo);
	formRadio.appendChild(foTxt);
	formRadio.appendChild(zzero);
	formRadio.appendChild(zzeroTxt);

tr4=document.createElement("tr");
	tableForm.appendChild(tr4);
tdF1=document.createElement("td");
	tr4.appendChild(tdF1);
checkbox=document.createElement("input");
checkbox.setAttribute("type", "checkbox");
checkbox.setAttribute("id", "checkbox");
if ((iddd!=undefined)&&(gr==1)&&(iddd!=0)) {checkbox.setAttribute("checked", "checked");}
	tdF1.appendChild(checkbox);
tdX=document.createElement("td");
	tr4.appendChild(tdX);
tdXtxt=document.createTextNode("Работать через Гарант");
	tdX.appendChild(tdXtxt);
tdF2=document.createElement("td");
tdF2.setAttribute("colspan","4");
	tr4.appendChild(tdF2);
input32=document.createElement("input");
input32.setAttribute("type", "button");
input32.setAttribute("id", "input32");
	if ((iddd!=undefined)&&(iddd!=0)) {razmes=1; idObmena=iddd; } else {razmes=0; idObmena=0;}
input32.setAttribute("onclick", "razmestit(U,razmes,idObmena,otdam.value,poluchu.value,region4.value,dopInfo.value,checkbox.checked,document.radioForm.topic1)");
input32.setAttribute("value", "Разместить");
	tdF2.appendChild(input32);
}
//------------------------------------------------------------------------------------------------------------------------------------------
//добавление (обновление существующей) новой объявы (юзер, тип операции, идОбмена, отдает, получает, город,инфо,гарант,размер)
function razmestit(idUsr,raz,obm,o,p,g,infa,gt,radioGroupObj) {
  for (var i=0; i < radioGroupObj.length; i++)	{
    if (radioGroupObj[i].checked) usd=radioGroupObj[i].value;	}
	if (gt==false) gt=0;
		else gt=1;
if ((raz==0) || (raz==1)) {
		if (((o==1)||(p==1))&&(gt==1)) { alert ("Гарант не работает с наличными средствами"); exit(); }
		if ((o==0)||(p==0)) { alert ("Выбирете валюты, которые обмениваете"); exit(); }
		if (((o==1)||(p==1))&&(g==0)) { alert ("Выбирете регион для обмена на наличные деньги"); exit(); }
	}

if (raz==3) {
	ans=confirm("Удалить объявление?");
	if (ans) { var url = "../beer/addZajava.php?o=" + escape(o)+"&p="+escape(p)+"&obm="+escape(obm)+"&g="+escape(g)+"&i="+escape(infa)+"&u="+escape(idUsr)+"&gt="+escape(gt)+"&raz="+escape(raz)+"&usd="+escape(usd);
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = razmestilOk;
	xmlHttp.send(null);
		}
	else { myAdv(idUsr); }
	}

else {
	var url = "../beer/addZajava.php?o=" + escape(o)+"&p="+escape(p)+"&obm="+escape(obm)+"&g="+escape(g)+"&i="+encodeURIComponent(infa)+"&u="+escape(idUsr)+"&gt="+escape(gt)+"&raz="+escape(raz)+"&usd="+escape(usd);
		if (raz==0) { waitLoad(); }
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = razmestilOk;
	xmlHttp.send(null);
	}
}

function razmestilOk() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.responseText!=0) myAdv(xmlHttp.responseText);
else alert("НЕ все верно в вашем запросе");
	}
}
//------------------------------------------------------------------------------------------------------------------------------------------
//выход
function logout() {
var url = '../beer/logout.php';
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = logoutOk;
xmlHttp.send(null);
}
function logoutOk() {
if (xmlHttp.readyState == 4) {
location.href="index.php";
	}
}
//------------------------------------------------------------------------------------------------------------------------------------------
//поиск предложений обмена
function obmen(sHom, sGet, region, gr, usd) {
if (sHom==0) {alert("Выберите деньги, которые Вы отдаете"); exit(); }
if ((region==0)&&((sHom==1) || (sGet==1))) {alert("Выберете регион для обмена наличных"); exit();}
if ((gr==1) && ((sHom==1) || (sGet==1))) {alert("Гарант не работает при обмене наличных средств"); exit();}
var url="../beer/choise.php?gv="+escape(sHom)+"&gt="+escape(sGet)+"&rg="+escape(region)+"&gr="+escape(gr)+"&usd="+escape(usd);

xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange=obmenUpd;
xmlHttp.send(null); 
}

function obmenUpd() {
if (xmlHttp.readyState < 4)  waitLoad();
else {
		if (xmlHttp.status == 200) {
clearWorkspace();
table();
		}
	}
}
//------------------------------------------------------------------------------------------------------------------------------------------
//акцепты заявки
// (имя заявителя, ид заявителя, ид обмена, положение гаранта, текст)
function msgalert(one,two,three,four,five) {
		var url="../beer/accept.php?nmZ=" + escape(one)+"&idZ=" + escape(two)+"&idO=" + escape(three)+"&gart=" + escape(four)+"&msg="+encodeURIComponent(five);
		xmlHttp.open("GET", url, true);
		xmlHttp.onreadystatechange=msgUpd;
		xmlHttp.send(null);
}

function msgUpd() {
if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
if (xmlHttp.responseText==11) { alert("У Вас уже принята данная заявка"); exit(); }
if ((xmlHttp.responseText>=0)&&(xmlHttp.responseText<=5)) {
	zajavkaDet = document.getElementById("zajavkaDet");
	BeforezajavkaDet=document.getElementById("BeforezajavkaDet");
	BeforezajavkaDet.removeChild(zajavkaDet);
	prinyato = document.createTextNode("Заявка принята");
	br=document.createElement("br");
	napom = document.createTextNode("По результатам сделки не забудьте оценить заявителя");
	BeforezajavkaDet.appendChild(prinyato);
	BeforezajavkaDet.appendChild(br);
	BeforezajavkaDet.appendChild(br);
	BeforezajavkaDet.appendChild(br);
	BeforezajavkaDet.appendChild(napom);
	}
else { alert("Нельзя принимать заявки если у Вас уже имеются 5 обязательств");}
}
}
}
//------------------------------------------------------------------------------------------------------------------------------------------
//Очистка рабочей области и начало создания результата в ней
function clearWorkspace() {
var res = document.getElementById("results");
	if (document.getElementById("resultTable")!=undefined) {tblOld=document.getElementById("resultTable"); res.removeChild(tblOld); }
sel=document.createElement('table');
sel.setAttribute('border', "0");
sel.setAttribute('width', "650");
sel.setAttribute('id', "resultTable");
		res.appendChild(sel);
}
//------------------------------------------------------------------------------------------------------------------------------------------
//в рабоче области рисуем шапку таблицы с названиями столбцов
var ocenil=[]; ocenka=[]; day=[]; ocen=[];
function table() {
tr = document.createElement('tr');
tr.setAttribute("id","trFirst");
td = document.createElement('td');
td.setAttribute('width', "12%");
text=document.createTextNode("Дата");
td1 = document.createElement('td');
td1.setAttribute('width', "15%");
text1=document.createTextNode("Пользователь");
td2 = document.createElement('td');
td2.setAttribute('width', "18%");
text2=document.createTextNode("Отдает");
td3 = document.createElement('td');
td3.setAttribute('width', "18%");
text3=document.createTextNode("Хочет получить");
td4 = document.createElement('td');
td4.setAttribute('width', "15%");
text4=document.createTextNode("В регионе");
td42 = document.createElement('td');
td42.setAttribute('width', "10%");
text42=document.createTextNode("USD");
td5 = document.createElement('td');
td5.setAttribute('width', "12%");
text5=document.createTextNode("Детали");
td5.appendChild(text5);
td42.appendChild(text42);
td4.appendChild(text4);
td3.appendChild(text3);
td2.appendChild(text2);
td1.appendChild(text1);
td.appendChild(text);
tr.appendChild(td);
tr.appendChild(td1);
tr.appendChild(td2);
tr.appendChild(td3);
tr.appendChild(td4);
tr.appendChild(td42);
tr.appendChild(td5)
sel.appendChild(tr);
		var response=eval("("+xmlHttp.responseText+")");
			i=0;
				while(response.resul[i]!=null) { 
						Info=response.resul[i].addit;
						iddd = response.resul[i].id;
						gr = response.resul[i].gr;
						ui=response.resul[i].userid;
						USER=response.resul[i].user;
						give=response.resul[i].give;
						get=response.resul[i].get;
						reGion=response.resul[i].region;
						usd=response.resul[i].usd;
						tel1=response.resul[i].tel1;
						tel2=response.resul[i].tel2;
						icq=response.resul[i].icq;
						email=response.resul[i].email;
						guthist=response.resul[i].guthist;
						nohist=response.resul[i].nohist;
						badhist=response.resul[i].badhist;
						regdate=response.resul[i].regdate;
						acceptor=response.resul[i].acceptor;
						kolZ=response.resul[i].kolZ;
						prinato=response.resul[i].rowPreOldA;
						eta=response.resul[i].rowchRe;

	trig=1;
	ocenKi="";
	while(eval("response.resul[i].ocenil"+trig)!=undefined) {
							ocenil[trig]=eval("response.resul[i].ocenil"+trig); 
							ocenka[trig]=eval("response.resul[i].ocenka"+trig); 
							day[trig]=eval("response.resul[i].day"+trig); 
							ocen[trig]=day[trig]+" "+ocenil[trig]+" "+ocenka[trig]+"\\n";
							ocenKi=ocen[trig]+ocenKi;
							trig++;	}
	if (badhist!='undefined') hist="<tr><td colspan=2>"+USER+" участник с "+regdate+",  подал заявок - "+kolZ+", результаты cделок +"+guthist+"</a>/"+nohist+"/-"+badhist+"</td></tr><tr><td colspan=2><textarea cols=52 rows=4 readonly=readonly>"+ocenKi+"</textarea></td></tr>";
	else hist='<tr><td colspan=2>Чтобы получить детальную информацию о заявителе Вам следует авторизоваться</td></tr>';
	if (gr==1) garTip='<tr><td colspan=2 align=center><b>Обмен через Гарант</b></td></tr>';
	else garTip="<tr><td colspan=2 align=center>Контакты:</td></tr><tr><td>Телефоны: </td><td>"+tel1+"</td></tr><tr><td>Телефоны: </td><td>"+tel2+" </td></tr><tr><td>ICQ: </td><td>"+icq+"</td></tr><tr><td>E-mail: </td><td>"+email+"</td></tr>";
	if (prinato>=5) acceptorTxt="<tr><td colspan=2>У вас уже 5 принятых заявок. Дайте оценки тому с кем Вы работали, иначе Вы не сможете принимать новые заявки.</td></tr>";
	else if (eta!=0) acceptorTxt="<tr><td colspan=2>У вас уже принята данная заявка.</td></tr>";
	else if (acceptor!=0) acceptorTxt="<tr><td colspan=2>Ваше сообщение заявителю:<br><input type=text maxlength=50 size=45 id=msgaccept /></td></tr><tr><td colspan=2 align=center><input type=button value=\"Принять заявку\" onmousedown=msgalert(\""+USER+"\",\""+ui+"\",\""+iddd+"\",\""+gr+"\",msgaccept.value) /></td></tr>";
	else acceptorTxt="";

						tr = document.createElement('tr');
						tr.setAttribute("onmouseover","this.style.backgroundColor='#f3f4fb'");
						tr.setAttribute("onmouseout","this.style.backgroundColor='#FFFFFF'");
						td5 = document.createElement('td');
						td5.setAttribute("onclick", "Tip('<div id=BeforezajavkaDet><form id=zajavkaDet ><table border=1 width=300><tr><td colspan=2 align=center>Пользователь <b>"+USER+"</b> подал заявку:</td></tr><tr><td width=80>отдает: </td><td><b>"+give+"</b></td></tr><tr><td>получает: </td><td><b>"+get+"</b></td></tr><tr><td>регион: </td><td><b>"+reGion+"</b></td></tr><tr><td colspan=2 align=center>Дополнительная информация от заявителя:</td></tr><tr><td colspan=2><b>"+Info+"</b></td></tr>"+garTip+hist+acceptorTxt+"</table></form></div>',BORDERCOLOR,'#DDDDDD',BGCOLOR,'#DDDDDD',CLOSEBTN,'true',CLOSEBTNTEXT,'X',CLOSEBTNCOLORS,['#DDDDDD','#929292','#DDDDDD','#777777'],EXCLUSIVE,'true',DURATION,'0',OPACITY,'95',FIX,['informer',-50,-50],FADEIN,'200',HEIGHT,0,WIDTH,'31')");
						td5.setAttribute("onmouseover", "Tip(' "+Info+" ')");
						td5.setAttribute("onmouseout", "UnTip()");
						text5=document.createTextNode("Инфо....");
						a5 = document.createElement("a");
						a5.setAttribute("href", "javascript:void(0)");
						a5.appendChild(text5);
						td5.appendChild(a5);
						td = document.createElement('td');
						text=document.createTextNode(" "+response.resul[i].d+" ");
						td1 = document.createElement('td');
						text1=document.createTextNode(" "+USER);
						a1=document.createElement("a");
			if (acceptor!=0)	 {	a1.setAttribute("href","javascript:void(0)");
			  		 	a1.setAttribute("onmouseover", "Tip('Написать сообщение "+USER+" ')");
						a1.setAttribute("onmouseout", "UnTip()");
	td1.setAttribute("onclick", "Tip('<div id=BefoMsg><form id=MsgTo><table border=1 width=300><tr><td colspan=2 align=center>Сообщение пользователю <b>"+USER+"</b>:</td></tr><tr><td><input type=text id=sentmsg maxlength=50 size=45 /></td></tr><tr><td colspan=2 align=center><input type=button value=\"Отправить\" onclick=sendmsg(\""+USER+"\",\""+ui+"\",sentmsg.value) /></td></tr></table></form></div>',BORDERCOLOR,'#DDDDDD',BGCOLOR,'#DDDDDD',CLOSEBTN,'true',CLOSEBTNTEXT,'X',CLOSEBTNCOLORS,['#DDDDDD','#929292','#DDDDDD','#777777'],EXCLUSIVE,'true',DURATION,'0',OPACITY,'95',FIX,['informer',-50,-50],FADEIN,'400',HEIGHT,0,WIDTH,'31')");
					}
						td2 = document.createElement('td');
						text2=document.createTextNode(" "+give);
						td3 = document.createElement('td');
						text3=document.createTextNode(" "+get);
						td4 = document.createElement('td');
						text4=document.createTextNode(" "+reGion+" ");
						td42 = document.createElement('td');
					if (usd==0) text42=document.createTextNode(" до 100 ");
					if (usd==1) text42=document.createTextNode(" до 300 ");
					if (usd==2) text42=document.createTextNode(" до 500 ");
					if (usd==3) text42=document.createTextNode(" до 1000 ");
					if (usd==4) text42=document.createTextNode(" >1000 ");
						td42.appendChild(text42);
						td4.appendChild(text4);
						td3.appendChild(text3);
						td2.appendChild(text2);
						a1.appendChild(text1);
						td1.appendChild(a1);
						td.appendChild(text);
						tr.appendChild(td);
						tr.appendChild(td1);
						tr.appendChild(td2);
						tr.appendChild(td3);		
						tr.appendChild(td4);
						tr.appendChild(td42);
						tr.appendChild(td5);
						sel.appendChild(tr);
						i++;  		}
				
	if (response.resul[0]==null) { 		tr = document.createElement('tr');
						td = document.createElement('td');
						td.setAttribute("colspan", 7);
						text=document.createTextNode("Действующие предложения отсутствуют. Подайте заявку, дайте знать другим о нужном Вам варианте обмена.");
						td.appendChild(text);
						tr.appendChild(td);
						sel.appendChild(tr);
					}
}
//------------------------------------------------------------------------------------------------------------------------------------------
//отправка сообщения
function sendmsg(user,userid,txt) {
if (txt=='') { exit(); }
var url = '../beer/addmsg.php?us='+escape(user)+'&usid='+escape(userid)+'&tx='+encodeURIComponent(txt);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = sendmsgUpd;
xmlHttp.send(null);
}

function sendmsgUpd() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
if (xmlHttp.responseText==0) {
	MsgTo= document.getElementById("MsgTo");
	BefoMsg=document.getElementById("BefoMsg");
	BefoMsg.removeChild(MsgTo);
	sentok = document.createTextNode("Сообщение отправлено");
	br=document.createElement("br");
	BefoMsg.appendChild(sentok);
	BefoMsg.appendChild(br);
	}
}
}
}
//------------------------------------------------------------------------------------------------------------------------------------------
//появление формы для регистрации
function wind() {
clearWorkspace();
tr1 = document.createElement("tr");
tr1.setAttribute("id", "regynewuser");
tr1.setAttribute("align", "center");
td = document.createElement("td");
td.setAttribute("colspan", "4");
txt1 = document.createTextNode("Рeгистрация нового пользователя");
		sel.appendChild(tr1);
		tr1.appendChild(td);
		td.appendChild(txt1);
tr2 = document.createElement("tr");
td21=document.createElement("td");
td21.setAttribute("width", "15%");
td21Txt = document.createTextNode("Ваш ник:");
td22 = document.createElement("td");
td22.setAttribute("width", "45%");
td222 = document.createElement("td");
a222 = document.createElement("a");
a222.setAttribute("href", "javascript:regName()");
a222Txt = document.createTextNode("Проверить");
divName = document.createElement("div");
divName.setAttribute("id", "divName");
divNameTxt = document.createTextNode("Только латиница и цифры");
inputName = document.createElement("input");
inputName.setAttribute("type", "text");
inputName.setAttribute("id", "newname");
inputName.setAttribute("maxlength", "10");
inputName.setAttribute("onkeyup", "chk()");
td23 = document.createElement("td");
td23.setAttribute("width", "40%");
td23.setAttribute("id", "nameClear");
		sel.appendChild(tr2);
		tr2.appendChild(td21);
		td21.appendChild(td21Txt);
		tr2.appendChild(td22);
		td22.appendChild(inputName);
		tr2.appendChild(td222);
		td222.appendChild(a222);
		a222.appendChild(a222Txt);
		tr2.appendChild(td23);
		td23.appendChild(divName);
		divName.appendChild(divNameTxt);
tr3 = document.createElement("tr");
td31=document.createElement("td");
td31Txt = document.createTextNode("PIN-код:");
td32 = document.createElement("td");
for (i=0; i<=9; i++) {
	inputM[i]=document.createElement("input");
	inputM[i].setAttribute("type", "button");
	inputM[i].setAttribute("value", i);
	inputM[i].setAttribute("onclick", "pin(value)");
	inputM[i].setAttribute("style", "width:20px");
	}
sbros = document.createElement("input");
sbros.setAttribute("type","button");
sbros.setAttribute("value","Сброс");
sbros.setAttribute("onclick","pin()");
brr = document.createElement("br");
pp = document.createElement("input");
pp.setAttribute("type","text");
pp.setAttribute("size","9");
pp.setAttribute("id","pp");
pp.setAttribute("value","");
pp.setAttribute("readonly","readonly");	
td322 = document.createElement("td");
td33 = document.createElement("td");
td33.setAttribute("id", "pswdClear");
divPass = document.createElement("div");
divPass.setAttribute("id", "divPass");
divPassTxt= document.createTextNode("Длина PIN-кода 4 - 9 цифр")
		sel.appendChild(tr3);
		tr3.appendChild(td31);
		td31.appendChild(td31Txt);
		tr3.appendChild(td32);
for (i=0; i<=9; i++) { td32.appendChild(inputM[i]); }
		td322.appendChild(pp);
		td32.appendChild(brr);
		td32.appendChild(sbros);
		tr3.appendChild(td322);
		tr3.appendChild(td33);
		td33.appendChild(divPass);
		divPass.appendChild(divPassTxt);
tr4 = document.createElement("tr");
tr4.setAttribute("align", "center");
td4 = document.createElement("td");
td4.setAttribute("colspan", "4");
txt4 = document.createTextNode("Ваши контактные данные");
		sel.appendChild(tr4);
		tr4.appendChild(td4);
		td4.appendChild(txt4);
tr5 = document.createElement("tr");
td51=document.createElement("td");
td51Txt = document.createTextNode("Телефоны:");
td52 = document.createElement("td");
td52.setAttribute("colspan", "2");
inputPhone = document.createElement("input");
inputPhone.setAttribute("type", "text");
inputPhone.setAttribute("id", "newtel1");
inputPhone.setAttribute("onkeyup", "chk()");
inputPhone.setAttribute("maxlength", "15");
td53 = document.createElement("td");
inputPhone2 = document.createElement("input");
inputPhone2.setAttribute("type", "text");
inputPhone2.setAttribute("id", "newtel2");
inputPhone2.setAttribute("onkeyup", "chk()");
inputPhone2.setAttribute("maxlength", "15");
		sel.appendChild(tr5);
		tr5.appendChild(td51);
		td51.appendChild(td51Txt);
		tr5.appendChild(td52);
		td52.appendChild(inputPhone);
		tr5.appendChild(td53);
		td53.appendChild(inputPhone2);
tr6 = document.createElement("tr");
td61=document.createElement("td");
td61Txt = document.createTextNode("ICQ:");
td62 = document.createElement("td");
td62.setAttribute("colspan", "2");
inputIcq = document.createElement("input");
inputIcq.setAttribute("type", "text");
inputIcq.setAttribute("id", "newicq");
inputIcq.setAttribute("onkeyup", "chkIcq()");
inputIcq.setAttribute("maxlength", "9");
td63 = document.createElement("td");
td63.setAttribute("id", "newicqClear");
		sel.appendChild(tr6);
		tr6.appendChild(td61);
		td61.appendChild(td61Txt);
		tr6.appendChild(td62);
		td62.appendChild(inputIcq);
		tr6.appendChild(td63);
tr7 = document.createElement("tr");
td71=document.createElement("td");
td71Txt = document.createTextNode("Email:");
td72 = document.createElement("td");
td72.setAttribute("colspan", "2");
inputMail = document.createElement("input");
inputMail.setAttribute("type", "text");
inputMail.setAttribute("id", "newemail");
inputMail.setAttribute("onkeyup", "chk()");
inputMail.setAttribute("maxlength", "25");
td73 = document.createElement("td");
td73.setAttribute("id", "newemailconClear");
		sel.appendChild(tr7);
		tr7.appendChild(td71);
		td71.appendChild(td71Txt);
		tr7.appendChild(td72);
		td72.appendChild(inputMail);
		tr7.appendChild(td73);

tr9 = document.createElement("tr");
td91=document.createElement("td");
txt91= document.createTextNode("Ваш регион:");
td92=document.createElement("td");
country2 = document.createElement("select");
country2.setAttribute("id","country2");
country2.setAttribute("onchange","chng(value,2)");
		sel.appendChild(tr9);
		tr9.appendChild(td91);
		td91.appendChild(txt91);
		tr9.appendChild(td92);
		td92.appendChild(country2);
for (i=0;i<=16;i++) {
	opt[i]= document.createElement("option");
	opt[i].setAttribute("value",i);
	optTxt[i] = document.createTextNode(city[0][i]);
		country2.appendChild(opt[i]);
		opt[i].appendChild(optTxt[i]);
	}
region2= document.createElement("select");
region2.setAttribute("name","region2");
region2.setAttribute("id","region2");
region2.setAttribute("disabled","disabled");
value02 = document.createElement("option");
value02.setAttribute("value","0");
value02.setAttribute("id","value02");
value02txt= document.createTextNode("все регионы");
td93=document.createElement("td");
td94=document.createElement("td");
		tr9.appendChild(td93);
		tr9.appendChild(td94);
		td94.appendChild(region2);
		region2.appendChild(value02);
		value02.appendChild(value02txt);
trL = document.createElement("tr");
trL.setAttribute("align", "center");
tdL = document.createElement("td");
tdL.setAttribute("colspan", "4");
tdL.setAttribute("id", "tdButReg");
inputButt = document.createElement("input");
inputButt.setAttribute("type", "button");
inputButt.setAttribute("id", "DisBut");
inputButt.setAttribute("value", "Регистрируемся");
inputButt.setAttribute("disabled", "disabled");
		sel.appendChild(trL);
		trL.appendChild(tdL);
		tdL.appendChild(inputButt);
}

//------------------------------------------------------------------------------------------------------------------------------------------
//проверка на доступность нового регистрируемого имени
function regName() {
if (document.getElementById("divName")!=undefined) {
			nameClear = document.getElementById("nameClear");
			divName = document.getElementById("divName");
			nameClear.removeChild(divName);
			}
if (document.getElementById("reds")!=undefined) { 	red=document.getElementById("reds");
									redBefore=red.parentNode;
									redBefore.removeChild(red);
									}
if (document.getElementById("shr")!=undefined) { 	red=document.getElementById("shr");
									redBefore=red.parentNode;
									redBefore.removeChild(red);
									}
if (document.getElementById("svb")!=undefined) { 	red=document.getElementById("svb");
									redBefore=red.parentNode;
									redBefore.removeChild(red);
									}
if ((document.getElementById("newname").value!=undefined) && (document.getElementById("newname").value.length>2)) {
var nick = document.getElementById("newname").value;
	var url = '../beer/check.php?nick=' + escape(nick);
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = regNameOk;
	xmlHttp.send(null);
	}
if (document.getElementById("newname").value.length<3) {
		var nameClear = document.getElementById("nameClear");
		var b = document.createElement("b");
		b.setAttribute("id", "shr");
		ntCl = document.createTextNode("ИМЯ СЛИШКОМ КОРОТКОЕ");
		b.appendChild(ntCl);
		nameClear.appendChild(b); 	chk();}
}

function regNameOk() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
var response =xmlHttp.responseText;
if (response==0) {
	if (document.getElementById("reds")==undefined) {
		var nameClear = document.getElementById("nameClear");
		var b = document.createElement("b");
		b.setAttribute("id", "reds");
		ntCl = document.createTextNode("ИМЯ ЗАНЯТО");
		b.appendChild(ntCl);
		nameClear.appendChild(b);   chk();}
		}
if (response==1) {
	if (document.getElementById("reds")==undefined) {
		var nameClear = document.getElementById("nameClear");
		var b = document.createElement("b");
		b.setAttribute("id", "svb");
		ntCl = document.createTextNode("СВОБОДНО");
		b.appendChild(ntCl);
		nameClear.appendChild(b); 
		chk();			}
		}
	}
    }
}
//------------------------------------------------------------------------------------------------------------------------------------------
//проверка на ввод pina при входе
function pinLogin(d) {
var pp = document.getElementById("ppLogin");
var sbros = document.getElementById("sbros");
if (d==null) { pp.setAttribute("value",""); sbros.setAttribute("disabled","disabled"); }
else { txt=pp.getAttribute("value");
	if (txt.length<9) {
		newvalue=txt+d;
		pp.setAttribute("value", newvalue);
		sbros.removeAttribute("disabled"); }
	}
}
//.. при регистрации
function pin(d) {
var pp = document.getElementById("pp");
if (d==null) { pp.setAttribute("value",""); chk();  }
else { txt=pp.getAttribute("value");
	if (txt.length<9) {
		newvalue=txt+d;
		pp.setAttribute("value", newvalue);
		chk();	 }
	}
}

//..при потдверждении изменения
function pinChange(d) {
var pp = document.getElementById("ppChange");
var esc = document.getElementById("escChange");
if (d==null) { pp.setAttribute("value",""); esc.setAttribute("disabled","disabled"); }
else { txt=pp.getAttribute("value");
	if (txt.length<9) {
		newvalue=txt+d;
		pp.setAttribute("value", newvalue);
		esc.removeAttribute("disabled"); }
	}
}
//..при вводе нового
function pinNew(d) {
var pp = document.getElementById("ppNew");
var esc = document.getElementById("escNew");
if (d==null) { pp.setAttribute("value",""); esc.setAttribute("disabled","disabled"); }
else { txt=pp.getAttribute("value");
	if (txt.length<9) {
		newvalue=txt+d;
		pp.setAttribute("value", newvalue);
		esc.removeAttribute("disabled"); }
	}
}
//------------------------------------------------------------------------------------------------------------------------------------------
//регистрация если заполнены все поля появляется кнопка для входа
function chk() {
tdButReg=document.getElementById("tdButReg");
if ((document.getElementById("newname").value.length>2) && (document.getElementById("pp").value.length>=4)
	&& (document.getElementById("butReg")==undefined))
	{
	  butReg = document.createElement("input");
	  butReg.setAttribute("type", "button");
	  butReg.setAttribute("value", "Регимся");
  	  butReg.setAttribute("onclick", "regy()");
	  butReg.setAttribute("id", "butReg");
	  DisBut = document.getElementById("DisBut");
	  tdButReg.removeChild(DisBut);
	  tdButReg.appendChild(butReg);  }
if (((document.getElementById("newname").value.length<3) || (document.getElementById("pp").value.length<4)) &&
	(document.getElementById("butReg")!=undefined)) 
	{
	butReg = document.getElementById("butReg"); 
	prt = butReg.parentNode;
	prt.removeChild(butReg);
	inputButt = document.createElement("input");
	inputButt.setAttribute("type", "button");
	inputButt.setAttribute("id", "DisBut");
	inputButt.setAttribute("value", "Регимся");
	inputButt.setAttribute("disabled", "disabled");
	tdButReg.appendChild(DisBut);
					 }
}
//------------------------------------------------------------------------------------------------------------------------------------------
//проверка на правильность ввода ICQ
function chkIcq() {
if (document.getElementById("gdIcq") != undefined) { gdIcq = document.getElementById("gdIcq"); Parent = gdIcq.parentNode; Parent.removeChild(gdIcq); }
if (document.getElementById("ngdIcq") != undefined) { ngdIcq = document.getElementById("ngdIcq"); Parent = ngdIcq.parentNode; Parent.removeChild(ngdIcq); }
newicqClear = document.getElementById("newicqClear");
newicq = document.getElementById("newicq").value;
var b = document.createElement("b");
var pat = /^([1-9])+([0-9])+$/;
if ((newicq.match(pat)) && (newicq.length<10) && (newicq.length>4)) 
	{ 	b.setAttribute("id", "gdIcq");
		ntCl = document.createTextNode("OK");
		 }
else { 	            b.setAttribute("id", "ngdIcq");
		ntCl = document.createTextNode("НЕ ВЕРНЫЙ НОМЕР");
		 }
b.appendChild(ntCl);
newicqClear.appendChild(b);
}
//------------------------------------------------------------------------------------------------------------------------------------------
//регистрация юзера
function regy() {
var nick = document.getElementById("newname").value;
var pswd = document.getElementById("pp").value;
var newtel1 = document.getElementById("newtel1").value;
var newtel2 = document.getElementById("newtel2").value;
var newicq = document.getElementById("newicq").value;
var newemail = document.getElementById("newemail").value;
var gorod = document.getElementById("region2").value;
if ((document.getElementById("newname").value.length>2)&&(document.getElementById("pp").value.length>=4))
	{
	var url = '../beer/regnew.php?nick=' + escape(nick)+'&pswd='+escape(pswd)+'&newtel1='+escape(newtel1)+'&newtel2='+escape(newtel2)+'&newicq='+escape(newicq)+'&newemail='+escape(newemail)+'&city='+escape(gorod);
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = newUserUpd;
	xmlHttp.send(null);
	}
else {alert("You typed something wrong");}
}

function newUserUpd() {
if (xmlHttp.readyState < 4) waitLoad();
else {
if (xmlHttp.status == 200) {
var response =xmlHttp.responseText;
if (response==1) { location.href='index.php';}
if (response==0) {alert("You typed something wrong");}
	}
     }
}
//---------------------------------------------------------------------------------------------------------------------------------
//показывает последние заявки
function last() {
var url = '../beer/choise.php';
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = obmenUpd;
xmlHttp.send(null);
}
//---------------------------------------------------------------------------------------------------------------------------------
//показ тех кому не дал ещё оценки
function owait(id) {
var url = '../beer/owait.php?napr='+escape(id);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = owaitUpd;
xmlHttp.send(null);
}

function owaitUpd() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
clearWorkspace();
var responze=eval("("+xmlHttp.responseText+")");
	i=0;

if ((responze.resul[0]!=null) && (responze.resul[0].owait=='1')) {
tr0=document.createElement("tr");
txt0=document.createTextNode("Ждут Ваших оценок. Я принял заявки");
td0=document.createElement("td");
td0.setAttribute("align","center");
td0.setAttribute("colspan","7");
	td0.appendChild(txt0);
	tr0.appendChild(td0);
	sel.appendChild(tr0);
tr1=document.createElement("tr");
tr1.setAttribute("id","trFirst");
for(st=0; st<=4; st++) {
tdM[st]=document.createElement("td");
	switch(st) {
		case 0: txtM[0]=document.createTextNode("Заявка принята");
			tdM[0].appendChild(txtM[0]);
		break;
		case 1: txtM[1]=document.createTextNode("Пользователь");
			tdM[1].appendChild(txtM[1]);
		break;
		case 2: txtM[2]=document.createTextNode("Отдавал");
			tdM[2].appendChild(txtM[2]);
		break;
		case 3: txtM[3]=document.createTextNode("Вы получали");
			tdM[3].appendChild(txtM[3]);
		break;
		case 4: txtM[4]=document.createTextNode("Оценка сделки");
			tdM[4].appendChild(txtM[4]);
			tdM[4].setAttribute("colspan","3");
		break;
		}
tr1.appendChild(tdM[st]);
	}
sel.appendChild(tr1);
}

if ((responze.resul[0]!=null) && (responze.resul[0].owait=='0')) {
tr0=document.createElement("tr");
txt0=document.createTextNode("Мои заявки приняли");
td0=document.createElement("td");
td0.setAttribute("align","center");
td0.setAttribute("colspan","7");
	td0.appendChild(txt0);
	tr0.appendChild(td0);
	sel.appendChild(tr0);
tr1=document.createElement("tr");
tr1.setAttribute("id","trFirst");
for(st=0; st<=4; st++) {
tdM[st]=document.createElement("td");
	switch(st) {
		case 0: txtM[0]=document.createTextNode("Дата принятия");
			tdM[0].appendChild(txtM[0]);
		break;
		case 1: txtM[1]=document.createTextNode("Пользователь");
			tdM[1].appendChild(txtM[1]);
		break;
		case 2: txtM[2]=document.createTextNode("Хочет получить");
			tdM[2].appendChild(txtM[2]);
		break;
		case 3: txtM[3]=document.createTextNode("Вы получаете");
			tdM[3].appendChild(txtM[3]);
		break;
		case 4: txtM[4]=document.createTextNode("Оценка сделки");
			tdM[4].appendChild(txtM[4]);
			tdM[4].setAttribute("colspan","3");
		break;
		}
tr1.appendChild(tdM[st]);
	}
sel.appendChild(tr1);
}



	if (responze.resul[0]==null) { 		trL = document.createElement("tr");
						tdL = document.createElement("td");
						tdL.setAttribute("colspan", 7);
						textL=document.createTextNode("предложения отсутствуют");
						tdL.appendChild(textL);
						trL.appendChild(tdL);
						sel.appendChild(trL);	}
	while(responze.resul[i]!=null) { 
		ow=responze.resul[i].owait;
		date=responze.resul[i].date;
		us = responze.resul[i].us;
		usid = responze.resul[i].usid;
		ot = responze.resul[i].ot;
		po=responze.resul[i].po;
		ido=responze.resul[i].ido;
		tr=document.createElement("tr");
		tr.setAttribute("onmouseover","this.style.backgroundColor='#f3f4fb'");
		tr.setAttribute("onmouseout","this.style.backgroundColor='#FFFFFF'");

		for(sti=0; sti<=6; sti++) {
			tdM[sti]=document.createElement("td");
			switch(sti) {
				case 0: txtM[sti]=document.createTextNode(date);
					tdM[sti].appendChild(txtM[sti]);
				break;
				case 1: txtM[sti]=document.createTextNode(us);
					aM[sti]= document.createElement("a");
					aM[sti].setAttribute("href","javascript:void(0)");
					aM[sti].setAttribute("onclick","IsMsg('"+us+"',"+usid+")");
					aM[sti].setAttribute("onmouseover", "Tip('Моя переписка c "+us+"')");
					aM[sti].setAttribute("onmouseout", "UnTip()");
					aM[sti].appendChild(txtM[sti]);
					tdM[sti].appendChild(aM[sti]);
				break;
				case 2: txtM[sti]=document.createTextNode(ot);
					tdM[sti].appendChild(txtM[sti]);
				break;
				case 3: txtM[sti]=document.createTextNode(po);
					tdM[sti].appendChild(txtM[sti]);
				break;
				case 4: imgM[sti]=document.createElement("img");
					imgM[sti].setAttribute("src","../img/1.gif");
					imgM[sti].setAttribute("width","20");
					imgM[sti].setAttribute("border","0");
					aM[sti]=document.createElement("a");
					aM[sti].setAttribute("href","javascript:void(0)");
					aM[sti].setAttribute("onclick", "ocenivaem(1,"+ido+",'"+us+"',"+ow+")");
					aM[sti].appendChild(imgM[sti]);
					aM[sti].setAttribute("onmouseover", "Tip('Сделка прошла успешно')");
					aM[sti].setAttribute("onmouseout", "UnTip()");
					tdM[sti].setAttribute("align","center");
					tdM[sti].appendChild(aM[sti]);
				break;
				case 5: imgM[5]=document.createElement("img");
					imgM[5].setAttribute("src","../img/2.gif");
					imgM[5].setAttribute("width","20");
					imgM[5].setAttribute("border","0");
					aM[5]=document.createElement("a");
					aM[5].setAttribute("href","javascript:void(0)");
					aM[5].setAttribute("onclick", "ocenivaem(2,"+ido+",'"+us+"',"+ow+")");
					aM[5].appendChild(imgM[5]);
					aM[5].setAttribute("onmouseover", "Tip('Сделка не состоялась')");
					aM[5].setAttribute("onmouseout", "UnTip()");
					tdM[5].setAttribute("align","center");
					tdM[5].appendChild(aM[5]);
				break;
				case 6: imgM[6]=document.createElement("img");
					imgM[6].setAttribute("src","../img/3.gif");
					imgM[6].setAttribute("width","20");
					imgM[6].setAttribute("border","0");
					aM[6]=document.createElement("a");
					aM[6].setAttribute("href","javascript:void(0)");
					aM[6].setAttribute("onclick", "ocenivaem(3,"+ido+",'"+us+"',"+ow+")");
					aM[6].appendChild(imgM[6]);
					aM[6].setAttribute("onmouseover", "Tip('Кидала')");
					aM[6].setAttribute("onmouseout", "UnTip()");
					tdM[6].setAttribute("align","center");
					tdM[6].appendChild(aM[6]);
				break;
				}
		tr.appendChild(tdM[sti]);
		}
		sel.appendChild(tr);
		i++;
	}	
}
}
}
//---------------------------------------------------------------------------------------------------------------------------------
//оценка юзера - оценка, идобмена,никюзера,тип(принятые,ждут ответа)
function ocenivaem(oc,t,f,tt) {
var url = '../beer/oceni.php?oc='+escape(oc)+'&t='+escape(t)+'&f='+escape(f)+'&tt='+escape(tt);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = ocenivaemUpd;
xmlHttp.send(null);
}

function ocenivaemUpd() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
alert("Спасибо, за Вашу честность. Это поможет будущим клиентам");
owait(xmlHttp.responseText);
}
}
}
//---------------------------------------------------------------------------------------------------------------------------------
function IsMsg(Usr,idUsr) {
var url = '../beer/showmssg.php?usid='+escape(idUsr)+'&us='+escape(Usr);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = IsMsgUpd;
xmlHttp.send(null);
}
function IsMsgUpd() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
Tip(xmlHttp.responseText,BORDERCOLOR,'#DDDDDD',BGCOLOR,'#DDDDDD',CLOSEBTN,'true',CLOSEBTNTEXT,'X',CLOSEBTNCOLORS,['#DDDDDD','#929292','#DDDDDD','#777777'],EXCLUSIVE,'true',DURATION,'0',OPACITY,'95',FIX,['informer',-50,-50],FADEIN,'200',HEIGHT,0,WIDTH,'30');
}
}
}

//переписка юзера 2
function ls(idUsr) {
clearWorkspace();
var url = '../beer/showmssg.php';
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = IsUpd;
xmlHttp.send(null);
}

function IsUpd() {
if (xmlHttp.readyState== 4) { 
if (xmlHttp.status == 200) {
	clearWorkspace();
	tr = document.createElement("tr");
	td = document.createElement("td");
	td.setAttribute("colspan", "5");
	td.setAttribute("align", "center");
	txt = document.createTextNode("Раздел сообщений");
		td.appendChild(txt);
		tr.appendChild(td);
		sel.appendChild(tr);
tr2 = document.createElement("tr");
tr2.setAttribute("id","trFirst");
td2 = document.createElement("td");
text=document.createTextNode("Дата");
td21 = document.createElement("td");
text21=document.createTextNode("Направление");
td22 = document.createElement("td");
text22=document.createTextNode("Юзер");
td23 = document.createElement("td");
text23=document.createTextNode("Текст сообщения");
td24 = document.createElement("td");
text24=document.createTextNode("Тема");
	td24.appendChild(text24);
	td23.appendChild(text23);
	td22.appendChild(text22);
	td21.appendChild(text21);
	td2.appendChild(text);
	tr2.appendChild(td2);
	tr2.appendChild(td21);
	tr2.appendChild(td22);
	tr2.appendChild(td23);
	tr2.appendChild(td24);
	sel.appendChild(tr2);

var responz=eval("("+xmlHttp.responseText+")");
			i=0;
				while(responz.resul[i]!=null) { 
						type=responz.resul[i].type;
						napr=responz.resul[i].napr;
						user=responz.resul[i].user;
						msg=responz.resul[i].msg;
						date=responz.resul[i].date;
						usid=responz.resul[i].usid;
					if (type==0) type="Обмен";
					else type="Переписка";
				if (napr==0) napr="Входящее";
				else napr="Исходящее";
			
						tr3 = document.createElement('tr');
						td1 = document.createElement('td');
						txt1=document.createTextNode(date);
						td2 = document.createElement('td');
						txt2=document.createTextNode(napr);
						td3 = document.createElement('td');
						txt3=document.createTextNode(user);
						a3 = document.createElement("a");
						a3.setAttribute("href","javascript:void(0)");
						a3.setAttribute("onmouseover","Tip('Моя переписка с "+user+"')");
						a3.setAttribute("onmouseout","UnTip()");
						a3.setAttribute("onclick","IsMsg('"+user+"',"+usid+")");
						td4 = document.createElement('td');
						txt4=document.createTextNode(msg);
						td5 = document.createElement('td');
						txt5=document.createTextNode(type);
						td1.appendChild(txt1);
						td2.appendChild(txt2);
						a3.appendChild(txt3);
						td3.appendChild(a3);
						td4.appendChild(txt4);
						td5.appendChild(txt5);
						tr3.appendChild(td1);
						tr3.appendChild(td2);
						tr3.appendChild(td3);
						tr3.appendChild(td4);
						tr3.appendChild(td5);
						sel.appendChild(tr3);
						i++;  		}
				
	if (responz.resul[0]==null) { 		tr = document.createElement('tr');
						td = document.createElement('td');
						td.setAttribute("colspan", "5");
						text=document.createTextNode("сообщения отсутствуют");
						td.appendChild(text);
						tr.appendChild(td);
						sel.appendChild(tr);
					}
}
}
}
//---------------------------------------------------------------------------------------------------------------------------------
//выбор региона в зависимости от страны tup - место в котором эта форма появляется, 1 -в форме поиска,2-регистрация,3-
function chng(val,tup) {
sel=document.getElementById('region'+tup);
while(document.getElementById('valueOld'+tup)!=undefined) {
					valueOld = document.getElementById('valueOld'+tup);
					sel.removeChild(valueOld);
					}
sel.removeAttribute('disabled');		
option0=document.getElementById('value0'+tup);
if (val==1) { valOpt=2; option0.setAttribute('value','1'); }
if (val==2) { valOpt=51; option0.setAttribute('value','50'); }
if (val==3) { valOpt=101; option0.setAttribute('value','100'); }
if (val==0) { valOpt=0; option0.setAttribute('value','0'); sel.setAttribute('disabled','disabled'); }
if (val==4) { valOpt=201; option0.setAttribute('value','200');  }
if (val==5) { valOpt=221; option0.setAttribute('value','220');  }
if (val==6) { valOpt=241; option0.setAttribute('value','240');  }
if (val==7) { valOpt=261; option0.setAttribute('value','260');  }
if (val==8) { valOpt=281; option0.setAttribute('value','280');  }
if (val==9) { valOpt=301; option0.setAttribute('value','300');  }
if (val==10) { valOpt=321; option0.setAttribute('value','320');  }
if (val==11) { valOpt=341; option0.setAttribute('value','340');  }
if (val==12) { valOpt=361; option0.setAttribute('value','360');  }
if (val==13) { valOpt=381; option0.setAttribute('value','380');  }
if (val==14) { valOpt=401; option0.setAttribute('value','400');  }
if (val==15) { valOpt=421; option0.setAttribute('value','420');  }
if (val==16) { valOpt=441; option0.setAttribute('value','440');  }
for (i=0; i<=199;i++,valOpt++) {
	if (city[val][i]!=undefined) { 
				option = document.createElement('option');
				optionTxt=document.createTextNode(city[val][i]);
				option.setAttribute('value',valOpt);
				option.setAttribute('id','valueOld'+tup);
				option.appendChild(optionTxt);
				sel.appendChild(option);
					}
				}
}
//---------------------------------------------------------------------------------------------------------------------------------
//разблокирование кнопки "Найти"
function formSear(val,regg) {
butSearch = document.getElementById("butSearch");
if (val==0) butSearch.setAttribute("disabled","disabled");
else if ((val==1)&&(regg==0)) butSearch.setAttribute("disabled","disabled");
else if (val!=0) butSearch.removeAttribute("disabled");

}
//---------------------------------------------------------------------------------------------------------------------------------
//запрос пароля
function remember() {
clearWorkspace();
tr0=document.createElement("tr");
txt0=document.createTextNode("Восстановление пароля или имени, а также пожелания, предложения....");
td0=document.createElement("td");
td0.setAttribute("align","center");
td0.setAttribute("colspan","2");
	td0.appendChild(txt0);
	tr0.appendChild(td0);
	sel.appendChild(tr0);
form=document.createElement("form");
tableForm=document.createElement("table");
	td0.appendChild(form);
	form.appendChild(tableForm);
tr1= document.createElement("tr");
td1=document.createElement("td");
td2=document.createElement("td");
tr2= document.createElement("tr");
td21=document.createElement("td");
td22=document.createElement("td")
input=document.createElement("input");
input.setAttribute("type", "text");
input.setAttribute("id","inp");
input.setAttribute("maxlength", "100");
input.setAttribute("size", "50");
button=document.createElement("input");
button.setAttribute("type", "button");
button.setAttribute("value", "Направить");
button.setAttribute("onclick", "wrote(inp.value)");
Txt=document.createTextNode("Введите Ваши данные, которые вы помните (имя или пароль)...либо пишите по любым вопросам, связанным с Webratex");
Txt2=document.createTextNode("В течении суток Вам будут высланы имя и пароль на Ваш e-mail");
	tableForm.appendChild(tr1);
	tr1.appendChild(td1);
	tr1.appendChild(td2);
	td1.appendChild(Txt);
	td2.appendChild(input);
	tableForm.appendChild(tr2);
	tr2.appendChild(td21);
	tr2.appendChild(td22);
	td21.appendChild(Txt2);
	td22.appendChild(button);
}

function wrote(msg) {
clearWorkspace();
var url = '../beer/sendus.php?msg='+encodeURIComponent(msg);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = wroteUpd;
xmlHttp.send(null);
}

function wroteUpd() {
if (xmlHttp.readyState== 4) { 
if (xmlHttp.status == 200) {
	clearWorkspace();
location.href="index.php";
}	}	}
//---------------------------------------------------------------------------------------------------------------------------------
//FAQ
function faq() {
clearWorkspace();
tr = document.createElement("tr");
td = document.createElement("td");
p = document.createElement("div");
p1 = document.createElement("div");
br= document.createElement("br");
br1= document.createElement("br");
citat= document.createElement("cite");
citat1= document.createElement("cite");
txt1=document.createTextNode("Что такое биржа обмена электронных валют Webratex?");
txt2=document.createTextNode("Зачем нужен сервис Гарант Webratex?");
txt3=document.createTextNode("Могу ли я работать не регистрируясь на сайте?");
txt4=document.createTextNode("Я зарегистрировался и хочу, чтобы всегда при открытии сайта webratex.com я уже был авторизован. Иначе я постоянно трачу время на ввод своего имени и пина?");
txt5=document.createTextNode("На сайте предусмотрены принятия заявок, оценка пользователей по результатам обмена. Зачем мне это?");
txt6=document.createTextNode("Я забыл пин и имя пользователя?");
txt7=document.createTextNode("Как я могу заработать при помощи биржы валют?");
txt8=document.createTextNode("Почему сайт такой глючный?");
txt9=document.createTextNode("Кто сделал такой не красивый вид сайта?");
r1=document.createTextNode("В современном мире существует множество элетронных платежных систем. Причем обмен денег из одной системы в другую не всегда возможен, либо сулит значительные потери на коммисиях. Каждый год рождаются и умирают различные платежные системы, но пользователи сети Интернет не должны быть жертвами отсутсвия способа вывода либо ввода электронных денег. Ведь всегда есть тот кто продает и найдется тот, кто хочет купить. Биржа Webratex является Интернет площадкой созданной для всех пользователей столкнувшихся с проблемой многообразия электронных валют в сети Интернет и предназначена для осуществления поиска нужного варианта обмена электронных валют, в нужном регионе, а также для подачи своих предложений по необходимому направлению обмена.");
r2=document.createTextNode("Сеть кишит мошенниками. Ведь Интернет вселяет мнимую уверенность в незаметность совершаемых действий. Сервис Гарант обеспечивает защиту от кидалова за счет использования в обменной операции третьего не заинтересованного в обмене лица. Таким образом при совершении обмена, средства от обоих участников сделки должны поступить на счета Гаранта и лишь затем перечиляются адресатам. Услуга сервиса Гарант платная - при обмене вычитается 1% от переводимой через Гарант суммы, без учета комиссий взымаемых платежными системами. Однако это мелочь в сравнении с безопасностью и гарантированным переводом средств. Обмен совершается только в том случае если оба участника сделки переводят на счета Гаранта оговоренную сумму обмена. Если один из участников принятой заявки отказывается от сделки через Гарант, средства без взымания 1% возвращаются пользователю не отказавшемуся от обмена. Участник отказывашийся от сделки, в не зависимости от причин отказа, получает в свою репутацию отрицательный отзыв от сервиса Гарант. После двух отрицательных отзывов Гаранта пользоваель попадает под тщательную проверку, по результатам которой он может быть заблокированным на бирже. В целях безопасности мы не рекомендуем производить обмен с незнакомыми пользователями, как бы мило они себя не вели. О всех фактах мошеничества либо попыток килалова просьба сообщать в суппорт Webratex ");
r3=document.createTextNode("Каждый может ознакамливаться с имеющимися на сайте заявками. Однако не зарегистрированный пользователь имеет ограниченный набор функций. В частности у такого пользователя отсутсвует возможность просмотра репутации, того кто подал заявку и истории работы заявителя, отсутсвует возможность принятия заявок и соответсвенно оповещения заявителю о своем желании совершить обмен, кроме того заявки на бирже поданные через сервис Гарант, доступны только для зарегистрированных пользователей. Ну, и конечно же не зарегистрированный пользователь не имеет права размещать объявление на бирже.");
r4=document.createTextNode("В целях безопасности, биржа не поддерживает cookie, являющиеся основой Ваших требований.");
r5=document.createTextNode("Для того чтобы быть уверенным в совершаемых сделках с незнакомыми пользователями, необходимо чтобы у таких пользователей был значимый авторитет, который может быть им получен только если до обмена с Вами его объективно оценивали другие. Давая объективную оценку тому или иному пользователю, с которым Вы совершали обмен Вы помогаете не только другим узнать о качестве работы с таким пользователем, но помагаете и себе. Ведь, чем больше из нас будут справедливы в своих оценках, тем меньше шансов у мошенников. Справедливости не должно быть мало.");
r6=document.createTextNode("Отпишите в суппорт с указанием Ваших других контактных данных, которые Вы оставляли на сайте. Также будет не лишним отписать Ваше последнее время посещения, периодичность. После проверки мы направим Вам имя и пин на один из Ваших контактов");
r7=document.createTextNode("Владельцам сайтов предлагаем вариант привлечения пользователей на биржу Webratex с оплатой за каждого направленного пользователя. Подробнее");
r8=document.createTextNode("Биржа постоянно оптимизируется (надеемся что улучшается), в настоящее время у нас не совсем коректно отображаются определенные разделы в браузерах на основе Internet Explorer и Google Chrome.");
r9=document.createTextNode("Целью создания сайта было получение максимальной производительности и обечпечение быстроты загрузки и легкости работы сайта. Создатели биржы являются приверженцами движения MAT(Man againts traffic), направленного на продвижение сайтов несущих в себе максимальное колличество полезной информации при минимальном объеме графики, мультимедия и иного трафика, тормозящего работу и отвлекающего от нужной информации. ");
p.appendChild(citat);
citat.appendChild(txt1);
p.appendChild(br);
p.appendChild(r1);
p.appendChild(p1);
p1.appendChild(citat);
citat1.appendChild(txt2);
p1.appendChild(br1);
p1.appendChild(r2);

td.appendChild(p);
tr.appendChild(td);
sel.appendChild(tr);
}
//---------------------------------------------------------------------------------------------------------------------------------
//Описание Гаранта
function fraud() {
clearWorkspace();
tr = document.createElement("tr");
td = document.createElement("td");
br = document.createElement("br");
br1 = document.createElement("br");
br2 = document.createElement("br");
br3 = document.createElement("br");
txt=document.createTextNode("Сеть кишит мошенниками. Интернет вселяет в них мнимую уверенность в незаметность совершаемых действий. Сервис Гарант обеспечивает защиту от мошенничества со стороны участников обмена за счет использования в обменной операции третьего не заинтересованного в обмене лица.");
txt1=document.createTextNode("Для совершения обмена через Гарант, участник подающий на бирже объявление должен отметить опцию - Работать через Гарант-, подрозумевая, что обмен по данной заявке возможен лишь через Гарант. Другой участник биржи при согласии на обмен и работу через Гарант обязан при просмотре данной заявки принять её путем нажатия имеющейся кнопки -Принять заявку- . После того как участники оговаривают сумму сделки и время перевода, оба должны отписать в Гарант о готовности перевода. Средства от обоих участников сделки должны поступить на счета Гаранта и лишь затем перечиляются адресатам.");
txt2=document.createTextNode("При работе через услугу вычитается 1% от переводимой через Гарант суммы, в качестве вознаграждения Гаранта, без учета комиссий взымаемых платежными системами. Взамен Гарант обеспечивает гарантированный перевод средств. Обмен совершается только в том случае если оба участника сделки переводят на счета Гаранта оговоренную сумму обмена. Если один из участников принятой заявки отказывается от сделки через Гарант,либо переводит менее оговоренной с партнером суммы, средства без взымания 1% возвращаются пользователю не отказавшемуся от обмена. При переводе на счет Гаранта сумм больше оговоренных остаток денег, без взымания вознаграждения Гаранта возвращается на счет откуда деньги поступили");
txt3 = document.createTextNode("Участник принявший заявку либо её разместивший и отказывашийся от совершения сделки, уже после перечисления оппонентом денег на счет Гаранта, в не зависимости от причин отказа, получает в свою репутацию отрицательный отзыв от сервиса Гарант. После двух отрицательных отзывов Гаранта пользоваель попадает под тщательную проверку, по результатам которой он может быть заблокированным на бирже. В целях безопасности мы не рекомендуем производить обмен с незнакомыми пользователями, как бы мило они себя не вели. О всех фактах мошеничества либо попыток килалова просьба сообщать в суппорт Webratex.");
td.appendChild(txt);
td.appendChild(br);
td.appendChild(txt1);
td.appendChild(br1);
td.appendChild(txt2);
td.appendChild(br2);
td.appendChild(txt3);
tr.appendChild(td);
sel.appendChild(tr);
}
//---------------------------------------------------------------------------------------------------------------------------------
//Заработок

function earn() {
clearWorkspace();
tr = document.createElement("tr");
td = document.createElement("td");
br = document.createElement("br");
txt = document.createTextNode("Для владельцев сайтов предлагаем дополнительный способ заработка. Разместите на своем сайте форму для поиска обмена электронных валют на бирже Webratex. За каждых 100 уникальных посетителей приглашенных Вами мы начисляем 1 доллар США в желаемой Вами электронной валюте.");
txt1= document.createTextNode("Для получения формы поиска валют под Ваш сайт, необходимо предварительно зарегистрироваться на бирже Webratex и затем связаться с нами с указанием Вашего ника на бирже, а также адреса сайта на котором Вы желаете разместить форму поиска");
exmpl = document.createElement("img");
exmpl.setAttribute("src","img/exmpl.png");
tr.appendChild(exmpl);
td.appendChild(txt);
td.appendChild(br);
td.appendChild(txt1);
tr.appendChild(td);
sel.appendChild(tr);
}
