// Preloading images for buy button
if (document.images) {
  btn_down = new Image(); btn_down.src = "/img/b-buying.gif"; 
  btn_up = new Image(); btn_up.src = "/img/b-buy.gif"; 
  btn_fb = new Image(); btn_fb.src = "/img/b-forbid.gif"; 
}

// Event handlers
function pressButton(btName) {
  if (document.images) eval('document.'+btName+'.src='+btName+'_down.src');
}

function releaseButton(btName) {
  if (document.images) eval('document.'+btName+'.src='+btName+'_up.src');
}

function forbidButton(btName) {
  if (document.images) eval('document.'+btName+'.src='+btName+'_fb.src');
}

var winw = "400"; // How wide should your window be (pixels)
var winh = "200"; // How tall should the window be (pixels)

var ie=(document.all);
var ns=(document.layers);
var ns6=(document.getElementById && !ie);
var calculate=ns? "" : "px"

function loadElement(){
if(!ns && !ie && !ns6) return;
if(ie) popup=eval('document.all.elementDiv.style');
else if(ns) popup=eval('document.layers["elementDiv"]');
else if(ns6) popup=eval('document.getElementById("elementDiv").style');
if (ie||ns6) popup.visibility="visible";
else popup.visibility ="show";
displayElement()
}

function displayElement(){
var agent=navigator.userAgent.toLowerCase();
if (ie){
	documentWidth = (centerElement().offsetWidth)/2+centerElement().scrollLeft-(winw/2);
	documentHeight = (centerElement().offsetHeight)/2+centerElement().scrollTop-(winh/2);
}
else if (ns){
	documentWidth=window.innerWidth/2+window.pageXOffset-(winw/2);
	documentHeight=window.innerHeight/2+window.pageYOffset-(winh/2);
}
else if (ns6){
	documentWidth=self.innerWidth/2+window.pageXOffset-(winw/2);
	documentHeight=self.innerHeight/2+window.pageYOffset-(winh/2);
}
popup.left = documentWidth+calculate;
popup.top = documentHeight+calculate;
}

function centerElement(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function closeElement(){
    popup.visibility="hidden";
}

function endBuying() {
if(!ns && !ie && !ns6) return;
if(ie) bbtn=eval('document.all.buying_btn');
else if(ns) bbtn=eval('document.layers["buying_btn"]');
else if(ns6) bbtn=eval('document.getElementById("buying_btn")');
bbtn.innerHTML = "<img name='btn' width='150' height='26' border='0' alt='' src='/img/b-forbid.gif'>";
closeElement();
}

