	
	//Function to hide / show an area.
	function hideShow (theArea,theHeader){
	
		var onOrOff = false;
	
		var tObj = document.getElementById (theArea);
		
		if (tObj){
		
			if (tObj.className == "invis"){
			
				tObj.className = "vis";
				onOrOff = true;
			
			} else {
			
				tObj.className = "invis";
			
			}
		
		}
		
		//Header.
		var tHeader = document.getElementById (theHeader);
		
		if (tHeader){
		
			if (onOrOff){
			
				tHeader.className = "big_black";
			
			} else {
			
				tHeader.className = "blue";
			
			}
		
		}
	
	}

	//Function to create an AJAX style pop-up.
	function popup (where, e, theid, offsett, offsetl, thewidth, exactx, exacty, remclass, putOver){
		
		var mydiv;
		
		//If this popup already exists, remove it.
		
		if (document.getElementById(theid)){
			removeElement (theid);
		} else {
		
			if (putOver){
				myShim = document.createElement ("iframe");
				//myShim.style.display = "none";
				myShim.style.left = "0px";
				myShim.style.top = "0px";
				myShim.style.position = "absolute";
				myShim.src = "";
				myShim.id = "iframe" + theid;
				myShim.frameBorder = "0";
				myShim.scrolling = "no";
				myShim.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
				myShim.style.width = "auto";
				myShim.style.height = "auto";
				myShim.style.border = "none";
				//Position a div overtop of the shim.
				mydiv = document.createElement("div");
			} else {
				//Create the div.
				mydiv = document.createElement("div");
			}
			
			if (remclass != "yes"){
				//Set the div's class.
				mydiv.className = "popupwin";
			} else {
				mydiv.className = "borderlesspopupwin";
			}
			//Set the width.
			if (thewidth){
				mydiv.style.width = thewidth + "px";
			}
			//Set the id.
			mydiv.id = theid;
					
			var posx = 0;
			var posy = 0;
			
			//Set the exact coordinates.
			if (exactx && exacty){
				mydiv.style.borderWidth = "0px";
				posx = exactx;
				posy = exacty;
			} else {
			
				posx += e.clientX + document.body.scrollLeft;
				posy += e.clientY + document.body.scrollTop;
				
				if (isNaN (posx)){
					posx = 0;
				}
				if (isNaN (posy)){
					posy = 0;
				}
				
				
				//Deal with manual offsets.
				if (offsett != 0 && offsett != ""){
					posy = posy - offsett;
				}
				if (offsetl != 0 && offsetl != ""){
					posx = posx - offsetl;
				}
				
			}
			
			mydiv.style.left = posx + "px";
			mydiv.style.top = posy + "px";
			
			if (putOver){
				myShim.style.left = posx + "px";
				myShim.style.top = posy + "px";
			}
			
			// Update element's z-index.
			newZIndex = 10;
			mydiv.style.zIndex = ++newZIndex;
			
			if (putOver){
				myShim.zIndex = ++newZIndex;
				document.body.appendChild (myShim);
				document.body.appendChild (mydiv);
			} else {
				//Append the div to the body.
				document.body.appendChild (mydiv);
			}
			
			//Fire the request.
			//processajax (where, mydiv, "get", "");
			xmlhttp = getXmlHttp();
			xmlhttp.open("GET",where,false);
			xmlhttp.send('');
			mydiv.innerHTML = xmlhttp.responseText;
			
			//Lastly, duplicate the width and height of the element for the putOver.
			if (putOver){
				var curDiv = document.getElementById(theid);
				if (curDiv){
					myShim.style.width = curDiv.clientWidth + "px";
					myShim.style.height = curDiv.clientHeight + "px";
				}
			}
		}
		
	}
	
	//Function to remove an elemnet by id.
	function removeElement (theid,id,folder,theIndex,indid){
		var em = document.getElementById(theid);
		if (!em){
			em = parent.document.getElementById(theid);
		}
		if (em){
			em.parentNode.removeChild(em);
		}
	}
	
	//Function to set the date field in the add capital cost pop up.
	function setDate (theVal,theId){
		var tObj = document.getElementById(theId);
		if (tObj){
			tObj.value = theVal;
		}
		
	}
	
	//Function to open the coupon print dialog.
	function openPrint (theAd){
	
		window.open ("../print.php?ad="+theAd,"print","width=735,heigh=436");
	
	}
