saleDownSum=2000;
currency=0;
currencyNames=new Array();
currencyNames[0]='у.е.';
currencyNames[1]='руб.';
currencyNames[2]='безнал.руб';
rates=new Array();

function OpenDevice(id,cost1,cost2,cost3,cost4,gar)
{
  var price1,price2;
  if (currency>0 && cost1!="")
  {
  	price1=Math.floor(rates[currency-1]*cost1*100+0.5)/100;
  	price2=Math.floor(rates[currency-1]*cost2*100+0.5)/100;
  	price3=Math.floor(rates[currency-1]*cost3*100+0.5)/100;
  	price4=Math.floor(rates[currency-1]*cost4*100+0.5)/100;
  }
  else
  {
    price1=cost1;
    price2=cost2;
    price3=cost3;
    price4=cost4;
  }
  //if (cost1!="") ShowBasket();
  var win=window.open('/cgi-bin/info.pl?id='+id+'&cost1='+cost1+'&cost2='+cost2+'&cost3='+cost3+'&cost4='+cost4+'&gar='+gar+'&price1='+price1+'&price2='+price2+'&price3='+price3+'&price4='+price4+'&currency='+currencyNames[currency],"","toolbar=0,location=0,directoties=0,status=0,menubar=0,scrollbars=1,resizable=1,width=500,height=500");
  win.focus();
}

function _ShowBasket()
{
	var h=screen.height-300;
	BasketWin=window.open('','basket123','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,left=200,width=700,height='+h);
	if (BasketWin.bottom!=null)
	{
		BasketItemCount=BasketWin.bottom.ItemCount;
		BasketItems=BasketWin.bottom.Items;
	}
	else
	{
		BasketItemCount=0;
		BasketItems=new Array();
	}
}

function _ShowRequest()
{
	var h=screen.height-300;
	RequestWin=window.open('','request123','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,left=200,width=450,height='+h);
	if (RequestWin.bottom!=null)
	{
		RequestItemCount=RequestWin.bottom.ItemCount;
		RequestItems=RequestWin.bottom.Items;
	}
	else
	{
		RequestItemCount=0;
		RequestItems=new Array();
	}
}

function ShowBasket()
{
	_ShowBasket();
	if (BasketWin.bottom==null) BasketWin.location="/basket.html"; else BasketWin.bottom.act=0;
	BasketWin.focus();
}

function ShowRequest()
{
	_ShowRequest();
	if (RequestWin.bottom==null) RequestWin.location="/ordbasket.html"; else RequestWin.bottom.act=0;
	RequestWin.focus();
}

function Buy(id,Name,cost1,cost2,cost3,cost4,gar,tech)
{
	_ShowBasket();	
	var NoAdd=0;
	for (i=0;i<BasketItemCount;i++)
	if (BasketItems[i][0]==id)
	{
		BasketItems[i][3]++;
		NoAdd=1;
		break;
	}
	if (!NoAdd)
	{
		BasketItems[BasketItemCount]=new Array();
		BasketItems[BasketItemCount][0]=id;
		BasketItems[BasketItemCount][1]=unescape(Name);
		BasketItems[BasketItemCount][2]=new Array(parseFloat(cost1),parseFloat(cost2),parseFloat(cost3),parseFloat(cost4));
		BasketItems[BasketItemCount][3]=1;
		BasketItems[BasketItemCount][4]=parseInt(tech);
		BasketItems[BasketItemCount][5]=gar;
		BasketItems[BasketItemCount][6]=-1;
		BasketItemCount++;
	}
	if (BasketWin.bottom==null) BasketWin.location="/basket.html"; else BasketWin.bottom.Update();
	BasketWin.focus();
}

function Request(id,Name)
{
	_ShowRequest();
	var NoAdd=0;
	for (i=0;i<RequestItemCount;i++)
	if (RequestItems[i][0]==id)
	{
		RequestItems[i][2]++;
		NoAdd=1;
		break;
	}
	if (!NoAdd)
	{
		RequestItems[RequestItemCount]=new Array();
		RequestItems[RequestItemCount][0]=id;
		RequestItems[RequestItemCount][1]=unescape(Name);
		RequestItems[RequestItemCount][2]=1;
		RequestItemCount++;
	}
	if (RequestWin.bottom==null) RequestWin.location="/ordbasket.html"; else RequestWin.bottom.Update();
	RequestWin.focus();
}


function BEGIN(page,date)
{
if (!date) date='';
html=
'<body OnResize="move_popups()">'+
'<a href="http://top100.rambler.ru/top100/">'+
'<img src="http://counter.rambler.ru/top100.cnt?346066" alt="Rambler&#39;s Top100" width=1 height=1 border=0></a><br>'+
'<TABLE bgcolor=#ffffff border=0 cellspacing=0 cellpadding=0 width=100% height=100%>'+
'  <TR style="height: 1;">'+
'    <TD background="TResizex.gif" valign=top style="width: 80%; padding-left: 40px;">'+
'      <TABLE border=0 cellspacing=0 cellpadding=0 width=100% height=180>'+
'       <TR>'+
'          <TD valign=top align=left width=100%>'+
'          <IMG src="Logo.gif" border=0 vspace=4></TD>'+
'       </TR>'+
'       <TR>'+
'          <TD nowrap align=left valign=bottom>'+
'              <font class=t><b>';
switch(page)
 {
 case -4:
 html+= 'Голосование';
 break;
 case -3:
 html+= 'Адреса сервисных центров';
 break;
 case -2:
 html+= 'Черный список';
 break;
 case -1:
 html+= 'Информационная ответственность';
 break;
 case 0:
 html+= 'Главная';
 break;
 case 1:
 html+= 'Прайс'+date;
 break;
 case 2:
 html+= 'Каталог';
 break;
 case 3:
 html+= 'Гарантийное обслуживнаие';
 break;
 case 4:
 html+= 'Оплата';
 break;
 case 5:
 html+= 'Новые поступления';
 break;
 case 6:
 html+= 'Гостевая';
 break;
 case 7:
 html+= 'Баланс';
 break;
 case 8:
 html+= 'О нас';
 break;
 }
html+=
'</b></font></TD>'+
'       </TR>'+
'      </TABLE>'+
'    </TD>'+
'    <TD background="TResizex.gif" align="right" style="width: 1px;">'+
'    <IMG src="TopLeftx.gif" border=0 usemap="#MenuLeft"></TD>'+
'    <TD width=1>'+
'    <IMG src="TopRight.gif" border=0 usemap="#MenuRight"></TD>'+
'  </TR>'+
'  <TR>'+
'    <TD colspan=2 align=center style="text-align: center; vertical-align: top; padding: 10px;">';
document.write(html);
}

function SubItem(text,ref)
{
	for (var i=0;i<25-MenuItemCount*6;i++) html+='&nbsp;';
	html+='<a onmouseover="MouseOnMenu=1" onMouseOver="MouseOnMenu=0" class=menu href="'+ref+'">'+text+'</a><br>';
	MenuItemCount++;
}

function END()
{
d=new Date();
year=d.getYear();
if (year<100) year+=2000;
else
if (year<1000) year+=1900;
html=
'    </TD>'+
'    <TD valign=top style="width: 1px; vertical-align: top;">'+
'      <TABLE border=0 cellspacing=0 cellpadding=0 width=100% height=100%>'+
'       <TR style="height: 1;">'+
'          <TD style="background-image: url(NResizeH.gif); background-repeat: no-repeat; background-position: bottom; vertical-align:top">'+
'          <IMG src="SubTopR.gif" border=0 usemap="#MenuSubTop">'+
'          </TD>'+
'       </TR>'+
'<tr><td background="NResize.gif" height=1%><div align=center><a href="film.html" target=_blank><b>Как сделать покупку в Интернет-магазине PriceWatch</b></a><br><font style="size:10px">Видеоролик 652 кб</font></td></tr>'+
'       <TR>'+
'          <TD valign=top background="NResize.gif" style="vertical-align: top; padding-left: 15; padding-right: 15;">'+
'          <iframe src="/news.html" width=100% height=240 frameborder=0 scrolling=no></iframe>'+
'          </TD>'+
'       </TR>'+
'       <TR style="height: 1;">'+
'          <TD background="NResize.gif" style="text-align: right; vertical-align: bottom; padding-left: 15; padding-right: 10;">'+
'          <small>© '+year+', pricewatch. <br>Все права защищены.<br>Предлагаемое оборудоваие сертифицировано.<br><a href="mailto:info@pricewatch.ru">info@pricewatch.ru</a><br><br><a href="/rights.html">Ограничение информационной ответственности.</a><br><br><div width="100%" style="text-align: center;"><a href="http://top100.rambler.ru/top100/">'+
'<img align=center src="http://top100-images.rambler.ru/top100/w2.gif" alt="Rambler&#39;s Top100" width=88 height=31 border=0></a></div><br></small>'+
'          </TD>'+
'       </TR>'+
'      </TABLE>'+
'    </TD>'+
'  </TR>'+
'</TABLE>';

html+=
'<map name="MenuLeft">'+
'<area alt="Главная" shape="poly" coords="111,38,217,34,216,59,112,65" href="/index.php"  OnMouseOver="show_popup(\'pup_0\', false)" OnMouseOut="hide_popup(\'pup_0\', true)">'+
'<area alt="Прайс" shape="poly"  coords="66,108,135,105,135,121,67,129" href="/price3.php">'+
'<area alt="Каталог" shape="poly"  coords="79,141,166,127,166,144,81,158" href="/price3.php?tech=1">'+
'</map>'+
'<map name="MenuRight">'+
'<area alt="Гарантийное обслуживание" shape="poly"  coords="46,22,170,22,168,51,44,52" href="guar.php" OnMouseOver="show_popup(\'pup_1\', false)" OnMouseOut="hide_popup(\'pup_1\', true)">'+
'<area alt="Оплата" shape="poly"  coords="136,97,218,127,202,159,122,122" href="/receipt.php">'+
'<area alt="Новые поступления" shape="poly"  coords="87,137,99,163,130,182,98,182" href="/index.php">'+
'</map>'+
'<map name="MenuSubTop">'+
'<area alt="Новые поступления" shape="poly"  coords="95,0,148,0,210,34,194,63" href="/index.php">'+
'<area alt="Гостевая" shape="poly"  coords="96,19,198,90,181,111,85,35" href="/cgi-bin/guest.pl">'+
'</map>';
document.write(html+doc_start());
doc_init();
}

function doc_start()
{
var res = '';
for(i=0; i<pup_links.length; i++)
	{
	var txt='';
	var pup_width=170;
	if (i==0) pup_width=300;
	for(j=0;j<pup_links[i].length;j++)
		{
		txt+="<a href='"+pup_links[i][j]+"'>"+pup_titles[i][j]+"</a><br>";
		}
	res+= "<div name='pup_"+i+"' id='pup_"+i+"' style='text-align: left; padding: 4 8; background-color: "+pup_bgcolor+"; border: "+pup_border+"; width: "+pup_width+"px; position: absolute; left: "+pup_XY[i][0]+"px; top: "+pup_XY[i][1]+"px; display: none;' OnMouseOver=\"show_popup('pup_"+i+"', false)\" OnMouseOut=\"hide_popup('pup_"+i+"', true)\">"+txt+"</div>";
	}
return res;
}

function doc_init()
{
  move_popups();
}

function getobjnumber(objid)
{
res = -1;
pos=objid.indexOf('_');
if(pos>-1)
  {
  res = parseInt(objid.slice(pos+1,10), 10);
  }
return res;
}

function change_popup(objid, prm)
{
if(prm[0]=='move')
  {
  document.all[objid].style.left = prm[1];
  document.all[objid].style.top = prm[2];
  }
}

function move_popups()
{
  v_width = screen.width-(screen.width-document.body.clientWidth);
//status = screen.width+' : '+document.body.clientWidth;
  prm = ['move', v_width-380, pup_XY[0][1]];
  change_popup('pup_0', prm);
  prm = ['move', v_width-220, pup_XY[1][1]];
  change_popup('pup_1', prm);
}

function show_popup(objid, delay)
{
if(delay)
  {
  setTimeout("show_popup('"+objid+"', false)", 500);
  }
else
  {
  pup_mouse_over[getobjnumber(objid)]=true;
  document.all[objid].style.display="block";
  }
}

function hide_popup(objid, delay)
{
if(delay)
  {
  pup_mouse_over[getobjnumber(objid)]=false;
  setTimeout("hide_popup('"+objid+"', false)", 200);
  }
  else
  {
  if(!pup_mouse_over[getobjnumber(objid)])
    {
    document.all[objid].style.display="none";
    }
  }
}

var pup_bgcolor='#FFFFFF';
var pup_border='1px solid #99CCFF';

pup_links = 
		[
		['/index.php', '/register.php', '/services.html', '/rights.html', '/blacklist.html', '/balans.html', '/about.html'],
		['guar.php', '/cgi-bin/getbrak.pl' , '/cgi-bin/brak.pl']
		];
pup_titles = 
		[
		['Стартовая страница', 'Регистрация постоянных клиентов', 'Сервисные центры', 'Ограничение&nbsp;информационной&nbsp;ответственности', 'Черный список', 'Баланс', 'О нас'],
		['Проверка срока гарантии', 'Заявка о неисправности', 'Проверка готовности']
		];
pup_XY = 
		[
		[-300, 60],
		[-450, 50]
		];
pup_mouse_over = [false, false];

