var xmlHttp;var reqTimeout;var cell=null;var tableRef=null;var rowNo=0;var image=null;var tableCols=0;var isIE=(navigator.appName.indexOf("Microsoft")!=-1);function preloadImgs(){var f=document;if(f.images){if(!f.MM_p){f.MM_p=new Array()}var e,c=f.MM_p.length,b=preloadImgs.arguments;for(e=0;e<b.length;e++){if(b[e].indexOf("#")!=0){f.MM_p[c]=new Image;f.MM_p[c++].src=b[e]}}}}function swapImgRestore(){var d,b,c=document.MM_sr;for(d=0;c&&d<c.length&&(b=c[d])&&b.oSrc;d++){b.src=b.oSrc}}function swapImage(){var e,d=0,b,c=swapImage.arguments;document.MM_sr=new Array;for(e=0;e<(c.length-2);e+=3){if((b=MM_findObj(c[e]))!=null){document.MM_sr[d++]=b;if(!b.oSrc){b.oSrc=b.src}b.src=c[e+2]}}}function MM_findObj(f,e){var c,b,a;if(!e){e=document}if((c=f.indexOf("?"))>0&&parent.frames.length){e=parent.frames[f.substring(c+1)].document;f=f.substring(0,c)}if(!(a=e[f])&&e.all){a=e.all[f]}for(b=0;!a&&b<e.forms.length;b++){a=e.forms[b][f]}for(b=0;!a&&e.layers&&b<e.layers.length;b++){a=MM_findObj(f,e.layers[b].document)}if(!a&&e.getElementById){a=e.getElementById(f)}return a}function loadXMLDoc(a,b){xmlHttp=null;try{xmlHttp=new XMLHttpRequest()}catch(c){try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP")}catch(c){try{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")}catch(c){}}}if(xmlHttp){reqTimeout=setTimeout("xmlHttp.abort()",15000);xmlHttp.onreadystatechange=function(){try{if(xmlHttp.readyState==4){clearTimeout(reqTimeout);if(xmlHttp.status==200){if(b){b()}}}}catch(d){}};xmlHttp.open("GET",a+"&ms="+new Date().getTime(),true);xmlHttp.send(null)}}function open_window(c,a,b){var d="width="+a+",height="+b+",menubar=no,location=no,resizable=yes,scrollbars=yes";newWin=window.open(c,"CartWin",d);newWin.focus()}function order(b,c){b=document.getElementById("q"+b);if(b){b=b.value}else{b=1}var a="?cmd=cart&add=add&win=1&p4="+b+c;open_window(a,630,200)}function changeVal(d,c){var b=document.getElementById(d);var a=parseInt(b.value)+c;if(a>=0){b.value=a}}function openOrder(a,b){if(a==1){top.opener.window.location.href=b;window.close()}else{window.location.href=b}}function adjust_cart_window(c,b){var a=screen.availHeight-50;if(navigator.appName.indexOf("Microsoft")!=-1){s=200}else{s=180}if(b){s+=130}var d=s+c*30;window.resizeTo(630,Math.min(a,d))}function expand_row(e){var b=tableRef.insertRow(rowNo+1);b.style.backgroundColor="#E1E2DB";if(e.length<7){var f=b.insertCell(0);f.colSpan=tableCols;var d=document.createTextNode("Аналогов не найдено");f.appendChild(d)}else{var a=0;for(i=0;i<tableCols;i++){var f=b.insertCell(i);f.align=cell.parentNode.cells[i].align;var c=tableRef.tBodies[0].rows[0].cells[i].abbr;switch(c){case"b":data_el=e[0];break;case"a":data_el=e[1];break;case"q":data_el=e[2];break;case"p":data_el=e[3];break;case"p2":data_el=e[4];break;case"c":data_el=e[5];break;case"l":data_el=e[6];break;default:data_el=" "}d=document.createTextNode(data_el);f.appendChild(d)}}}function RequestChange(){image.src="images/spacer.gif";response=xmlHttp.responseXML;if(response&&response.documentElement){xmlRoot=response.documentElement;rows=xmlRoot.getElementsByTagName("row");if(rows&&rows.length>0){for(var b=0;b<rows.length;b++){var d=new Array(6);cels=rows[b].getElementsByTagName("cell");for(var a=0;a<cels.length;a++){if(!cels[a].firstChild){var c=""}else{var c=cels[a].firstChild.data}d[a]=c}expand_row(d)}return}}expand_row(Array())}function get_analogs(e,d,b,a){cell=document.getElementById("cell"+e);link=document.getElementById("link"+e);link.onclick="return false";image=document.getElementById("img_header");image.src="images/loading.gif";tableRef=document.getElementById("table");rowNo=cell.parentNode.rowIndex;tableCols=tableRef.tBodies[0].rows[0].cells.length;loadXMLDoc("?cmd=search&brand="+d+"&item="+b+"&user_login="+a,RequestChange)}function ReloadLoginForm(){var a=xmlHttp.responseText;if(a.indexOf("detected")>-1){alert("Слишком много попыток авторизации!");top.window.location.reload();return}var b=document.getElementById("login_block");if(b){b.innerHTML=a}loadXMLDoc("?cmd=hello&ajax=1",ReloadHello)}function ReloadHello(){var a=document.getElementById("hello");if(a){a.innerHTML=xmlHttp.responseText}}function login_form(a,b){if(a==""||b==""){return false}document.getElementById("login").innerHTML='<div style="text-align: center; font-weight: Bold;">Входим, пожалуйста подождите...<br /><img src="images/loading1.gif" border="0" alt="" /></div>';loadXMLDoc("?cmd=login&l="+a+"&p="+b+"&ajax=1",ReloadLoginForm);return false}function logout(){loadXMLDoc("?cmd=logout&ajax=1",ReloadLoginForm)}function resort(b,a){var b=document.getElementById(b);var a=document.getElementById(a);if(b&&a){a.value=a.value^1;b.submit()}}function AddRow(c,b){var e=document.getElementById(c);var a=document.getElementById(b);if(e&&a){var g=parseInt(e.rows.value)+1;if(g>50){alert("Пожалуй, достаточно!");return}e.rows.value=g;var d=a.tBodies[0].rows[0].cloneNode(true);a.tBodies[0].appendChild(d);d.cells[0].innerHTML=g+".";d.cells[1].innerHTML='<input type="text" class="input" name="pd'+g+'" value="" maxlength="255" />';d.cells[2].innerHTML='<input type="text" name="pq'+g+'" value="1" maxlength="4" size="3" />'}}function DelRow(e,d,a){var g=document.getElementById(e);var b=document.getElementById(d);if(g&&b){var h=parseInt(g.rows.value)-1;var c=(a==null)?1:a;if(h>=c){g.rows.value=h;b.tBodies[0].deleteRow(h)}else{alert("Нечего больше удалять.")}}}function OSubmit(d,a){var e=document.getElementById(d);if(e){a.disabled=true;var c=true;if(c&&e.c_vin.value.length!=17){alert("Укажите правильный VIN!");c=false}if(c&&e.c_model.value==""){alert("Укажите модель/серию авто!");c=false}if(c&&e.c_year.value.length!=4){alert("Укажите год выпуска авто (4 цифры)!");c=false}if(c){e.submit()}else{a.disabled=false}}}function VIN_view(b){var a=document.getElementById("f_form");a.o.value=b;a.submit()}function SendsToggle(c){var a=document.getElementById("img"+c);var b=document.getElementById("b"+c);if(b.style.display=="block"){a.src="images/b_open.gif";a.title="Кликните для просмотра полной информации";b.style.display="none"}else{a.src="images/b_close.gif";a.title="Кликните для сворачивания информации";b.style.display="block";a=document.getElementById("im"+c);if(a){a.src="images/spacer.gif";a.title="";loadXMLDoc("?cmd=sends&ajax=1&r="+c,null)}}}function ChbToggle(b,d){var b=document.forms[b];if(b){for(k=0;k<b.elements.length;k++){var a=b.elements[k];if(a.type=="checkbox"){a.checked=d.checked}}}}function toggle(c){var a=document.getElementById(c);if(a){a.style.display=(!a.clientHeight?"block":"none")}}function fixPNG(a){if(!isIE){return}if(a.tagName=="IMG"&&(/\.png$/i).test(a.src)){var b=a.src;a.src="images/blank.gif";a.runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+b+"', sizingMethod='image')"}};