var menuLineHeight = 22;
var menuLineHeightV = 17;

var d = document;

function GEByID(id) { 
   return d.all ? d.all[id] : d.getElementById(id);
}

function relPosXX(e) { 
   return e.offsetLeft + (e.offsetParent != null && e.tagName != 'BODY' ? relPosXX(e.offsetParent) : 0);
}

function relPosYY(e) { 
   return e.offsetTop + (e.offsetParent != null && e.tagName != 'BODY' ? relPosYY(e.offsetParent) : 0);
}

function displayMenu(n,x,y) {  
   //alert("x="+x+", y="+y); 
   m = GEByID("menu"+n);
   m.style.left = x;
   m.style.top = y + menuLineHeight - 2;
   m.style.visibility = 'visible';
   if ((n==1) && (r_menu!=n)) {document.pic1.src='http://peugeot.arkont.ru/img/menu_01_x.jpg';}
   if ((n==2) && (r_menu!=n)) {document.pic2.src='http://peugeot.arkont.ru/img/menu_02_x.jpg';}
   if ((n==3) && (r_menu!=n)) {document.pic3.src='http://peugeot.arkont.ru/img/menu_03_x.jpg';}
   if ((n==5) && (r_menu!=n)) {document.pic5.src='http://peugeot.arkont.ru/img/menu_05_x.jpg';}
   if ((n==10) && (r_menu!=2)) {document.pic2.src='http://peugeot.arkont.ru/img/menu_02_x.jpg';}
}

function displayMenuV(n,x,y) {
   
   m = GEByID("menu"+n);
   m.style.left = x;
   m.style.top = y + menuLineHeightV;
   m.style.visibility = 'visible';
}

function showMenu(n) {
   m = GEByID("menu"+n);
   m.style.visibility = 'visible';
   if (n==10)
   {
   	m = GEByID("menu2");
   	m.style.visibility = 'visible';   
   }
   if ((n==1) && (r_menu!=n)) {document.pic1.src='http://peugeot.arkont.ru/img/menu_01_x.jpg';}
   if ((n==2) && (r_menu!=n)) {document.pic2.src='http://peugeot.arkont.ru/img/menu_02_x.jpg';}
   if ((n==3) && (r_menu!=n)) {document.pic3.src='http://peugeot.arkont.ru/img/menu_03_x.jpg';}
   if ((n==5) && (r_menu!=n)) {document.pic5.src='http://peugeot.arkont.ru/img/menu_05_x.jpg';}
   if ((n==10) && (r_menu!=2)) {document.pic2.src='http://peugeot.arkont.ru/img/menu_02_x.jpg';}
}

function hideMenu(n) {   
   m = GEByID("menu"+n);
   m.style.visibility = 'hidden';
   if (n==10)
   {
   	m = GEByID("menu2");
   	m.style.visibility = 'hidden';   
   }
   if ((n==1) && (r_menu!=n)) {document.pic1.src='http://peugeot.arkont.ru/img/menu_01.jpg';}
   if ((n==2) && (r_menu!=n)) {document.pic2.src='http://peugeot.arkont.ru/img/menu_02.jpg';}
   if ((n==3) && (r_menu!=n)) {document.pic3.src='http://peugeot.arkont.ru/img/menu_03.jpg';}
   if ((n==5) && (r_menu!=n)) {document.pic5.src='http://peugeot.arkont.ru/img/menu_05.jpg';}
   if ((n==10) && (r_menu!=2)) {document.pic2.src='http://peugeot.arkont.ru/img/menu_02.jpg';}
}

function newSubMenu(id, xmenu) {
   d.write('<div class=test id=menu',id,' style="z-index: 99; top:0; position:absolute; visibility:hidden;" onMouseOver="showMenu(',id,');" onMouseOut="hideMenu(',id,');">');
   d.write('<table cellspacing=0 cellpadding=3 width="155">');
}

function endSubMenu() {
   d.write('<tr><td height="1" bgcolor="#EEEEEE"></td></tr>');
   d.write('</table></div>');
}

function newSubMenuItem(hrf, txt, idM, color_bg, color2_over, color3_border, nmenu, pxx, pyy) {
	if (nmenu != 0) { 
      d.write('<tr><td style="cursor: hand; border-top:1px solid ',color3_border,'; border-left:1px solid ',color3_border,'; border-right:1px solid ',color3_border,'" bordercolor="', color3_border, '" bgcolor=\'',color_bg,'\' onMouseOver="this.style.backgroundColor=\'',color2_over,'\'; displayMenu(',nmenu,', relPosXX(this) + ',pxx,', relPosYY(this) + ',pyy,')" onMouseOut="this.style.backgroundColor=\'',color_bg,'\'; hideMenu(',nmenu,');" onClick="location.href=\'',hrf,'\';" align="center" height="15"><a href="',hrf,'" class="text_11_white">',txt,'</a></td></tr>'); 
	  }
	  else
	  {
      d.write('<tr><td style="cursor: hand; border-top:1px solid ',color3_border,'; border-left:1px solid ',color3_border,'; border-right:1px solid ',color3_border,'" bordercolor="', color3_border, '" bgcolor=\'',color_bg,'\' onMouseOver="this.style.backgroundColor=\'',color2_over,'\'" onMouseOut="this.style.backgroundColor=\'',color_bg,'\'" onClick="location.href=\'',hrf,'\';" align="center" height="15"><a href="',hrf,'" class="text_11_white">',txt,'</a></td></tr>'); 
		  }
}

function showCar(pic){
var iPath="http://peugeot.arkont.ru/images/tradein/" + usedCars[pic] + ".jpg"
var nw=window.open("","","width=820,height=650,toolbar=no,status=no,menubar=no")
nw.document.writeln("<img src='http://peugeot.arkont.ru/" + iPath + "' width='800' alt='' /><br />");
nw.document.writeln("<div style='text-align:center;font-weight:bold'><a href='#' onclick='window.close()'>Закрыть окно</a>")
}

