//      IE
function setCart() {
  this.w = 120; //  
  this.h = 71; //  
  this.l = 103; //    
  this.t = 5; //    
//  this.p = "lt"; //      b_left  b_top (lt || lc || lb || ct || cc || cb || rt || rc || rb)
  return this; 
} // End function setCart

cid = '';

//  
function Position() { 
     if( bw.ie ) { 
       obj.pixelLeft = cart.l + document.body.scrollLeft; 
       obj.pixelTop  = cart.t + document.body.scrollTop; 
     } // End if 
} // End function Position


//  
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(); document.cookie = " check_esm=on; path=/";

//    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"><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"]; 

} // End if

function check_vis() {
   alert('check_vis');
  if( !cid ) {
   alert('hid');
     obj.visibility = "hidden"; 
     obj_ind.src = "about:blank"; 
  }
  return 1;
}

//      
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; 
} // End function bwSize


//    cookie  cid'
function loadCart() { 
  rnd = parseInt( ( Math.random() * 1000000 + 1 ) ); 
  cid = check_esm=""; 
  esm_cookie = " " + document.cookie + ";";
  esm_cookie = esm_cookie.substring( esm_cookie.indexOf( " check_esm=" ) );

  // cookie
  find1 = esm_cookie.indexOf( " check_esm=" ); 
  if( find1 != -1 ) { 
    find1 += 11; 
    find2  = esm_cookie.indexOf( ";" ); 
    check_esm = unescape( esm_cookie.substring( find1, find2 ) ); 
  }

  // cid
  find1 = esm_cookie.indexOf( " esm_cid=" ); 
  if( find1 != -1 ) { 
    find1 += 9; 
    find2  = esm_cookie.lastIndexOf( ";" ); 
    cid = unescape( esm_cookie.substring( find1, find2 ) ); 
  }
  if( check_esm == "on" && cid != "" && bw.ie ) { 
    goods = "/cgi-bin/esm/add_to_cart.pl?" + rnd + "&cid=" + cid; 
    Position(); 
    obj.visibility = "visible"; 
    obj_ind.src = goods; 
  } else if( check_esm != "" && cid == "" && bw.ie ) { 
    goods = "about:blank"; 
    Position(); 
//    obj.visibility = "hidden"; 
//    obj_ind.src = "about:blank"; 
  } 
  
} // End function loadCart

//   
function toCart( eIntID, eName, eTm, eCode, eCost, eQuantity, eWeight, eImgPath, eImgWidth, eImgHeight ) {
eTm=(eTm)?eTm:""; eWeight=(eWeight)?eWeight:""; bw=new browse_check();
rnd=parseInt((Math.random()*1000000+1)); cid=check_esm=""; esm_cookie=" "+document.cookie+";";
esm_cookie=esm_cookie.substring(esm_cookie.indexOf(" check_esm="));
// cookie
find1=esm_cookie.indexOf(" check_esm="); if (find1!=-1) { find1+=11; find2=esm_cookie.indexOf(";"); check_esm=unescape(esm_cookie.substring(find1,find2)); }
// cid
find1=esm_cookie.indexOf(" esm_cid="); if (find1!=-1) { find1+=9; find2=esm_cookie.lastIndexOf(";"); cid=unescape(esm_cookie.substring(find1,find2)); }

if ((check_esm=="on"&&bw.ie)&&eName&&eCost&&eQuantity) {
goods="/cgi-bin/esm/add_to_cart.pl?"+rnd+"&cid="+cid+"&name="+eName+"&tm="+eTm+"&code="+eCode+"&cost="+eCost+"&quantity="+eQuantity+"&weight="+eWeight+"&img_path="+eImgPath+"&img_width="+eImgWidth+"&img_height="+eImgHeight+"&int_id="+eIntID;
Position(); obj.visibility="visible"; obj_ind.src=goods; }
else if (check_esm!="on"||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+"&img_path="+eImgPath+"&img_width="+eImgWidth+"&img_height="+eImgHeight;
  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(); }

if (bw.ie) { onresize=Position; }

window.setInterval( "Position()", 30 );


