var vrqos=0
var mr=0
var rfact=0
var send_sfh=0
var vrqw=0
var nsp=-1
var cnl=-1
var vqrel1=0
var issetnewans=0
var openmenu=0
var js_delay=7000
var whait1='<SPAN class="whinfo">Пожалуйста, подождите. Выполняется запрос...&nbsp;</SPAN>';
var whait2='<SPAN class="whinfo">Сервер обрабатывает Ваш запрос, пожалуйста, подождите...&nbsp;</SPAN>';
var tresp=0
var catselr=''
var scrolltop=0

function mktime()
{
	timestamp = new Date().getTime();
	return timestamp;
}


var request = false;

try { request = new XMLHttpRequest(); } 
catch (trymicrosoft) {
 try { request = new ActiveXObject("Msxml2.XMLHTTP"); } 
 catch (othermicrosoft) { 
  try { request = new ActiveXObject("Microsoft.XMLHTTP"); } 
  catch (failed) {
   request = false;
   }  
  }
 }
 
function swst(idordb,nsc,rcol,dp) {
request.open("POST", "swstat.php", true);
request.onreadystatechange = sh_status; 
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
request.send("idordb="+idordb+"&newstat="+nsc+"&rowcolor="+rcol+"&dp="+dp);
}


function autlosfv() {
request.open("POST", "autlosfv.php", true);
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
request.send("empty=");
}

function showfindhis(v) {
if(v!='') {
request.open("POST", "sh_f_his.php", true);
request.onreadystatechange = sh_f_his; 
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
send_sfh=1;
request.send("value="+v);
} else {
document.all("findhistoryspan").style.display="none";
document.all("findhistoryspan").innerHTML=""; 
}
}


function sh_f_his() {
if (request.readyState == 4) {
if (request.status == 200) {
if(send_sfh==1) {
resp = request.responseText.split("^");
if(resp[0]!=0) {
document.all("findhistoryspan").style.display="block";
document.all("findhistoryspan").innerHTML=resp[1];
} else { 
document.all("findhistoryspan").style.display="none";
document.all("findhistoryspan").innerHTML=""; 
}
send_sfh=0
}
}
}
}

function sh_status() {
if (request.readyState == 4) {
if (request.status == 200) {
resp = request.responseText.split("^|^");
if(resp[1]!="0") {
document.all("stat_td_"+resp[1]).innerHTML = resp[2]; 
document.all("but_td_"+resp[1]).innerHTML = resp[3]; 
document.all("edcnt_td_"+resp[1]).innerHTML = resp[4]; 
document.all("edprc_td_"+resp[1]).innerHTML = resp[5]; 
if(resp[0]!=-1) { 
document.all("row_"+resp[1]).style.backgroundColor = resp[6]; 
document.all("row_"+resp[1]).style.color = "#000000"; 
document.all("type_ordb_"+resp[1]).style.color = resp[7];
} 
else { 
document.all("row_"+resp[1]).style.backgroundColor = "#f4ebe6"; 
document.all("row_"+resp[1]).style.color = "#bbbbbb"; 
document.all("type_ordb_"+resp[1]).style.color = "#bbbbbb"; 
} 
if(resp[8]!="0") {
if(resp[6]=="#f0f0f0") nextcolor="#ffffff";
if(resp[6]=="#ffffff") nextcolor="#f0f0f0";
if(resp[6]=="#e0e0f0") nextcolor="#eeeeff";
if(resp[6]=="#eeeeff") nextcolor="#e0e0f0";
swst(resp[8],resp[0],nextcolor,1);
}
}
} else alert("Status is " + request.status);
} 
}

function sh_type() {
if (request.readyState == 4) {
if (request.status == 200) {
resp = request.responseText.split("^|^");
if(resp[0]!="_") {
if(resp[1]!="-1") {
if(resp[0]=="1") { document.all("type_ordb_"+resp[2]).style.color = "#006600"; document.all("type_ordb_"+resp[2]).innerHTML = "Основной&nbsp;&nbsp;&nbsp;"; }
if(resp[0]=="0") { document.all("type_ordb_"+resp[2]).style.color = "#bb0000"; document.all("type_ordb_"+resp[2]).innerHTML = "Backorder&nbsp;&nbsp;&nbsp;"; }
} else {
document.all("type_ordb_"+resp[2]).style.color = "#bbbbbb";
if(resp[0]=="1") { document.all("type_ordb_"+resp[2]).innerHTML = "Основной&nbsp;&nbsp;&nbsp;"; }
if(resp[0]=="0") { document.all("type_ordb_"+resp[2]).innerHTML = "Backorder&nbsp;&nbsp;&nbsp;"; }
}
}
} else alert("Status is " + request.status);
} 
}

function swtypeord(idordb) {
if(confirm("Изменить тип заказа?")) {
request.open("POST", "swtype.php", true);
request.onreadystatechange = sh_type; 
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
request.send("idordb="+idordb);
}
}

function vraf() {
if(vrqos==0) {
if(vrqw==0) document.all("vinreq").style.display="block"
vrqw=vrqw+tdl
if(vrqw<500) { 
document.all("vinreq").style.width=vrqw 
opvrq=setTimeout("vraf()",10)
} else {
vrqos=1
vrqw=500
document.all("vinreq").style.width=vrqw 
vinformrel()
clearTimeout(opvrq)
}
} else {
document.all("vinreq").innerHTML='';
vrqw=vrqw-tdl
if(vrqw>0) { 
document.all("vinreq").style.width=vrqw 
opvrq=setTimeout("vraf()",10)
} else {
clearTimeout(opvrq)
vrqos=0
vrqw=0
document.all("vinreq").style.width=vrqw 
document.all("vinreq").style.display="none"
}
}
}

function checkunaform() {
err=0
err2=1
erstr=""
if(document.all("fio_ifd").value==0) { err++; erstr=erstr+"Не указано ФИО!<BR>"; }
if(document.all("email_ifd").value!=0) { err2=0; }
if(document.all("icq_ifd").value!=0) { err2=0; }
if(document.all("tel_ifd").value!=0) { err2=0; }
if(err2!=0) { err++; erstr=erstr+"Не заполнено ни одно поле контактов!<BR>"; }
if(document.all("vin_ifd").value==0) { err++; erstr=erstr+"Не указан VIN-номер!<BR>"; }
if(document.all("mark_ifd").value==0) { err++; erstr=erstr+"Не указана марка!<BR>"; }
if(document.all("comment_ifd").value==0) { err++; erstr=erstr+"Нет описания детали!<BR>"; }
if(err==0) {
document.all("errtd").innerHTML=erstr
fio_js=document.all("fio_ifd").value
email_js=document.all("email_ifd").value
icq_js=document.all("icq_ifd").value
tel_js=document.all("tel_ifd").value
vin_js=document.all("vin_ifd").value
mark_js=document.all("mark_ifd").value
md_js=document.all("md_ifd").value
wfrml_js=document.all("wfrml_ifd").value
taxl_js=document.all("taxl_ifd").value
tcar_js=document.all("tcar_ifd").value
tcp_js=document.all("tcp_ifd").value
comment_js=document.all("comment_ifd").value
request.open("POST", "send4.php", true);
request.onreadystatechange = vinformreload; 
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
rfact=0
document.all("vinreq").innerHTML="<TABLE width=\"470px\" width=\"470px\" cellpadding=\"2\" cellspacing=\"2\"><TR><TD class=\"vqloadinfo\" align=\"center\">Подождите. Идёт  загрузка...&nbsp; <IMG SRC=\"graphics/progressbar.gif\"></TD></TR></TABLE>";
request.send("fio="+fio_js+"&email="+email_js+"&icq="+icq_js+"&tel="+tel_js+"&vin="+vin_js+"&mark="+mark_js+"&md="+md_js+"&wfrml="+wfrml_js+"&taxl="+taxl_js+"&tcar="+tcar_js+"&tcp="+tcp_js+"&comment="+comment_js);
return true
} else {
document.all("errtd").innerHTML=erstr
return false
}
}

function checkform() {
err=0
erstr=""
if(document.all("vin_ifd").value==0) { err++; erstr=erstr+"Не указан VIN-номер!<BR>"; }
if(document.all("mark_ifd").value==0) { err++; erstr=erstr+"Не указана марка!<BR>"; }
if(document.all("comment_ifd").value==0) { err++; erstr=erstr+"Нет описания детали!<BR>"; }
if(err==0) {
document.all("errtd").innerHTML=erstr
vin_js=document.all("vin_ifd").value
mark_js=document.all("mark_ifd").value
md_js=document.all("md_ifd").value
wfrml_js=document.all("wfrml_ifd").value
taxl_js=document.all("taxl_ifd").value
tcar_js=document.all("tcar_ifd").value
tcp_js=document.all("tcp_ifd").value
comment_js=document.all("comment_ifd").value
request.open("POST", "vinformreq.php", true);
request.onreadystatechange = vinformreload; 
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
rfact=0
document.all("vinreq").innerHTML="<TABLE width=\"470px\" width=\"470px\" cellpadding=\"2\" cellspacing=\"2\"><TR><TD class=\"vqloadinfo\" align=\"center\">Подождите. Идёт  загрузка...&nbsp; <IMG SRC=\"graphics/progressbar.gif\"></TD></TR></TABLE>";
request.send("id="+thisuser_id+"&vin="+vin_js+"&mark="+mark_js+"&md="+md_js+"&wfrml="+wfrml_js+"&taxl="+taxl_js+"&tcar="+tcar_js+"&tcp="+tcp_js+"&comment="+comment_js+"&numshowpage=-1");
return true
} else {
document.all("errtd").innerHTML=erstr
return false
}
}

function vinformrel() {
rfact=0
request.open("POST", "vinformreq.php", true);
request.onreadystatechange = vinformreload; 
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
document.all("vinreq").innerHTML="<TABLE width=\"470px\" width=\"470px\" cellpadding=\"2\" cellspacing=\"2\"><TR><TD class=\"vqloadinfo\" align=\"center\">Подождите. Идёт  загрузка...&nbsp; <IMG SRC=\"graphics/progressbar.gif\"></TD></TR></TABLE>";
request.send("id="+thisuser_id+"&numshowpage="+nsp);
setTimeout("chload();",10000)
}

function chload() { if(rfact==0) vinformrel() }


function vinformreload() {
if (request.readyState == 4) {
if (request.status == 200) {
rspns = request.responseText.split("^")
if(rspns[0]!="_"&&rfact==0&&rspns[1]!=5) {
document.all("vinreq").innerHTML=rspns[0];
if(rspns[0].indexOf("успешно")!=-1&&thisuser_id!=-1) {
request.open("POST", "sendvinreqicq.php", true);
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
request.send("id="+thisuser_id);
}
rfact=1
cnl=rspns[2];
}
if(rspns[1]>2&&rspns[1]<6) { 
chlint=setTimeout("checknewans()",5000); }
}
}
}

function vinformreload2() {
if (request.readyState == 4) {
if (request.status == 200) {
rspns = request.responseText.split("^")
if(rspns[1]==5&&rspns[0].length>10) {
document.all("listtab_td").innerHTML=rspns[0] 
cnl=rspns[2]
}
if(rspns[1]>2&&rspns[1]<6) { chlint=setTimeout("checknewans()",5000); }
}
}
}

function viewanswer(idr) {
request.open("POST", "vinformreq.php", true);
request.onreadystatechange = vinformreload3; 
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
request.send("id="+thisuser_id+"&idrequest="+idr+"&type=4");
}

function vinformreload3() {
if (request.readyState == 4) {
if (request.status == 200) {
if(request.responseText.length>10) document.all("listtab_td").innerHTML=request.responseText;
clearTimeout(chlint)
}
}
}

function gotopage(n) {
clearTimeout(chlint)
if(n!=-2) { nsp=n; } else { n=nsp }  
request.open("POST", "vinformreq.php", true);
request.onreadystatechange = vinformreload2; 
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
document.all("listtab_td").innerHTML="<TABLE width=\"470px\" width=\"470px\" cellpadding=\"2\" cellspacing=\"2\"><TR><TD class=\"vqloadinfo\" align=\"center\">Подождите. Идёт  загрузка...&nbsp; <IMG SRC=\"graphics/progressbar.gif\"></TD></TR></TABLE>";
request.send("id="+thisuser_id+"&numshowpage="+n+"&nowcountansw=-1&type=2");
chlint=setTimeout("checknewans()",5000);
}

function upselbt(w) { w.src="graphics/mselect.jpg"; }
function downselbt(w) { w.src="graphics/mselect_p.jpg"; }
function upcansbt(w) { w.src="graphics/mcansel.jpg"; }
function downcansbt(w) { w.src="graphics/mcansel_p.jpg"; }

function current_time()
{
	return new Date().getTime();
}

function setprtype() {
catselr=''
if(document.all("valchbx").checked) { r=1; } else { r=0; }
document.all("valchbx").blur();
request.open("POST", "reloadmag.php", true);
request.onreadystatechange = mtrel; 
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
document.all("maintabdiv").innerHTML=whait1;
document.all("nxp").style.display="none";
mr=1;
tresp=mktime();
setCookie("rub",r);
js_v_pricetype = r
request.send("type_price="+r);
chto = setTimeout("sheckajaxrequest()",js_delay);
}

function setfindparam() {
catselr=''
if(document.all("allbasechbx").checked) { r=1; } else { r=0; }
if(document.all("accrfind").checked) { ar=1; } else { ar=0; }
document.all("allbasechbx").blur();
request.open("POST", "reloadmag.php", true);
request.onreadystatechange = mtrel; 
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
document.all("maintabdiv").innerHTML=whait1;
document.all("nxp").style.display="none";
mr=1;
tresp=mktime();
setCookie("fab",r);
setCookie("acfnd",ar);
js_v_findparam = r;
if(r==1) {
closemarkdiv();
document.all("marktdname").style.font="7pt Verdana";
document.all("marktdname").style.color="#000000";
document.all("marktdname").innerHTML="Выберите марку...";
document.all("marktdbutt").innerHTML='';
closegroupdiv();
document.all("grouptdname").style.font="7pt Verdana";
document.all("grouptdname").style.color="#000000";
document.all("grouptdname").innerHTML="Выберите группу...";
document.all("grouptdbutt").innerHTML='';
setCookie("m","");
setCookie("g","");
request.send("findparam="+r+"&m=&g=&acf="+ar);
} else {
request.send("findparam="+r+"&acf="+ar);
}
chto = setTimeout("sheckajaxrequest()",js_delay);
}

function swonlyapr() {
catselr=''
if(document.all("shonlyapr").checked) { r=1; } else { r=0; }
document.all("shonlyapr").blur();
request.open("POST", "reloadmag.php", true);
request.onreadystatechange = mtrel; 
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
document.all("maintabdiv").innerHTML=whait1;
document.all("nxp").style.display="none";
mr=1;
tresp=mktime();
setCookie("onlyapr",r);
request.send("swonlyaprice="+r);
chto = setTimeout("sheckajaxrequest()",js_delay);
}

function swonlyiss() {
catselr=''
if(document.all("shonlyist").checked) { r=1; } else { r=0; }
document.all("shonlyist").blur();
request.open("POST", "reloadmag.php", true);
request.onreadystatechange = mtrel; 
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
document.all("maintabdiv").innerHTML=whait1;
document.all("nxp").style.display="none";
mr=1;
tresp=mktime();
setCookie("onlyisset",r);
request.send("swonlyisset="+r);
chto = setTimeout("sheckajaxrequest()",js_delay);
}

function chnumrow(v) {
catselr=''
document.all("selnumrows").blur();
request.open("POST", "reloadmag.php", true);
request.onreadystatechange = mtrel; 
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
document.all("maintabdiv").innerHTML=whait1;
document.all("nxp").style.display="none";
mr=1;
tresp=mktime();
setCookie("chnr",v);
request.send("swnr="+v);
chto = setTimeout("sheckajaxrequest()",js_delay);
}

function changemark(m) {
catselr=''
request.open("POST", "reloadmag.php", true);
request.onreadystatechange = mtrel; 
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
mr=1;
tresp=mktime();
setCookie("m",m);
if(js_v_findparam==1) { 
setCookie("findpart",""); 
document.all("findpart").value="";
}
request.send("m="+m);
document.all("maintabdiv").innerHTML=whait1;
document.all("nxp").style.display="none";
closemarkdiv();
if(m!='') {
document.all("marktdname").innerHTML=m;
document.all("marktdname").style.font="bold 7pt verdana";
document.all("marktdname").style.color="#330000";
document.all("marktdbutt").innerHTML='<IMG SRC="graphics/mcansel.jpg" style="cursor:pointer" onMouseDown="downcansbt(this)" onMouseOut="upcansbt(this)" onMouseUp="upcansbt(this),clearsm()">';
}
chto = setTimeout("sheckajaxrequest()",js_delay);
}

function changegroup(g,gcn) {
catselr=''
request.open("POST", "reloadmag.php", true);
request.onreadystatechange = mtrel; 
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
mr=1;
tresp=mktime();
setCookie("g",g);
if(js_v_findparam==1) { 
setCookie("findpart",""); 
document.all("findpart").value="";
}
request.send("g="+g);
document.all("maintabdiv").innerHTML=whait1;
document.all("nxp").style.display="none";
if(g!='') {
document.all("grouptdname").innerHTML=gcn;
document.all("grouptdname").style.font="bold 7pt verdana";
document.all("grouptdname").style.color="#330000";
document.all("grouptdbutt").innerHTML='<IMG SRC="graphics/mcansel.jpg" style="cursor:pointer" onMouseDown="downcansbt(this)" onMouseOut="upcansbt(this)" onMouseUp="upcansbt(this),clearsg()">'; 
} 
closegroupdiv();
chto = setTimeout("sheckajaxrequest()",js_delay);
}


function ent_subm(w,e) {
e = e || window.event
var k = e.keyCode;
if(k==13) { 
err=0;
if(w.value>0&&w.value<1000&&w.value.indexOf('.')==-1) err=1;
if(err==0) { gofind(w.value); }
if(err==1) alert("Введено слишком малое количество знаков!");
} else { showfindhis(w.value); }
}

function find() { 
var findstringvalue=document.all("findpart").value;
var err=0;
if(findstringvalue>0&&findstringvalue<1000&&findstringvalue.indexOf('.')==-1) err=1;
if(err==0) { gofind(findstringvalue); }
if(err==1) alert("Введено слишком малое количество знаков!");
}

function gofind(w) {
catselr=''
document.all("maintabdiv").innerHTML=whait1;
document.all("nxp").style.display="none";
mr=1;
tresp=mktime();
setCookie("findpart",w);
if(js_v_findparam==1) {
closemarkdiv();
document.all("marktdname").innerHTML="Выберите марку...";
document.all("marktdbutt").innerHTML='';
closegroupdiv();
document.all("grouptdname").innerHTML="Выберите группу...";
document.all("grouptdbutt").innerHTML='';
setCookie("m","");
setCookie("g","");
} else {
closemarkdiv();
closegroupdiv();
}
document.all("findhistoryspan").style.display="none";

request.open("POST", "reloadmag.php", true);
request.onreadystatechange = mtrel; 
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

if(js_v_findparam==1) {
request.send("strtofind="+w+"&g=&m=");
} else {
request.send("strtofind="+w);
}
chto = setTimeout("sheckajaxrequest()",js_delay);
}

function fhisclick(w) {
document.all('findinput').value=w 
gofind(w);
}

function gt_page(n,p)
{
	scrolltop=document.body.scrollTop;
	catselr=''
	request.open("POST", "reloadmag.php", true);
	request.onreadystatechange = mtrel; 
	request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	document.all("maintabdiv").innerHTML=whait1;
	document.all("nxp").style.display="none";
	mr = 1;
	tresp = mktime();
	setCookie("numshpg",n);
	request.send("numshowpage="+n+"&nmn="+p);
	chto = setTimeout("sheckajaxrequest()",js_delay);
}

function cwsort(st) {
catselr=''
request.open("POST", "reloadmag.php", true);
request.onreadystatechange = mtrel; 
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
document.all("maintabdiv").innerHTML=whait1;
document.all("nxp").style.display="none";
mr=1;
tresp=mktime();
setCookie("ord",st);
request.send("sortby="+st);
chto = setTimeout("sheckajaxrequest()",js_delay);
}

function clearsm() {
document.all("marktdname").innerHTML="Выберите марку...";
document.all("marktdname").style.font="7pt verdana";
document.all("marktdname").style.color="#000000";
document.all("marktdbutt").innerHTML="";
changemark('');
}

function clearsg() {
document.all("grouptdname").innerHTML="Выберите группу...";
document.all("grouptdname").style.font="7pt verdana";
document.all("grouptdname").style.color="#000000";
document.all("grouptdbutt").innerHTML="";
changegroup('','');
}

function sheckajaxrequest() {
clearTimeout(chto);
if(mr==1) window.location.reload(true);
}

function mtrel(n) {
	if (request.readyState == 4) {
		if (request.status==200&&request.responseText.length>10) {
			resp = request.responseText.split('|^|');
			if(mr==1) {
				document.all("maintabdiv").innerHTML=resp[0];
				if(resp[0].indexOf('allpagediv')!=-1) scrollapdto(resp[3]);
				sendtimeresponse();
				document.all("nxp").style.display="block";
				if(resp[1]>0) { aprcolcor(resp[1]); }
				if(resp[2]!=0) { document.all("baskinfodiv").innerHTML=resp[2]; } 
				mr=0;
				clearTimeout(chto);
				document.body.scrollTop=100;
			}
		}
	}
}

function sendtimeresponse()
{
	tresp=mktime()-tresp;
	request.open("POST", "savetimeresp.php", true);
	request.onreadystatechange = emptyfunction; 
	request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	request.send("timeresp="+tresp+"&id="+thisuser_id);
	setCookie("timeresponse",tresp);
}

function emptyfunction() {}

function aprcolcor(r) {
if(document.all("aprth")) { document.all("aprth").style.display="none";
for(i=1; i<=r; i++) {
document.all("aprtd_"+i).style.display="none";
}
}
} 


function checknewans() {
request.open("POST", "vinformreq.php", true);
request.onreadystatechange = vinformreload2; 
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
request.send("id="+thisuser_id+"&numshowpage=-1&nowcountansw="+cnl+"&type=2");
}

function checknewans2(u) {
request.open("POST", "vinformreq.php", true);
request.onreadystatechange = vinbuttrel; 
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
vqrel1=0;
request.send("id="+u+"&type=3");
}

function vinbuttrel() {
if (request.readyState == 4) {
if (request.status==200&&vqrel1==0) {
if(request.responseText=="есть") { issetnewans=1; vqrel1=1; } 
if(request.responseText=="нет") { issetnewans=0; vqrel1=1; }
} 
}
}

function blinkvqbutt() {
if(issetnewans==1) { 
if(document.all("defaultvinreq").style.display=="block") {
document.all("defaultvinreq").style.display="none"
document.all("newansvinreq").style.display="block"
} else {
document.all("defaultvinreq").style.display="block"
document.all("newansvinreq").style.display="none"
}
} else {
document.all("defaultvinreq").style.display="block"
document.all("newansvinreq").style.display="none"
}
chintnavq1=setTimeout("blinkvqbutt()",1000);
}

function setnsp(v,c) { if(c==13) { if(v>0) gotopage(v) }}

$(document).ready(function(){
$("div.menu_content:not(:first)").hide();
$("div.menu_content_title > table").click(function(){
$(this).parent().next().slideToggle("slow");
if($(this).find("td#minus").text()=="[ - ]"){
$(this).find("td#minus").text("[+]");
}else{
$(this).find("td#minus").text("[ - ]");
}
return false;
});
});

// Функции для обработки формы

      function SendForm1() 
      { 
        document.getElementById("f1").innerHTML = "Отправляю";
        var errors = "";
          if (form1.name.value.replace(/\s/g,'') == '') {
            var errors = errors+"Вы не ввели наименование, номер<br>";
            var error = "yes";
          }
          if (form1.prim.value.replace(/\s/g,'') == '') {
            var errors = errors+"Вы не ввели примечание <br>";
            var error = "yes";
          }
          if (form1.email.value.replace(/\s/g,'') == '') {
            var errors = errors+"Вы не ввели e-mail  <br>";
            var error = "yes";
          }
        if (error == "yes") {
        document.getElementById("f1").innerHTML = '<br>'+errors;
         return false;
          }
        var msg = '<b>Наименование, номер:</b><br>'+form1.name.value+'<br><b>Примечание:</b><br>'+form1.prim.value+'<br><b>Эл. Почта:</b><br>'+form1.email.value;
        $.get("mail.php", { id: "1", msg: msg},
          function(data){
            document.getElementById("f1").innerHTML = data;
          document.form1.reset();
          });
        return true;
          
      }
      
      function SendForm2() 
      {
        document.getElementById("f2").innerHTML = "Отправляю";

        var errors = "";
          if (form2.email.value.replace(/\s/g,'') == '') {
            var errors = errors+"Вы не ввели e-mail  <br>";
            var error = "yes";
          }
        if (error == "yes") {
        document.getElementById("f2").innerHTML = '<br>'+errors;
         return false;
          }
        var msg = form2.email.value;
        $.get("mailputindb.php", { email: msg},
          function(data){
          document.getElementById("f2").innerHTML = data;
          document.form2.reset();
          });
        return true;
          
      }
      
      function SendForm3() 
      {
        document.getElementById("f3").innerHTML = "Отправляю";

        var errors = "";
          if (form2.email.value.replace(/\s/g,'') == '') {
            var errors = errors+"Вы не ввели e-mail  <br>";
            var error = "yes";
          }
        if (error == "yes") {
        document.getElementById("f2").innerHTML = '<br>'+errors;
         return false;
          }        
        
        var msg = '<b>Вопрос:</b><br>'+form3.quest.value+'<br><b>Недороботки:</b><br>'+form3.bug.value+'<br><b>Пожелания:</b><br>'+form3.poz.value+'<br><b>Эл. Почта:</b><br>'+form3.email.value;
        $.get("mail.php", {id: "3", msg: msg},
          function(data){
          document.getElementById("f3").innerHTML = data;
          document.form3.reset();
          });
        return true;
          
      }
      
        function SendOpros(n) 
      {
        document.getElementById("f4").innerHTML = "Отправляю";
        //var msg = formopros.answer.value;
        for (i=0; i<n; i++){
          if (document.formopros.answer[i].checked) {
            var ans = document.formopros.answer[i].value;
          }
        }
        
        if (ans == 0) {
          document.getElementById("f4").innerHTML = "Вы не выбрали ответ";
        } else {
          $.get("inquiry.php", {ans: ans},
            function(data){
            document.getElementById("oprops").innerHTML = data;
            });
        }
          
      }
      
        function SendCatalogs() {
		
				document.getElementById("f5").innerHTML = "Отправляю";
		
        var errors = "";
		var error = 0;
		
		if (sctlg.mail.value == '') {
            errors = errors+"Вы не ввели e-mail  <br>";
            error = 1;
          }
         if (sctlg.post.value == '') {
            errors = errors+"Вы не ввели почтовый адрес  <br>";
            error = 1;
          }
         if (sctlg.org.value  == '') {
            errors = errors+"Вы не ввели название организации  <br>";
            error = 1;
          }
         if (sctlg.name.value == '') {
            errors = errors+"Вы не ввели контактные данные  <br>";
            error = 1;
          }
        if (error == 1) { document.getElementById("f5").innerHTML = '<br>'+errors;
         return false;
          } 
		return true;
      }
      

function imaklient(i) {
if(i==1) { document.getElementById('corpcontdiv').style.display="block"; }
if(i==0) { document.getElementById('corpcontdiv').style.display="none"; }
}
	  
	  
function sendreg() {
var errstr='';
if(document.getElementById('companytypesel').value==0) errstr+='Вы не указали тип организации! \r';
if(document.getElementById('ri1').value=='') errstr+='Вы не указали название организации! \r';
if(document.getElementById('ri2').value=='') errstr+='Вы не указали ФИО! \r';
if(document.getElementById('ri3').value=='') errstr+='Вы не указали телефон! \r';
if(document.getElementById('ri5').value.indexOf('@')==-1) { if(document.getElementById('ec_r_1').checked==false) errstr+='Вы не указали e-mail! \r'; else errstr+='Вы не указали e-mail!'; }
if(document.getElementById('ec_r_1').checked==false) {
if(document.getElementById('ri6').value=='') errstr+='Вы не указали юридический адрес! \r';
if(document.getElementById('ri7').value=='') errstr+='Вы не указали телефон/факс! \r';
if(document.getElementById('ri8').value=='') errstr+='Вы не указали E-mail! \r';
if(document.getElementById('ri9').value=='') errstr+='Вы не указали расчетный счет! \r';
if(document.getElementById('ri10').value=='') errstr+='Вы не указали кореспондентский счет! \r';
if(document.getElementById('ri11').value=='') errstr+='Вы не указали БИК! \r';
if(document.getElementById('ri12').value=='') errstr+='Вы не указали ИНН адрес! \r';
if(document.getElementById('ri13').value=='') errstr+='Вы не указали КПП!';
}
if(errstr=='') {
document.getElementById('regmassta').value+=document.getElementById('companytypesel').value+'||#';
document.getElementById('regmassta').value+=document.getElementById('ri1').value+'||#';
document.getElementById('regmassta').value+=document.getElementById('ri2').value+'||#';
document.getElementById('regmassta').value+=document.getElementById('ri3').value+'||#';
document.getElementById('regmassta').value+=document.getElementById('ri4').value+'||#';
document.getElementById('regmassta').value+=document.getElementById('ri5').value+'||#';
document.getElementById('regmassta').value+=document.getElementById('ri6').value+'||#';
document.getElementById('regmassta').value+=document.getElementById('ri7').value+'||#';
document.getElementById('regmassta').value+=document.getElementById('ri8').value+'||#';
document.getElementById('regmassta').value+=document.getElementById('ri9').value+'||#';
document.getElementById('regmassta').value+=document.getElementById('ri10').value+'||#';
document.getElementById('regmassta').value+=document.getElementById('ri11').value+'||#';
document.getElementById('regmassta').value+=document.getElementById('ri12').value+'||#';
document.getElementById('regmassta').value+=document.getElementById('ri13').value+'||#';

if(document.getElementById('ec_r_1').checked) document.getElementById('regmassta').value+='1||#'; else document.getElementById('regmassta').value+='0||#';

document.getElementById('regmassta').value+=coordmas;
document.getElementById('regform').submit();
} else alert(errstr);
}

function SendRecovery(object){
      
  var errors=new Array();

  if(object.email.value.replace(/\s/g,'')==''){
    errors[errors.length]="Вы не ввели e-mail";
  }

  if(errors.length){
    alert(errors.join('\n'));
    return false;
  }

  return true;

}

function basket(pid) {

  var count=document.getElementById('product_'+pid).value;

  if(isNaN(count)){
    alert('Введите коректное количество заказываемых деталей.');
  }else{
    if(count>0){
	  if(confirm('Добавить в корзину '+count+' деталей?')){
        window.location='products.php?add='+pid+'&num='+count
		return true;
		
		}
		
    }else{
      alert('Число заказываемых деталей не может быть отрицательным или нулевым.');
    }
  }

  return false;

}

function basket2(pid,m,g){

  var count=document.getElementById('product_'+pid).value;

  if(isNaN(count)){
    alert('Введите коректное количество заказываемых деталей.');
  }else{
    if(count>0){
      if(confirm('Изменить число заказа на '+count+' деталей?')){
        window.location='baskedit.php?addp='+pid+'&nump='+count;
        return true;
		
		}
		
    }else{
      alert('Число заказываемых деталей не может быть отрицательным или нулевым.');
    }
  }

  return false;

}

function editnepp(i) { 

var count=document.getElementById(i).value;
if(isNaN(count)){
alert('Введите коректное количество заказываемых деталей.');
} else {
if(count>0) {
if(confirm('Изменить число заказа на '+count+' деталей?')){
window.location='baskedit.php?addnpp='+i+'&numnpp='+count+'&dbst='+document.body.scrollTop;
return true;
}
} else {
alert('Число заказываемых деталей не может быть отрицательным или нулевым.');
}
}
return false;
}

function backord(pid,m,g){

  var count=document.getElementById('productbo_'+pid).value;

  if(isNaN(count)){
    alert('Введите коректное количество заказываемых деталей.');
  }else{
    if(count>0){
      if(confirm('Изменить число заказа на '+count+' деталей?')){
        window.location='baskedit.php?chbo='+pid+'&numbo='+count;
        return true;
		
		}
		
    }else{
      alert('Число заказываемых деталей не может быть отрицательным или нулевым.');
    }
  }

  return false;

}

	  function delord(n) {
	  if (confirm("Вы действительно желаете удалить эту деталь из заказа?"))
	  { window.location='baskedit.php?piddel='+n }
	  }
	  
	  function delbord(n) {
	  if (confirm("Вы действительно желаете удалить эту деталь из заказа?"))
	  { window.location='baskedit.php?pidbdel='+n }
	  }
	  
	  function delnep()  {
	  if (confirm("Вы действительно желаете удалить этот раздел заказа?"))
	  { window.location='baskedit.php?delnep=1' }
	  }
	  function delneppart(i)  {
	  if (confirm("Вы действительно желаете удалить эту деталь из списка заказов?"))
	  { window.location='baskedit.php?delnepp='+i }
	  }
	  
function opquestform(w) {
if(w==1) {
chmagdialog=  open('chmagquest.php','displayWindow','width=500,height=200,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
}
if(w==2) {
chmagdialog=  open('chmagquest.php?show=set','displayWindow','width=600,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no');
}
}

function checknep() {
if(document.all.nonexpart.value!=""&&document.all.qntnep.value!="") {
return true;
} else {
if(document.all.nonexpart.value=="") { alert('Необходимо указать деталь!'); }
if(document.all.qntnep.value=="") { alert('Необходимо указать количество!'); }
return false;
}
}


function showhelpf(c,t) {
if(c==1) {
document.all.helpfield.style.visibility="visible";
document.all.helpfieldtext.innerHTML=t; 
}
}
function hidehelpf() {
document.all.helpfield.style.visibility="hidden";
document.all.helpfieldtext.innerHTML="";
}


function opclactfs(id) {
if(document.all(id).style.display=="none") { document.all(id).style.display="block" } else { document.all(id).style.display="none" }
}

function setCookie (name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

function valid_(idf) { if(document.all(idf).value=='') { return false; } else { return true; }}

function checkform2() {
var err=0
if(document.all.form2f1.value=="") err++
if(document.all.form2f2.value=="") err++
if(document.all.form2f3.value=="") err++
if(err!=0) { 
document.getElementById("f2").innerHTML = "Вы не заполнили все поля!";
return false; 
} else {
document.getElementById("f2").innerHTML = "";
document.getElementById("f22").innerHTML = "Идет отправка...";
} 
}

function checkform1() {

var err=0
if(document.all.form1f1.value=="") err++
if(document.all.form1f2.value=="") err++
if(document.all.form1f3.value=="") err++
if(err!=0) { 
document.getElementById("f1").innerHTML = "Вы не заполнили необходимые поля!";
return false; 
} else {
document.getElementById("f1").innerHTML = "";
document.getElementById("f11").innerHTML = "Идет отправка...";
} 

}

function checkform3() {
var err=0
if(document.all.form3f1.value=="") err++
if(document.all.form3f2.value=="") err++
if(document.all.form3f3.value=="") err++
if(err!=0) { 
document.getElementById("f3").innerHTML = "Вы не заполнили поля контактных данных!";
return false; 
} else {
document.getElementById("f3").innerHTML = "";
document.getElementById("f33").innerHTML = "Идет отправка...";
}
}


function showcorpriceform(id,mEvent,prc,name) {
var ex=0, ey=0;
ex=mEvent.clientX-310;
ey=mEvent.clientY-160;
document.all("cpfs").style.display="block";
document.all("cpfs").style.left=ex;
document.all("cpfs").style.top=ey;
document.all("tfs_l_i").value=ex;
document.all("tfs_t_i").value=ey;
document.all("prcspan").innerHTML=prc;
document.all("namespan").innerHTML=name;
document.all("pnp").value=id;
if(js_v_pricetype==0) {
document.all("vptp").innerHTML="&nbsp;&euro;";
document.all("vptp2").innerHTML="&nbsp;&euro;";
} else {
document.all("vptp").innerHTML="&nbsp;Руб.";
document.all("vptp2").innerHTML="&nbsp;Руб.";
}
document.all("rubl").value=js_v_pricetype;
}

function checkcorpr() {
newpr=document.all.user_new_price.value
linkpr=document.all.maglinkbetterprice.value

if(newpr==""&&linkpr=="") { alert("Введите цену и/или название поставщика!"); return false; }

if(newpr!=""&&linkpr=="") {
if(isNaN(newpr)) { alert("Вы ввели не корректное значение цены!"); return false; } else {
if(newpr<0||newpr==0) { alert("Значение цены не может быть отрецательным или нулевым!"); return false; }
}
}

if(newpr!=""&&linkpr!="") {
if(isNaN(newpr)) { alert("Вы ввели не корректное значение цены!"); return false; } else {
if(newpr<0||newpr==0) { alert("Значение цены не может быть отрецательным или нулевым!"); return false; }
}
}
}



function setimage(w,s) { w.src=s }

function openvq(w,mEvent) {
ex=mEvent.clientX+document.body.scrollLeft-200
ey=mEvent.clientY+document.body.scrollTop-50
if(ex>400) ex=400
if(ex<50) ex=50
document.all("vqfs").style.left=ex
document.all("vqfs").style.top=ey
document.all("vis_ta_comm").innerHTML=document.all("hiddencomment_"+w).value
document.all("vis_ta_answ").innerHTML=document.all("hiddenanswer_"+w).value
document.all("id_open_vq").value=w
document.all("vqfs").style.display="block"
}

function closevq() {
document.all("vis_ta_comm").innerHTML=""
document.all("vis_ta_answ").innerHTML=""
document.all("vqfs").style.display="none"
}

function saveansw() {
u=document.all("id_open_vq").value
an=document.all("vis_ta_answ").value
request.open("POST", "vinformreq.php", true);
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
request.send("idvq="+u+"&updans="+an+"&type=5");
window.location="orderlist.php"
}

var coordmas='';
function mm(h,mEvent) {
var ex=0, ey=0;
ex=mEvent.clientX;
ey=mEvent.clientY;

if(document.title.indexOf('Регистрация')!=-1) coordmas+=' '+ex+','+ey; 

if(ex>(document.body.clientWidth-240)) 
{ document.all.helpfield.style.left=ex-240+(document.body.clientWidth-ex+document.body.scrollLeft+30); } 
else 
{ document.all.helpfield.style.left=ex+document.body.scrollLeft+30; }

if(ey>(document.body.clientHeight-80)) 
{ document.all.helpfield.style.top=ey-75+document.body.scrollTop; } 
else 
{ document.all.helpfield.style.top=ey+25+document.body.scrollTop; }

if(openmenu==1) {
if(ex>465||ey>600||ex<50||ey<100) { 
closegroupdiv(); 
closemarkdiv(); 
}
}
}

function getAbsolutePos(el) {
   var r = { x: el.offsetLeft, y: el.offsetTop };
   if (el.offsetParent)
   {
       var tmp = getAbsolutePos(el.offsetParent);
       r.x += tmp.x;
       r.y += tmp.y;
   }
   return r;
}

function coroffset() {
pos = getAbsolutePos(document.all("contmenutab"))
if(browser=="MSIE") { 
document.all("markseltab").style.top=pos.y+23
document.all("groupseltab").style.top=pos.y+46
} else {
document.all("markseltab").style.top=pos.y+22
document.all("groupseltab").style.top=pos.y+45
}
}
 

function openmarkdiv() {
if(openmenu==0) {
document.all("shopmarkmenu").style.height="200"
document.all("shopmarkmenu").style.overflow="auto"
document.all("groupseltab").style.display="none"
document.all("listbut_on1").style.display="none"
document.all("listbut_off1").style.display="block"
closegroupdiv();
openmenu=1
}
}
 
function closemarkdiv() {
openmenu=0
var h=16;
if(browser=="MSIE") { h=19; } else { h=18; }
document.all("shopmarkmenu").style.height=h
document.all("shopgroupmenu").style.height=h
document.all("shopmarkmenu").style.overflow="hidden"
document.all("shopmarkmenu").scrollTop=0
document.all("groupseltab").style.display="block"
document.all("listbut_on1").style.display="block"
document.all("listbut_off1").style.display="none"
coroffset();
}

function opengroupdiv() {
if(openmenu==0) {
openmenu=1
document.all("shopgroupmenu").style.height="200"
document.all("shopgroupmenu").style.overflow="auto"
document.all("listbut_on2").style.display="none"
document.all("listbut_off2").style.display="block"
}
}
 
function closegroupdiv() {
openmenu=0
var h=16;
if(browser=="MSIE") { h=19; } else { h=18; }
document.all("shopgroupmenu").scrollTop=0
document.all("listbut_on2").style.display="block"
document.all("listbut_off2").style.display="none"
document.all("shopgroupmenu").style.height=h
document.all("shopgroupmenu").style.overflow="hidden"
coroffset();
}

function opclmarkdiv() { if(openmenu==0) { openmarkdiv(); } else { closemarkdiv(); } }
function opclgroupdiv() { if(openmenu==0) { opengroupdiv(); } else { closegroupdiv(); } }

function setviewopt(s1,s2,s3,s4) {
if(s1==1) { s1='&setshowacts=1'; } else { s1=''; }
if(s2==1) { s2='&setshownews=1'; } else { s2=''; }
if(s3==1) { s3='&setshowbackcont=1'; } else { s3=''; }
if(s4==1) { s4='&setshowbaskinfo=1'; } else { s4=''; }
if(s1!=''||s2!=''||s3!=''||s4!='') { window.location="chset.php?goback=1"+s1+s2+s3+s4; } else { window.location="chset.php?goback=1"; }
}


function shaf(w,s,v,c) {
var tv=v.split(',');
var i=tv.length;
var cl=0;

var cewd1=document.all('mtthmark').offsetWidth
var cewd2=document.all('mtthname').offsetWidth
var cewd3=document.all('mtthab').offsetWidth
var cewd4=document.all('mtthprod').offsetWidth
var cewd5=document.all('mtthorignum').offsetWidth
var cewd6=document.all('mtthprice').offsetWidth
if(document.all('aprth')) { var cewd7=document.all('aprth').offsetWidth; }
var cewd8=document.all('mtthrest').offsetWidth
var cewd9=document.all('mtthaddbtns').offsetWidth


for(j=0; j<i; j++) {
if(document.all('PR_'+tv[j]).style.display=="block") { document.all('PR_'+tv[j]).style.display="none"; cl=1; } else { 
document.all('PR_'+tv[j]).style.display="block"; 

//document.all('artd_mark_'+tv[j]).style.width=cewd1
//document.all('artd_name_'+tv[j]).style.width=cewd2
//document.all('artd_ab_'+tv[j]).style.width=cewd3
//document.all('artd_prod_'+tv[j]).style.width=cewd4
//document.all('artd_ornum_'+tv[j]).style.width=cewd5
//document.all('artd_price_'+tv[j]).style.width=cewd6
//document.all('aprtd_'+tv[j]).style.width=cewd7
//document.all('artd_rest_'+tv[j]).style.width=cewd8
//document.all('artd_addcnt_'+tv[j]).style.width=cewd9
//document.all('artd_adtb_'+tv[j]).style.width='30px'

cl=0; 
}
document.all(s).style.backgroundColor='#f9cb4d'; 
}
if(cl==0) { 
w.innerHTML="&nbsp;&nbsp;Скрыть аналоги&nbsp;&nbsp;";
w.style.backgroundColor='#fdf1d1'; 
catselr+=';'+s+';'
} else { 
w.innerHTML="&nbsp;Показать аналоги&nbsp;"; 
w.style.backgroundColor='#ffffff';
catselr=catselr.replace(';'+s+';','')
document.all(s).style.backgroundColor=c; 
}
}


function gotoauth() {document.all('log_us').focus();}

function shaf2(w,s,pname,p,nb) {
document.all('antab_'+s).style.display="block";
document.all('maincattab').style.display="none";
document.all('gminfo').style.display="none";
document.all('analoginfo').style.display="block";
if(nb==1) {
document.all('topnavtab').style.display="none";
document.all('bottomnavtab').style.display="none";
}
if(p==-1) { document.all('analoginfo').innerHTML='Аналоги детали: '+pname+'&nbsp;&nbsp;&nbsp;<SPAN class="sabtsp2" onClick="shaf2cl('+s+')" nowrap>&nbsp;Назад&nbsp;</SPAN>'; } else { document.all('analoginfo').innerHTML='Аналоги детали: '+pname+'&nbsp;&nbsp;&nbsp;<SPAN class="sabtsp2" onClick="gt_page('+p+')" nowrap>&nbsp;Назад&nbsp;</SPAN>'; }
//document.all('mtthmark_'+s).style.width=document.all('mtthmark').offsetWidth
//document.all('mtthname_'+s).style.width=document.all('mtthname').offsetWidth
//document.all('mtthab_'+s).style.width=document.all('mtthab').offsetWidth
//document.all('mtthprod_'+s).style.width=document.all('mtthprod').offsetWidth
//document.all('mtthorignum_'+s).style.width=document.all('mtthorignum').offsetWidth
//document.all('mtthprice_'+s).style.width=document.all('mtthprice').offsetWidth
//document.all('aprth_'+s).style.width=document.all('aprth').offsetWidth
//document.all('mtthrest_'+s).style.width=document.all('mtthrest').offsetWidth
//document.all('mtthaddbtns_'+s).style.width=document.all('mtthaddbtns').offsetWidth
//document.all('mtthaddbtns2_'+s).style.width='30px'
}


function shaf2cl(s) {
document.all('antab_'+s).style.display="none";
document.all('maincattab').style.display="block";
document.all('topnavtab').style.display="block";
if(document.all('bottomnavtab')) document.all('bottomnavtab').style.display="block";
document.all('gminfo').style.display="block";
document.all('analoginfo').style.display="none";
document.all('analoginfo').innerHTML='';
}


function selCatRow(r) {
if(catselr.indexOf(';PR_'+r+';')!=-1) {
document.all('PR_'+r).style.backgroundColor='#f9cb4d'; 
} else {
document.all('PR_'+r).style.backgroundColor='#CCCCCC'; 
}
}

function unselCatRow(r,c) {
if(catselr.indexOf(';PR_'+r+';')!=-1) {
document.all('PR_'+r).style.backgroundColor='#f7d067'; 
} else {
document.all('PR_'+r).style.backgroundColor=c; 
}
}

function apd_smin() { document.all('allpagediv').scrollLeft=0; }
function apd_smax() { document.all('allpagediv').scrollLeft=99999999; }
function apd_sdec() { document.all('allpagediv').scrollLeft=document.all('allpagediv').scrollLeft-5; apdsdecto=setTimeout("apd_sdec()",25); }
function apd_sinc() { document.all('allpagediv').scrollLeft=document.all('allpagediv').scrollLeft+5; apdsincto=setTimeout("apd_sinc()",25); }
function stop_apd_sdec() { clearTimeout(apdsdecto); }
function stop_apd_sinc() { clearTimeout(apdsincto); }


function scrollapdto(p) {
var i=7;
var sc=0;
var d=0;
for(i=7; i<=p; i++) {
d=1
if(i>9) d=2;
if(i>99) d=3;
if(i>999) d=4;
if(i>9999) d=5;
if(i>99999) d=6;
if(i>999999) d=7;
sc=sc+d*7+3
}
//alert(sc)
document.all('allpagediv').scrollLeft=sc
}

function delsupmes(id) {
if(confirm("Удалить этот вопрос?")) {
window.location="support.php?del="+id
}
}

function fixEvent(e) {
// получить объект событие для IE
e = e || window.event
// добавить pageX/pageY для IE
if ( e.pageX == null && e.clientX != null ) {
var html = document.documentElement
var body = document.body
e.pageX = e.clientX + (html && html.scrollLeft || body && body.scrollLeft || 0) - (html.clientLeft || 0)
e.pageY = e.clientY + (html && html.scrollTop || body && body.scrollTop || 0) - (html.clientTop || 0)
}
// добавить which для IE
if (!e.which && e.button) {
e.which = e.button & 1 ? 1 : ( e.button & 2 ? 3 : ( e.button & 4 ? 2 : 0 ) )
}
return e
}

function absPosition(obj) { 
      var x = y = 0; 
      while(obj) { 
            x += obj.offsetLeft; 
            y += obj.offsetTop; 
            obj = obj.offsetParent; 
      } 
      return {x:x, y:y}; 
} 

var bltimeout=0;
function blinksup() {
var sl = document.getElementById("supportlink");
if(sl.style.color=="#ffb400"||sl.style.color=="rgb(255, 180, 0)") { sl.style.color="#000000"; } else { sl.style.color="#ffb400"; }
bltimeout = setTimeout("blinksup()",300);
}

function loadcmpl() {
if(save_res==1) { window.location="products.php?saveres=ok&scrresw="+ww+"&scrresh="+wh; }  else {
document.body.scrollTop=bodyscrolltop;
if(document.getElementById("supportlink")) blinksup();
}
}

window.onload = loadcmpl;

