/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: JTricks.com :: http://www.jtricks.com/ */

function move_box(an, box) {
  var cleft = 0;
  var ctop = 0;
  var obj = document.getElementById(an);
 
  while (obj.offsetParent) {
    cleft += obj.offsetLeft;
    ctop += obj.offsetTop;
    obj = obj.offsetParent;	 
  }
  //box.style.left = cleft + 'px';
  ctop += an.offsetHeight + 8;
  if (document.body.currentStyle &&
    document.body.currentStyle['marginTop']) {
    ctop += parseInt(
      document.body.currentStyle['marginTop']);
  }
  box.style.top = ctop + 'px';
}

function newPopup(an, pItem, href) {
	
	
	var height='400';	
 	var boxdiv = document.getElementById(pItem);  
	refreshCheck = 0;

  boxdiv.style.display = 'block';
  boxdiv.style.position = 'absolute';
  //boxdiv.style.height = height + 'px';
  boxdiv.style.overflow = 'visible';
  boxdiv.style.backgroundColor = '#fff';


  //document.body.appendChild(boxdiv);
  //move_box(an, boxdiv);
  
  sendRequest_popup(href)


  return false;
}

function handleDivTag_calendarm(divtag){
   var divtag;
   return divtag;
}

function createRequestObject_popup() {
	var req;
	if(window.XMLHttpRequest){
		req = new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert("There was a problem creating the XMLHttpRequest object");
	}
	return req;
}
	
var http_popUp = createRequestObject_popup();
var divhandler_popUp = new handleDivTag_calendarm(null);


function sendRequest_popup(more) {
	//alert(divtag);
	//if (document.getElementById(divtag)) document.getElementById(divtag).innerHTML = "<img src='/filebin/images/loading.gif'> Loading...";
	http_popUp.open("get", "/filebin/template/popup.php?id="+more);
	http_popUp.onreadystatechange = handleResponse_popup;
	divhandler_popUp.divtag = "popup";
	//if (document.getElementById(divhandler_popUp.divtag).innerHTML == "logout") window.location.reload();
	http_popUp.send(null);
}
function handleResponse_popup() {    
	if(http_popUp.readyState == 4 && http_popUp.status == 200){
		var response = http_popUp.responseText;
		if(response) {
			document.getElementById(divhandler_popUp.divtag).innerHTML = response;
		}
		//else document.getElementById(divhandler_popUp.divtag).innerHTML = "Loading...";
	}
}
