function popupLoader()
{
	this.URL = "http://"+window.location.host;
	this.popWidth = 0;
	
	this.getPopUpXML = function(formID,wide)
						{
							xml=this.loadXMLDoc(this.URL+"/includes/FormBuilder/formDisplay.php?formID="+formID+"&type=popup");
							xsl=this.loadXMLDoc(this.URL+"/styles/forms_popup.xsl");
							
							// code for IE
							if (window.ActiveXObject)
							{
							  ex=xml.transformNode(xsl);
							  document.getElementById("popup_mid").innerHTML=ex;
							}
							// code for Mozilla, Firefox, Opera, etc.
							else if (document.implementation && document.implementation.createDocument)
							{
							  xsltProcessor=new XSLTProcessor();
							  xsltProcessor.importStylesheet(xsl);
							  resultDocument = xsltProcessor.transformToFragment(xml,document);
							  document.getElementById("popup_mid").appendChild(resultDocument);
							}
							
							var defaultValue = 300;
							if (wide == null){
							  this.popWidth = defaultValue;
							}
							else{
							  this.popWidth = wide; 
							}
							
							this.openPopUp();
						}
	
	this.getPopUpHTML = function(page,wide)
						{
							 var defaultValue = 300;
							 if (wide == null){
							   this.popWidth = defaultValue;
							 }
							 else{
							   this.popWidth = wide; 
							 }
							
							Spry.Utils.updateContent("popup_mid",this.URL+"/includes/PopUps/"+page);
							
							this.openPopUp();
						}
	
	this.loadXMLDoc = function(dname)
				{
					if (window.XMLHttpRequest)
					  {
					  xhttp=new XMLHttpRequest();
					  }
					else
					  {
					  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
					  }
					xhttp.open("GET",dname,false);
					xhttp.send("");
					return xhttp.responseXML;
				}
				
	this.openPopUp = function()
						{
							var popup = document.getElementById("popup");
							popup.style.display = "block";
							popup.style.position = "fixed";
							popup.style.top = "25px";
							var width = (document.body.clientWidth-this.popWidth)/2;
							popup.style.left = width+"px";
							popup.style.zIndex = "300000";
							
							document.getElementById("overlay").style.display = "inline";
							document.getElementById("overlay").style.height = document.getElementById("mainTbl").offsetHeight;
							
							document.getElementById("popup_top_img").style.width = (this.popWidth+20)+"px";
							document.getElementById("popup_bot_img").style.width = (this.popWidth+20)+"px";
							document.getElementById("popup_mid").style.width = (this.popWidth)+"px";
						}
						
	this.closePopUp = function()
						{
							document.getElementById("popup_mid").innerHTML = "";
							
							document.getElementById("popup").style.display = "none";
							document.getElementById("overlay").style.display = "none";
						}
						
	this.submitForm = function(form)
						{
							this.closePopUp();
							
							return Spry.Utils.submitForm(form);
						}
}


