function ap_getObj(name) {
	if (document.getElementById) {
		return document.getElementById(name);
	} else if (document.all) {
		return document.all[name];
	} else if (document.layers) {
		return document.layers[name];
	}
}


strGarantMail = "warranty@rabit.ru";
strZakazMail = "zakaz@rabit.ru";
strSupportMail = "info@rabit.ru";


function hide_menu(obj_id) {
	if (obj_id=="") return;
	var obj;
	var m;
	obj=ap_getObj("submenu_"+obj_id);
	obj.style.display='none';
	m=ap_getObj("main_menu_"+obj_id);
	m.className="menu_unselect";
	m.style.color="#ffffff";
	m.style.backgroundColor="#ffffff";

if (m != "http://stahanov.ru/remont-apple.html"  && m != "http://www.stahanov.ru/remont-apple.html")
		m.style.backgroundImage="url(/images/template/menu_img_new.gif)";
else
	m.style.backgroundImage="url(/images/template/menu_img_new_apple.gif)";

}
 
function show_menu(obj_id) {
	if (obj_id=="") return;
	var obj;
	var m;
	obj=ap_getObj("submenu_"+obj_id);
	obj.style.display='block';
	m=ap_getObj("main_menu_"+obj_id);
	m.style.color="#e77817";
//	m.style.backgroundColor="#ff9700";
if (m != "http://stahanov.ru/remont-apple.html" && m != "http://www.stahanov.ru/remont-apple.html")
	m.style.backgroundImage="url(/images/template/menu_img_back_new.gif)";
else
	m.style.backgroundImage="url(/images/template/menu_img_back_new_apple.gif)";
}


function GetNumBlock(block_id) {
	var block_num;
	block_num=block_id.lastIndexOf("_");
	if (block_num==-1) return "";
	return block_id.substring(block_num+1);
}

function init() {
	var main_block="main_menu_table";	// ID контейнера меню
	var main_tag="td";					// какому тэгу задаем события
	var main_class="menu_main_td";		// класс тэга под события
	var on_tag="div";					// какой тэг на действие
	var on_tag_class="sub_menu_div";	// класс тэга на действие

	var s="";
	var co,q,q2,featured,featured2,block;

	featured = document.getElementById(main_block).getElementsByTagName(main_tag);
	for(var q = 0; q < featured.length; q++) {
		if (featured[q].className==main_class || featured[q].className == "menu_main_td_apple") {
			// открываем подменю
			featured[q].onmouseover = function() {
				featured2 = this.getElementsByTagName(on_tag);
				for(var q2 = 0; q2 < featured2.length; q2++) {
					if (featured2[q2].className==on_tag_class) {
						block=GetNumBlock(featured2[q2].id);
						if (block != "") {show_menu(block);break;}
					}
				}
			}
			// закрываем подменю
			featured[q].onmouseout = function() {
				featured2 = this.getElementsByTagName(on_tag);
				for(var q2 = 0; q2 < featured2.length; q2++) {
					if (featured2[q2].className==on_tag_class) {
						block=GetNumBlock(featured2[q2].id);
						if (block != "") {hide_menu(block);break;}
					}
				}
			}
		}
	}
}

//window.onload = init;


function submit_parameters_form(input_value,output_name,form_name) {
	// присвоить значение input_value элементу output_name и отправить форму form_name
	output_el=ap_getObj(output_name);
	output_el.value=input_value;
	form_id=ap_getObj(form_name);
	form_id.submit();
}

function gou(El) {
  var vIndex = El.form.nav1.selectedIndex;
  var vURL = El.form.nav1.options[vIndex].value;
  window.location = vURL;
}

function AddIn(prodid,bar_code) {
	amount=document.getElementById("g"+prodid+"_"+bar_code).value;
	clien=document.getElementById("client").value;
	if(amount=="") amount=1;
	var url="pr_addinv.pl?cust="+clien+"&code="+prodid+"&quan="+amount;
	document.location=url;
}

function ch_pr() {
	var kol=document.getElementById("kol").value;
	window.open("pr_ch.pl?"+kol,"chpr","width=1,height=1");
}

function swaptable (id){
	d=document;
	if(d.getElementById('a'+id).style.display=='none')
		{d.getElementById('a'+id).style.display="block";}
	else
		{d.getElementById('a'+id).style.display="none";}
}

function infocust (cust) {
	window.open("./infocust.pl?"+cust,"cust","width=350,height=150,scrollbars=yes,resizable=yes");
}

function infodoc (no) {
	window.open("./infodoc.pl?"+no,"no","width=350,height=120");
}

function openPicture(name) {
	PicWin= open("", "pic","scrollbars=0,resizable=0,width=640,height=480,status=no,toolbar=no,menubar=no");
	PicWin.document.open();
	PicWin.document.write("<html><head><title>Фото");
	PicWin.document.write("</title></head><body leftmargin=0 topmargin=0><img src='");
	PicWin.document.write(name); PicWin.document.write("' border='0'></body></html>");
	PicWin.focus();
	PicWin.document.close();
}

function openPicture3(name) {
	PicWin= open("", "pic","scrollbars=0,resizable=0,width=484,height=445,status=no,toolbar=no,menubar=no");
	PicWin.document.open();
	PicWin.document.write("<html><head><title>Схема проезда в сервисный центр");
	PicWin.document.write("</title></head><body leftmargin=0 topmargin=0><img src='");
	PicWin.document.write(name); PicWin.document.write("' border='0'></body></html>");
	PicWin.focus();
	PicWin.document.close();
}

function openPicture2(name) {
	PicWin= open("", "pic","scrollbars=1,width=800,height=600,status=no,toolbar=no,menubar=no");
	PicWin.document.open();
	PicWin.document.write("<html><head><title>Фото");
	PicWin.document.write("</title></head><body leftmargin=0 topmargin=0><img src='");
	PicWin.document.write(name); PicWin.document.write("' border='0'></body></html>");
	PicWin.focus();
	PicWin.document.close();
}


function openMap(name) {
	PicWin1= open("", "pic","scrollbars=0,resizable=0,width=640,height=509,status=no,toolbar=no,menubar=no");
	PicWin1.document.open();
	PicWin1.document.write("<html><head><title>Схема проезда");
	PicWin1.document.write("</title></head><body leftmargin=0 topmargin=0><img src='");
	PicWin1.document.write(name);
	PicWin1.document.write("' border='0'></body></html>");
	PicWin1.focus();
	PicWin1.document.close();
}

