function GetXmlHttpObject() {
  var xmlHttp=null;
  try {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e) {
    // Internet Explorer
    try {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e) {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  return xmlHttp;
}

function getBookData(id,popup_type) {
//	alert("Count is "+count);
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null) {
        alert ("Browser does not support HTTP Request")
        return
    }
    //alert(xmlHttp);
    var url="/product/detail/short/"+id;
    xmlHttp.onreadystatechange=function() { updateBookData(id,popup_type) };
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
}

function updateBookData(id,popup_type) {
	if (xmlHttp.readyState==4 || xmlHttp.readyState=='complete') {
		// Only if ok
		if (xmlHttp.status == 200) {
//			alert('id is '+id);
//			alert("Status is 200!");
			document.getElementById(popup_type+id).innerHTML = xmlHttp.responseText;
			//var mySpan = document.getElementById(popup_type+id);
//			alert(mySpan);
			 //mySpan.innerHTML = xmlHttp.responseText;
		
		} else {
			alert("There was a problem retrieving the data:\n" + xmlHttp.statusText);
		}
	}
}


var ie, nn4, dom;

if(document.all){
	ie = true;
} else {
	ie = false;
}

if(document.layers){
	nn4 = true;
} else {
	nn4 = false;
}

if(document.getElementById){
	dom = true;
} else {
	dom = false;
}

function browser(id) {
	//if (ie) return eval("document.all." + id);
	if (ie) return document.getElementById(id);
	if (nn4) return eval("document.layers." + id);
	if (dom) return document.getElementById(id);
}

function hideThis(id) {
	var layer=browser(id);
	layer.style.visibility='hidden';
	//document.getElementById(id).style.visibility='hidden';
}

function showThis(id) {
	//alert('popup function accessed');
	var layer = browser(id);
	//var layer = browser(" + id + ");
	layer.style.visibility='visible';
	//document.getElementById(id).style.visibility='visible';
}


function loadShadows() {
	var size = document.images.length;
	for (var i = 0; i < size; i++) {
		var name = document.images[i].name;
		if (name.indexOf("cover_") == 0) {
			var id = name.substring(6);
			shadow = browser("shadow_" + id);
			shadow.style.height = document.images[i].height + "px";
			shadow.style.width = document.images[i].width + "px";
			
		}
	}
}

function openfwPop(url) {
	var fwPop = window.open(url, "fwPop", "width=300,height=460,top=10,left=10,toolbar=no,menubar=no,location=no,status=no,resizable=no,directories=no,scrollbars=yes");
	fwPop.focus();
}
