
	var dragObj = new Object();
	dragObj.zIndex = 0;
	
	function filterBillCycle (billCycle){
		processAjax ("specialoffers.php?cycle="+billCycle,document.getElementById('content'),"get","");
	}
	
	//Function to remove a pop-up.
	function popdown (theid){
		var theElement = document.getElementById(theid);
		if (theElement){
			opacity(theid, 100, 0, 500);
			setTimeout ("removeElement('" + theid + "')",501);
		} else {
			//Check for parent versions.
			var parElement = parent.document.getElementById(theid);
			if (parElement){
				opacity(theid, 100, 0, 500);
				setTimeout ("removeElement('" + theid + "')",501);
			}
		}
	}
	
	function removeElement (theid){
		var em = document.getElementById(theid);
		if (!em){
			em = parent.document.getElementById(theid);
		}
		if (em){
			em.parentNode.removeChild(em);
		}
	}
	
	function opacity(id, opacStart, opacEnd, millisec) {
		//speed for each frame
		var speed = Math.round(millisec / 100);
		var timer = 0;
	
		//determine the direction for the blending, if start and end are the same nothing happens
		if(opacStart > opacEnd) {
			for(i = opacStart; i >= opacEnd; i--) {
				setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
				timer++;
			}
		} else if(opacStart < opacEnd) {
			for(i = opacStart; i <= opacEnd; i++){
				setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
				timer++;
			}
		}
	}
	
	//change the opacity for different browsers
	function changeOpac(opacity, id) {
		var iniObj = document.getElementById(id);
		if (iniObj){
			var object = iniObj.style;
			object.opacity = (opacity / 100);
			object.MozOpacity = (opacity / 100);
			object.KhtmlOpacity = (opacity / 100);
			object.filter = "alpha(opacity=" + opacity + ")";
		} else {
			var parObj = parent.document.getElementById(id);
			if (parObj){
				var object = parObj.style;
				object.opacity = (opacity / 100);
				object.MozOpacity = (opacity / 100);
				object.KhtmlOpacity = (opacity / 100);
				object.filter = "alpha(opacity=" + opacity + ")";
			}
		}
	}
	
	//Function to find the x coordinate of an object.  Pass in by ID.
	function findPosX(obj){
		var tempObj = document.getElementById(obj);
		if (tempObj){
			obj = tempObj;
			var curleft = 0;
			if (obj.offsetParent){
				while (obj.offsetParent){
					curleft += obj.offsetLeft
					obj = obj.offsetParent;
				}
			} else if (obj.x){
				curleft += obj.x;
			}
			return curleft;
		} else {
			return false;
		}
	}
	
	//Function to find the y coordinate of an object.  Pass in by ID.
	function findPosY(obj){
		var tempObj = document.getElementById(obj);
		if (tempObj){
			obj = tempObj;
			var curtop = 0;
			if (obj.offsetParent){
				while (obj.offsetParent){
					curtop += obj.offsetTop
					obj = obj.offsetParent;
				}
			} else if (obj.y){
				curtop += obj.y;
			}
			return curtop;
		} else {
			return false;
		}
	}
	
	//Function to create a helpful pop up.
	function createPop (which, theId, theWidth, theItem){
		
		if (document.getElementById(theId)){
			popdown (theId);
		} else {
		
			//Create the div.
			var newPop = document.createElement ('div');
			newPop.className = "popup";
			
			newPop.style.width = theWidth + "px";
			
			//Set the id.
			newPop.id = theId;
					
			var posx = 0;
			var posy = 0;
						
			//Set the exact coordinates.
			posx += findPosX (theItem);
			posy += findPosY (theItem);
			
			if (isNaN (posx)){
				posx = 0;
			}
			if (isNaN (posy)){
				posy = 0;
			}
		
			newPop.style.left = posx + "px";
			newPop.style.top = posy + "px";
			
			// Update element's z-index.
			newZIndex = (dragObj.zIndex + 10);
			newPop.style.zIndex = ++newZIndex;
			
			//Append the div to the body.
			document.body.appendChild (newPop);
			
			//Fade it in.
			opacity(theId, 0, 100, 500);
			
			//Fire the request.
			processAjax (which,document.getElementById(theId),"get","");
		}
	}