	var popup = 0;
	
	function initHttpRequest() {
		HttpRequest = false; 	
	  if(window.XMLHttpRequest && !(window.ActiveXObject)) {
	  	try {
				HttpRequest = new XMLHttpRequest();
	   	} catch(e) {
				HttpRequest = false;
	  	}  
	 	} else if(window.ActiveXObject) {
	  	try {
	    	HttpRequest = new ActiveXObject('Msxml2.XMLHTTP');
	  	} catch(e) {
	    	try {
	      	HttpRequest = new ActiveXObject('Microsoft.XMLHTTP');
	    	} catch(e) {
	      	HttpRequest = false;
	   		}
			}
	  }
	  if(HttpRequest) return HttpRequest;	  	  
	}	

	function HttpPost(url,param,id,scrollto) {
		var obj = initHttpRequest();						
		if(obj) {
			obj.onreadystatechange = function() {
				switch(obj.readyState) {
					case 0:
						showStatus(id,'http://powerpack.2bmall.com/amazonprice/loader.gif','Uninitialized...',scrollto);
					break;
					case 1:
						showStatus(id,'http://powerpack.2bmall.com/amazonprice/loader.gif','Loading Data...',scrollto);
					break;
					case 2:
						showStatus(id,'http://powerpack.2bmall.com/amazonprice/loader.gif','Data loaded...',scrollto);
					break;
					case 3:
						showStatus(id,'http://powerpack.2bmall.com/amazonprice/loader.gif','Interactive...',scrollto);
					break;
					case 4:
						showStatus(id,'http://powerpack.2bmall.com/amazonprice/loader.gif','Complete...',scrollto);
					break;																								
				}											
				if(obj.readyState == 4) {
					if(obj.status == 200) {            
						document.getElementById(id).innerHTML = obj.responseText;
						if(scrollto) document.getElementById(id).scrollIntoView(true);
					} else if(obj.status == 404) {            
						document.getElementById(id).innerHTML = '<h1>404 Page not found!</h1>';
					}           
				}
			};       
			obj.open("POST", url, true);
			obj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			obj.setRequestHeader("Content-length", param.length);
			obj.setRequestHeader("Connection", "close");      
			obj.send(param);	  	
		}
	}	

	function showStatus(id,icon,msg,scrollto) {
		if(document.getElementById(id)) {
			if(scrollto) document.getElementById(id).scrollIntoView(true);
			document.getElementById(id).innerHTML = '<img src="'+icon+'" border="0" alt="" style="margin-right:3px;vertical-align:middle;"><small>'+msg+'</small>';
		}
	}

	function ShowReview(id,asin) {  
		var url = 'http://powerpack.2bmall.com/amazonprice/CustomerReview.php';
		param = 'eid='+id+'&itemid='+asin;
		HttpPost(url,param,id,false);
	}
	
	function ShowPrices(id,asin) {  
		var url = 'http://powerpack.2bmall.com/amazonprice/Marketplace.php';
		param = 'eid='+id+'&itemid='+asin;	
		HttpPost(url,param,id,false);
	}

	function AmazonMarketPlace(id,asin,page) {  
		var url = 'http://powerpack.2bmall.com/amazonprice/Marketplace.php';
		param = 'eid='+id+'&itemid='+asin;
		if(page) param = param+'&page='+page;		
		HttpPost(url,param,id,true);
	}  	

	function CustomerReviews(id,asin,page) {  
		var url = 'http://powerpack.2bmall.com/amazonprice/CustomerReview.php';
		param = 'eid='+id+'&itemid='+asin;
		if(page) param = param+'&page='+page;		
		HttpPost(url,param,id,true);
	}

	function EditorialReview(id,asin) {  
		var url = 'http://powerpack.2bmall.com/amazonprice/EditorialReview.php';
		param = 'eid='+id+'&itemid='+asin;	
		HttpPost(url,param,id,true);
	}		
	
	function MarketPlace(id,asin) {
		popOpen(id);
		AmazonMarketPlace(id,asin);		
	}

	function Reviews(id,asin) {		
		popOpen(id);
		CustomerReviews(id,asin);
	}
	
	function OverBody() {
		var id = "obody";
		if(!document.getElementById("obody")) {
			var obj = document.createElement("div");
			obj.setAttribute("id",id);
			obj.setAttribute("style","position:absolute;margin:0px;padding:0px;z-index:65534;width:100%;height:100%;background-color:#000;opacity:0.8;filter:alpha(opacity=80);");
			document.body.insertBefore(obj,document.body.firstChild);						
		} else {
			removeElement(id);
		}
	}
	
	function popOpen(id) {
		if(!id) id = "pop";
		OverBody();
		if(!document.getElementById(id)) {
			popup = setTimeout("popClose('"+id+"')",10000);
			var obj = document.createElement("div");
			obj.setAttribute("id",id);			  
			obj.setAttribute("style","position:absolute;z-index:65535;overflow:auto;width:60%;height:100%;margin:auto 20%;padding:10px;background: #fff;border-left: 2px solid #e1e1e1;border-right: 2px solid #e1e1e1;");
			obj.setAttribute("onmouseover","clearTimeout(popup);");
			obj.setAttribute("onmouseout",'clearTimeout(popup);popup = setTimeout("popClose(\''+id+'\')",500);');
			document.body.insertBefore(obj,document.body.firstChild);			
			document.getElementById(id).focus();
			obj = null;
		} else {
			clearTimeout(popup);
			popup = setTimeout("popClose('"+id+"')",10000);
		}		
    document.body.style.overflow = "hidden";
    document.body.scrollTop = 0;		
	}

	function popClose(id) {
		if(id) {
			removeElement(id);
			document.body.style.overflow = "";
			document.body.scrollTop = 1;
		}
		OverBody();
	}   	
	
	function removeElement(id) {
		var obj = document.getElementById(id);
		if(obj && obj.parentNode && obj.parentNode.removeChild)
			obj.parentNode.removeChild(obj);
	}
	

