// Начальные установки индикатора корзины для IE
function setCart() {
	this.w=120; // ширина индикатора
	this.h=55; // высота индикатора
	this.l=200; // положение относительно левого края
	this.t=140; // положение относительно верхнего края
	this.p=""; // положение на странице с учетом b_left и b_top (lt || lc || lb || ct || cc || cb || rt || rc || rb)
return this; }
// Тип браузера 
function browse_check() {
	this.ver=navigator.appVersion;
	this.agent=navigator.userAgent;
	this.dom=document.getElementById?1:0;
	this.opera5=this.agent.indexOf("Opera 5")>-1;
	this.ie5=(this.ver.indexOf("MSIE 5")>-1&&this.dom&&!this.opera5)?1:0;
	this.ie6=(this.ver.indexOf("MSIE 6")>-1&&this.dom&&!this.opera5)?1:0;
	this.ie4=(document.all&&!this.dom&&!this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6;
	this.mac=this.agent.indexOf("Mac")>-1;
	this.ns6=(this.dom&&parseInt(this.ver)>=5)?1:0;
	this.ns4=(document.layers&&!this.dom)?1:0;
	this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5);
	return this; }
bw=new browse_check();

// Конструктор индикатора для IE
if (bw.ie) { html_ind=''; cart=new setCart();
	html_ind+='<style type="text/css">\n#eCartDiv { left:-'+cart.w+'px; top:-'+cart.h+'px; width:'+cart.w+'px; height:'+cart.h+'px; position:absolute; visibility:hidden; }\n</style>\n';
	html_ind+='<div id="eCartDiv"><div style="width: 120px; cursor:hand;" id="dragbox" onmousedown="initializedrag();"><img src="/esm/i/esm_title.gif" width="120" height="16" alt="eSales Manager - Корзина покупок" border="0"></div><iframe id="eCart" width="'+cart.w+'" height="'+cart.h+'" marginwidth="0" marginheight="0" scrolling="no" frameborder="0"></iframe></div>';
	document.write(html_ind); obj=document.all["eCartDiv"].style; obj_ind=document.all["eCartDiv"].document.all["eCart"]; }
// Разрешение экрана и размер окна браузера
function bwSize() {
if (bw.ie) { this.w=document.body.offsetWidth-20; this.h=document.body.offsetHeight-5; }
if (self.screen) { this.sw=screen.width; this.sh=screen.height; } else if (self.java) { jkit=java.awt.Toolkit.getDefaultToolkit(); scrsize=jkit.getScreenSize(); this.sw=scrsize.width; this.sh=scrsize.height; } return this; }
// Позиционирование индикатора
function Position(goods) { page=new bwSize();
pos_l=(cart.p=="lt"||cart.p=="lc"||cart.p=="lb"||cart.p=="")?cart.l:(cart.p=="ct"||cart.p=="cc"||cart.p=="cb")?(page.w-cart.w-cart.l)/2:(cart.p=="rt"||cart.p=="rc"||cart.p=="rb")?page.w-cart.w+cart.l:0;
pos_t=(cart.p=="lt"||cart.p=="ct"||cart.p=="rt"||cart.p=="")?cart.t:(cart.p=="lc"||cart.p=="cc"||cart.p=="rc")?(page.h-cart.h-cart.t)/2:(cart.p=="lb"||cart.p=="cb"||cart.p=="rb")?page.h-cart.h+cart.t:0;
if (bw.ie) { obj.pixelLeft=pos_l; obj.pixelTop=pos_t; obj.visibility="visible"; obj_ind.src=goods; } }
// Определение cookie для IE
function check_cookie() { document.cookie=" check_esm=on; path=/"; check_esm=""; esm_cookie=" "+document.cookie+";"; esm_find=esm_cookie.indexOf(" check_esm="); 
if (esm_find!=-1) { esm_find=esm_find+11; esm_find1=esm_cookie.indexOf(";"); check_esm=unescape(esm_cookie.substring(esm_find,esm_find1)); }
this.ind=(check_esm=="on")?true:false; return this; }
// Определение cid'а
function esm_cid() { check_cid=""; check_esm=" "+document.cookie+";"; esm_find=check_esm.indexOf(" esm_cid=");
if (esm_find!=-1) { esm_find=esm_find+9; esm_find1=check_esm.lastIndexOf(";"); check_cid=unescape(check_esm.substring(esm_find,esm_find1)); }
this.cid=(check_cid!="")?check_cid:""; return this; }
// Первая загрузка
function loadCart() { cid=new esm_cid(); esm=new check_cookie(); rnd=parseInt((Math.random()*1000000+1));
if (esm.ind&&cid.cid!=""&&bw.ie) { goods="/cgi-bin/esm/add_to_cart.pl?"+rnd+"&cid="+cid.cid; Position(goods); } }
// Добавление в корзину
function toCart(eName,eTm,eCode,eCost,eQuantity,eWeight) { esm=new check_cookie(); eTm=(eTm)?eTm:""; eWeight=(eWeight)?eWeight:""; rnd=parseInt((Math.random()*1000000+1));
if (esm.ind&&eName&&eCost&&eQuantity&&bw.ie) { cid=new esm_cid();
goods="/cgi-bin/esm/add_to_cart.pl?"+rnd+"&cid="+cid.cid+"&name="+eName+"&tm="+eTm;
goods+="&code="+eCode+"&cost="+eCost+"&quantity="+eQuantity+"&weight="+eWeight; Position(goods); }
else if (!esm.ind||bw.ns4||bw.ns6) { page=new bwSize();
goods="/cgi-bin/esm/cart_stat.pl?"+rnd+"&good_name="+eName+"&tm="+eTm+"&code="+eCode+"&cost="+eCost+"&quantity="+eQuantity+"&weight="+eWeight;
wleft=(page.sw-(page.sw-100))/2; wtop=(page.sh-(page.sh-50))/2;
property="left="+wleft+",top="+wtop+",width="+(page.sw-100)+",height="+(page.sh-100)+",toolbar=0,menubar=0,scrollbars=1,resizable=0"
esm_win=window.open(goods,"esm_order",property); } }

if (bw.ie) { loadCart(); }
