function RollPop (arg) {
	//*** Create a reference to this instance;
	var me = this;
	this.arg = arg;
	this.source = (typeof(arg.source) == "undefined") ? null : arg.source;
	this.onShow = (typeof(arg.onShow) == "undefined") ? null : arg.onShow;
	this.onHide = (typeof(arg.onHide) == "undefined") ? null : arg.onHide;
	this.pop = (typeof(arg.pop) == "undefined") ? null : arg.pop;
	this.pointer = (typeof(arg.pointer) == "undefined") ? null : arg.pointer;
	this.pointerImage = (typeof(arg.pointerImage) == "undefined") ? null : arg.pointerImage;
	this.anchorTo = (typeof(arg.anchorTo) == "undefined") ? null : arg.anchorTo;
	this.sourceSelector = $("#" + arg.source);
	this.popSelector = $("#" + arg.pop);
	this.popInnerSelector = $("#" + arg.pop + "_inner");
	this.pointerSelector = $("#" + arg.pointer);
	this.anchorSelector = $("#" + arg.anchorTo);
	this.popName = (typeof(arg.popName) == "undefined") ? null : arg.popName;
	this.vOffset = (typeof(arg.vOffset) == "undefined") ? null : arg.vOffset;
	this.block = (typeof(arg.block) == "undefined") ? null : arg.block;
	this.blockSelector = $(this.block);
	this.ajaxURL = (typeof(arg.ajaxURL) == "undefined") ? null : arg.ajaxURL;
	this.urlString = (typeof(arg.urlString) == "undefined") ? null : "AJAX=True" + arg.urlString;
	this.enabled = (typeof(arg.enabled) == "undefined") ? true : arg.enabled;

	RollPop.prototype.hide = function () {
		me.popSelector.hide();
		me.pointerSelector.hide();
		me.blockSelector.unblock();
		me.anchorSelector.fadeTo('fast', 1.0);
		if (typeof(me.onHide) == "function") {
			me.onHide();
		}		
	}
	
	if (!this.enabled) {
		me.sourceSelector.css({ background: "url('./images/switch_off.png') top right no-repeat" });
	}

	//*** Handle mousesover/out for the "General Pest Control" section
	$("#" + this.source + " ul li").mouseover(function() {
		var thisTop = parseInt($(this).offset().top);
		var thisLeft = parseInt($(this).offset().left);
		var thisHeight = parseInt($(this).height());
		var thisWidth = parseInt($(this).width());
		var groupName = $(this).attr("id");

		if (!me.enabled) {
			return;
		}
			
		thisLeft = show_rollpop(groupName,me.popName);
		
		$(this).css({ color : "red", backgroundColor : "white" });
		me.pointerSelector.css({ 
			left: (thisLeft).toString() + "px", 
			top: (thisTop + (thisHeight / 2) + me.vOffset).toString() + "px",
			background: "url('./images/" + me.pointerImage + "')"
		});
		me.pointerSelector.show();
		

	}).mouseout(function(){
		$(this).css({ color : "#388409", backgroundColor : "transparent" });
  	});
	
	me.sourceSelector.click(function(e) {
		var x = parseInt(e.pageX - $(this).offset().left);
		var y = parseInt(e.pageY - $(this).offset().top);
		var onOffImage;
		
		if (x >= ($(this).width() - 16) && y <= ($(this).height() - 16)) {
			me.enabled = !me.enabled;
			me.hide();
			onOffImage = (me.enabled) ? "switch_on.png" : "switch_off.png";
			$(this).css({ background: "url('./images/" + onOffImage + "') top right no-repeat" });
			$.ajax({
			    url: "./include/toggleRollPops.php",
		    	type: 'POST',
			    data: "&name=" + me.popName,
			    success: function(data){
			    	//alert(data);
			    }
			});
		}
  	});
  	
	//*** Set up handler from "Close X" button
	me.popSelector.click(function(e) {
		var x = parseInt(e.pageX - $(this).offset().left);
		var y = parseInt(e.pageY - $(this).offset().top);
		
		if (x >= ($(this).width() - 90) && y <= ($(this).height() - 28)) {
			me.hide();
		}
  	});
  	
	function show_rollpop(seekName, popName) {
		var top = parseInt(me.anchorSelector.offset().top) + 10; 
		var left = parseInt(me.anchorSelector.offset().left) + 10;
		var mysteriousOffset = 0;
		var urlString;
		
		me.anchorSelector.fadeTo('fast', 0.4);
		
		if($.browser.msie) {
			curvyCorners(settings, me.pop);
		} else {
			mysteriousOffset = 34;
		}
	
		me.blockSelector.block({
			message: null,
			overlayCSS:  { 
	    	    backgroundColor: 'transparent', 
	       		opacity: 0.0,
	       		cursor: 'default'
	    	} 
	    });
	    
		me.popSelector.css({ "left" : left + "px", "top" : top + "px", "z-index" : 1001 });
		me.popSelector.show();
		
		if (typeof(me.onShow) == "function") {
			me.onShow();
		}
		
		$.ajax({
		    url: me.ajaxURL,
		    type: 'POST',
		    data: me.urlString + seekName,
		    success: function(data){
				me.popInnerSelector.html(data);
				me.popInnerSelector.css("background","white");
		    }
		});
			
		return me.popSelector.offset().left + me.popSelector.width() + mysteriousOffset;
	}
	
}
