/* 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 = 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 move_box_right(an, box) {
  var cleft = 0;
  var ctop = 0;
  var obj = 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 = '170px';
}
function move_box2(an, box) {
  var cleft = 0;
  var ctop = 0;
  var obj = an;
  while (obj.offsetParent) {
    cleft += obj.offsetLeft;
    ctop += obj.offsetTop;
    obj = obj.offsetParent;
  }
  
  box.style.left = cleft + 'px';
  ctop += an.offsetHeight - 800;
  if (document.body.currentStyle &&
    document.body.currentStyle['marginTop']) {
    ctop += parseInt(
      document.body.currentStyle['marginTop']);
  }
  box.style.top = ctop + 'px';
}

function close_iframe(id) {
	 var boxdiv = document.getElementById(id);
	 //alert(id);
	// alert(boxdiv.style.visibility);
	if (boxdiv != null) {
    if (boxdiv.style.visibility=='hidden') {
      move_box(an, boxdiv);
      boxdiv.style.visibility='visible';
	  an = document.getElementById("search_term");
	  move_box(an, boxdiv);
    } else 
      boxdiv.style.visibility='hidden';
	  an = document.getElementById("search_term");
	  move_box2(an, boxdiv);
    //return false;
    }
	 
	 //document.removeElement(id);
}
function show_hide_box(an, pdf) {
	var width='350';
	var height='420';
	var borderStyle='1px solid #8eb4ec';
	//;
	pdf = pdf.replace(/\//g,'\\');
  var href = '/pages/pdf_download_form/100.php?pdf='+pdf;
  
  var boxdiv = document.getElementById(href);
  

  if (boxdiv != null) {
    if (boxdiv.style.visibility=='hidden') {
      move_box(an, boxdiv);
      boxdiv.style.visibility='visible';
    } else
      boxdiv.style.visibility='hidden';
    return false;
  }

  boxdiv = document.createElement('div');
  boxdiv.setAttribute('id', href);
  boxdiv.style.visibility = 'visible';
  boxdiv.style.position = 'absolute';
  boxdiv.style.width = width + 'px';
  boxdiv.style.height = height + 'px';
  boxdiv.style.border = borderStyle;
  boxdiv.style.backgroundColor = '#fff';

  //document.getElementById(href).innerHTML = "<img src=\"filebin/images/x.jpg\" style=\"float:right; cursor:pointer;\" onClick=\"window.parent.close_iframe('"+href+");\">";
  var contents = document.createElement('iframe');
  contents.scrolling = 'no';
  contents.frameBorder = '0';
  contents.style.width = width + 'px';
  contents.style.height = height + 'px';
  contents.src = href;

  boxdiv.appendChild(contents);
  document.body.appendChild(boxdiv);
  move_box(an, boxdiv);

  return false;
}
function show_hide_box2(an) {
	var width='350';
	var height='420';
	var borderStyle='1px solid #8eb4ec';
	//;
  var href = '/pages/pdf_download_form/100.php?action=newURL';
  var boxdiv = document.getElementById(href);
  

  if (boxdiv != null) {
    if (boxdiv.style.visibility=='hidden') {
      move_box(an, boxdiv);
      boxdiv.style.visibility='visible';
    } else
      boxdiv.style.visibility='hidden';
    return false;
  }

  boxdiv = document.createElement('div');
  boxdiv.setAttribute('id', href);
  boxdiv.style.visibility = 'visible';
  boxdiv.style.position = 'absolute';
  boxdiv.style.width = width + 'px';
  boxdiv.style.height = height + 'px';
  boxdiv.style.border = borderStyle;
  boxdiv.style.backgroundColor = '#fff';

  //document.getElementById(href).innerHTML = "<img src=\"filebin/images/x.jpg\" style=\"float:right; cursor:pointer;\" onClick=\"window.parent.close_iframe('"+href+");\">";
  var contents = document.createElement('iframe');
  contents.scrolling = 'no';
  contents.frameBorder = '0';
  contents.style.width = width + 'px';
  contents.style.height = height + 'px';
  contents.src = href;

  boxdiv.appendChild(contents);
  document.body.appendChild(boxdiv);
  move_box(an, boxdiv);

  return false;
}
function show_hide_box3(an) {
	var width='350';
	var height='430';
	var borderStyle='1px solid #8eb4ec';
	//;
  var href = 'pages/webinar_forward/164.php';
  var boxdiv = document.getElementById(href);
  

  if (boxdiv != null) {
    if (boxdiv.style.visibility=='hidden') {
      move_box(an, boxdiv);
      boxdiv.style.visibility='visible';
    } else
      boxdiv.style.visibility='hidden';
    return false;
  }

  boxdiv = document.createElement('div');
  boxdiv.setAttribute('id', href);
  boxdiv.style.visibility = 'visible';
  boxdiv.style.position = 'absolute';
  boxdiv.style.width = width + 'px';
  boxdiv.style.height = height + 'px';
  boxdiv.style.border = borderStyle;
  boxdiv.style.backgroundColor = '#fff';

  //document.getElementById(href).innerHTML = "<img src=\"filebin/images/x.jpg\" style=\"float:right; cursor:pointer;\" onClick=\"window.parent.close_iframe('"+href+");\">";
  var contents = document.createElement('iframe');
  contents.scrolling = 'no';
  contents.frameBorder = '0';
  contents.style.width = width + 'px';
  contents.style.height = height + 'px';
  contents.src = href;

  boxdiv.appendChild(contents);
  document.body.appendChild(boxdiv);
  move_box(an, boxdiv);

  return false;
}
function show_hide_box_right(an, pdf) {
	var width='350';
	var height='420';
	var borderStyle='1px solid #8eb4ec';
	//;
  var href = '/pages/pdf_download_form/100.php?pdf='+pdf;
  var boxdiv = document.getElementById(href);
  

  if (boxdiv != null) {
    if (boxdiv.style.visibility=='hidden') {
      move_box_right(an, boxdiv);
      boxdiv.style.visibility='visible';
    } else
      boxdiv.style.visibility='hidden';
    return false;
  }

  boxdiv = document.createElement('div');
  boxdiv.setAttribute('id', href);
  boxdiv.style.visibility = 'visible';
  boxdiv.style.position = 'absolute';
  boxdiv.style.width = width + 'px';
  boxdiv.style.height = height + 'px';
  boxdiv.style.border = borderStyle;
  boxdiv.style.backgroundColor = '#fff';

  //document.getElementById(href).innerHTML = "<img src=\"filebin/images/x.jpg\" style=\"float:right; cursor:pointer;\" onClick=\"window.parent.close_iframe('"+href+");\">";
  var contents = document.createElement('iframe');
  contents.scrolling = 'no';
  contents.frameBorder = '0';
  contents.style.width = width + 'px';
  contents.style.height = height + 'px';
  contents.src = href;

  boxdiv.appendChild(contents);
  document.body.appendChild(boxdiv);
  move_box_right(an, boxdiv);

  return false;
}
function newPopup(an, pItem) {
	var width='350';
	var height='420';
	var borderStyle='1px solid #8eb4ec';
	//;
  var href = pItem;
  var boxdiv = document.getElementById(href);
  
refreshCheck = 0;
  if (boxdiv != null) {
    if (boxdiv.style.visibility=='hidden') {
	  refreshCheck = 1;
      move_box(an, boxdiv);
      boxdiv.style.visibility='visible';
    } else
     // boxdiv.style.visibility='hidden';
	  refreshCheck = 1;
    return false;
  }
if(refreshCheck == 0){
  boxdiv = document.createElement('div');
  boxdiv.setAttribute('id', pItem);
  boxdiv.style.visibility = 'visible';
  boxdiv.style.position = 'absolute';
  boxdiv.style.width = width + 'px';
  //boxdiv.style.height = height + 'px';
  boxdiv.style.border = borderStyle;
  boxdiv.style.overflow = 'visible';
  boxdiv.style.backgroundColor = '#fff';


  document.body.appendChild(boxdiv);
  move_box(an, boxdiv);
  
 	event_p(pItem)
  }

  return false;
}
function event_p(pItem) {
	var more = pItem;
	sendRequest_popup(more,pItem);
}
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,divtag) {
	//alert(divtag);
	//if (document.getElementById(divtag)) document.getElementById(divtag).innerHTML = "<img src='/filebin/images/loading.gif'> Loading...";
	http_popUp.open("get", "/pages/popup/119.php?item="+more);
	http_popUp.onreadystatechange = handleResponse_popup;
	divhandler_popUp.divtag = divtag;
	//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...";
	}
}
