var xmlHttp

function createDialog(e, str) {
	var posx; var posy;
	var tempHeight;
	var ev=(!e)?window.event:e; // IE: Moz
		if(ev.pageX){ //Moz
			posx=ev.pageX;
			posy=ev.pageY;
		}
		else if(ev.clientX){ //IE
			posx=ev.clientX+document.body.scrollLeft;
			posy=ev.clientY+document.body.scrollTop;
		}
		else { // Old Browsers
			document.getElementById("downloadsection").style.position = "relative";
			posx="10px";
			posy="-270px";
		}
	
	posy += -235;
	posx += -15;
	document.getElementById("downloadsection").style.position = "absolute";
	document.getElementById("downloadsection").style.left = posx + "px";
	document.getElementById("downloadsection").style.top = posy + "px";
	document.getElementById("downloadsection").style.visibility = "visible";
	showDownload(str);
	
}

function closeDialog(){
	
		document.getElementById("downloadsection").style.visibility = "hidden";

	
}


function showDownload(str)
{
if (str.length==0)
 { 
 return;
 }

xmlHttp=GetXmlHttpObject()

if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 } 

var url="b4download.php"
url=url+"?segment="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 
var closebox = "<a href='javascript:void(0)' onClick='closeDialog()'><img id='dialogclose' src='images/close.png'></a>"
document.getElementById("downloadsection").innerHTML=xmlHttp.responseText+closebox;
document.getElementById("downloadsection").style.visibility = "visible";
 
} 
}

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;
}