/******************\
 * System Classes *
\******************/

function MapState(o) {
	if (typeof o != 'undefined') {
		this.name = (typeof o.name != 'undefined') ? o.name : 'Default';
		this.rollover = (typeof o.rollover != 'undefined') ? o.rollover : '';
		this.emblem = (typeof o.emblem != 'undefined') ? o.emblem : '';
		this.pos = (typeof o.pos.x != 'undefined' && typeof o.pos.y != 'undefined') ? o.pos : {x: 0, y: 0};
		this.outerBox = (typeof o.outerBox != 'undefined' && o.outerBox instanceof MapStateBoundingBox) ? o.outerBox : new MapStateBoundingBox({top: {x: 0, y: 0}, bot: {x: 0, y: 0}});
		this.boundingBoxes = (typeof o.boundingBoxes != 'undefined' && o.boundingBoxes instanceof Array) ? o.boundingBoxes : [];
		this.boundingCircles = (typeof o.boundingCircles != 'undefined' && o.boundingCircles instanceof Array) ? o.boundingCircles : [];
		this.offsets = (typeof o.offsets != 'undefined') ? o.offsets : [];
	} else {
		this.name = 'Default';
		this.rollover = '';
		this.emblem = '';
		this.pos = {x: 0, y: 0};
		this.outerBox = new MapStateBoundingBox({top: {x: 0, y: 0}, bot: {x: 0, y: 0}});
		this.boundingBoxes = [];
		this.boundingCircles = [];
		this.offsets = [];
	}

	this.getOffset = function() {
		if (typeof this.offsets === 'object' && this.offsets instanceof Array && this.offsets.length > 0) {
			for (var offset in this.offsets) {
				if (this.offsets[offset].match()) {
					return(this.offsets[offset]);
				}
			}
		}

		return;
	};

	this.getPosition = function() {
		var offset = this.getOffset();

		if (typeof offset != 'undefined') {
			return({x: (this.pos.x + offset.x), y: (this.pos.y + offset.y)});
		}

		return({x: this.pos.x, y: this.pos.y});
	};

	this.isCollided = function(pos) {
		if (typeof pos.x == 'undefined' || typeof pos.y == 'undefined') {
			return(false);
		}

		if ((this.outerBox.bot.y - this.outerBox.top.y) < 1 || (this.outerBox.bot.x - this.outerBox.top.x) < 1) {
			return(false);
		}

		var offset = this.getOffset();
		var outBox = new MapStateBoundingBox({
			top: {
				x: this.outerBox.top.x,
				y: this.outerBox.top.y
			},
			bot: {
				x: this.outerBox.bot.x,
				y: this.outerBox.bot.y
			}
		});

		if (typeof offset != 'undefined') {
			outBox.top.x += offset.x;
			outBox.top.y += offset.y;
			outBox.bot.x += offset.x;
			outBox.bot.y += offset.y;
		}

		if (pos.y < outBox.top.y || pos.y > outBox.bot.y || pos.x < outBox.top.x || pos.x > outBox.bot.x) {
			return(false);
		}

		if (this.boundingBoxes.length < 1 && this.boundingCircles.length < 1) {
			return(false);
		}

		if (this.boundingBoxes.length > 0) {
			for (var i in this.boundingBoxes) {
				var box = this.boundingBoxes[i];
				var obox = new MapStateBoundingBox({
					top: {
						x: box.top.x,
						y: box.top.y
					},
					bot: {
						x: box.bot.x,
						y: box.bot.y
					}
				});

				if (typeof offset != 'undefined') {
					obox.top.x += offset.x;
					obox.top.y += offset.y;
					obox.bot.x += offset.x;
					obox.bot.y += offset.y;
				}

				if ((pos.y > obox.top.y && pos.y < obox.bot.y) && (pos.x > obox.top.x && pos.x < obox.bot.x)) {
					return(true);
				}
			}
		}

		if (this.boundingCircles.length > 0) {
			for (var i in this.boundingCircles) {
				var circle = this.boundingCircles[i];
				var ocircle = new MapStateBoundingCircle({
					x: circle.x,
					y: circle.y,
					d: circle.d
				});

				if (typeof offset != 'undefined') {
					ocircle.x += offset.x;
					ocircle.y += offset.y;
				}

				if (getDistance(pos, ocircle) < ocircle.d) {
					return(true);
				}
			}
		}

		return(false);
	};

	this.showInfo = function () {
		jQuery.ajax({
			url: pluginUrl + 'usrollover.php',
			type: 'POST',
			data: 'getstateinfo=true&state=' + this.name,
			cache: false,
			async: false,
			dataType: 'json',
			success: function (data, textStatus) {
				if (typeof data.text != 'undefined' && typeof data.href != 'undefined' && typeof curState != 'undefined') {
					var spos = curState.getPosition();

					jQuery('.map-overlay a').attr('href', data.href);
					openTip('<div style="float: left; margin-right: 5px"><img src="' + curState.emblem + '" /></div>' +
						'<div style="float: left; width: 150px"><strong>' + curState.name + '</strong><br /><br />' + data.text + '</div>' +
						'<br style="clear: both" />');
				}
			}
		});
	};
};

function MapStateBoundingBox(o) {
	if (typeof o != 'undefined') {
		this.top = {
			x: ((typeof o.top.x != 'undefined') ? o.top.x : 0),
			y: ((typeof o.top.y != 'undefined') ? o.top.y : 0)
		};
		this.bot = {
			x: ((typeof o.bot.x != 'undefined') ? o.bot.x : 0),
			y: ((typeof o.bot.y != 'undefined') ? o.bot.y : 0)
		};
	} else {
		this.top = {x: 0, y: 0};
		this.bot = {x: 0, y: 0}; 
	}
};

function MapStateBoundingCircle(o) {
	if (typeof o != 'undefined') {
		this.x = (typeof o.x != 'undefined') ? o.x : 0;
		this.y = (typeof o.y != 'undefined') ? o.y : 0;
		this.d = (typeof o.d != 'undefined') ? o.d : 0;
	} else {
		this.x = 0;
		this.y = 0;
		this.d = 0;
	}
};

function MapStateBrowserAdjustment(o) {
	if (typeof o != 'undefined') {
		this.x = (typeof o.x != 'undefined') ? o.x : 0;
		this.y = (typeof o.y != 'undefined') ? o.y : 0;
		this.match = (typeof o.match != 'undefined') ? o.match : function(){ return(false); };
	} else {
		this.x = 0;
		this.y = 0;
		this.match = function(){ return(false); };
	}
};

function MapStateAjaxInfo(o) {
	if (typeof o != 'undefined') {
		this.text = (typeof o.text != 'undefined') ? o.text : '';
		this.href = (typeof o.href != 'undefined') ? o.href : '#';
	} else {
		this.text = '';
		this.href = '#';
	}
};

/******************\
 * System Classes *
\******************/

/********************\
 * System Functions *
\********************/

var logInfo = function (num, msg) {
	if (typeof msg == 'undefined') {
		delete logmsgs[num];
	} else {
		logmsgs[num] = msg;
	}

	jQuery('.map-debug').html('');

	for (var logmsg in logmsgs) {
		jQuery('.map-debug').append('<div>' + logmsgs[logmsg] + '</div>');
	}
};

function getAbsolutePosition(element) {
	var r = { x: element.offsetLeft, y: element.offsetTop };

	if (element.offsetParent) {
		var tmp = getAbsolutePosition(element.offsetParent);
		r.x += tmp.x;
		r.y += tmp.y;
	}

	return r;
};

function getRelativeCoordinates(event, reference) {
	var x, y;
	event = event || window.event;
	var el = event.target || event.srcElement;
	
	if (!window.opera && typeof event.offsetX != 'undefined') {
		// Use offset coordinates and find common offsetParent
		var pos = { x: event.offsetX, y: event.offsetY };
		
		// Send the coordinates upwards through the offsetParent chain.
		var e = el;

		while (e) {
			e.mouseX = pos.x;
			e.mouseY = pos.y;
			pos.x += e.offsetLeft;
			pos.y += e.offsetTop;
			e = e.offsetParent;
		}
		
		// Look for the coordinates starting from the reference element.
		var e = reference;
		var offset = { x: 0, y: 0 };

		while (e) {
			if (typeof e.mouseX != 'undefined') {
				x = e.mouseX - offset.x;
				y = e.mouseY - offset.y;
				break;
			}
			offset.x += e.offsetLeft;
			offset.y += e.offsetTop;
			e = e.offsetParent;
		}
		
		// Reset stored coordinates
		e = el;

		while (e) {
			e.mouseX = undefined;
			e.mouseY = undefined;
			e = e.offsetParent;
		}
	} else {
		// Use absolute coordinates
		var pos = getAbsolutePosition(reference);
		x = event.pageX  - pos.x;
		y = event.pageY - pos.y;
	}

	// Subtract distance to middle
	return { x: x, y: y };
}

var getMousePosition = function (e) {
	var pos = {x: 0, y: 0};

	if (map_isIE()) {
		pos.x = event.clientX + document.body.scrollLeft;
		pos.y = event.clientY + document.body.scrollTop;
	} else {
		pos.x = e.pageX;
		pos.y = e.pageY;
	}

	if (pos.x < 0) {
		pos.x = 0;
	}

	if (pos.y < 0) {
		pos.y = 0;
	}

	return(pos);
};

var getDistance = function (pos1, pos2) {
	var dx, dy;

	dx = pos2.x - pos1.x;
	dy = pos2.y - pos1.y;

	return(Math.sqrt((dx * dx) + (dy * dy)));
};

var openTip = function (contents) {
	jQuery('.map-container').append('<div class="chillTip">' + contents + '</div>');
	curTip = jQuery('.chillTip');
	curTip.css("filter:", "alpha(opacity=85)").css("-moz-opacity", "0.85").css("-khtml-opacity", "0.85").css("opacity", "0.85");

	var border_top = jQuery(window).scrollTop(), border_right = jQuery(window).width(), offset = 65, border_offset = 15, left_pos, top_pos;

	if (border_right - (border_offset * 2) >= curTip.width() + mousePos.x) {
		left_pos = mousePos.x + offset;
	} else {
		left_pos = border_right - curTip.width() - offset;
	}

	if (border_top + (border_offset * 2) >= mousePos.y + curTip.height()) {
		top_pos = border_top + offset;
	} else {
		top_pos = mousePos.y + offset;
	}

	curTip.css({left:left_pos, top:top_pos});
	curTip.fadeIn(500);
};

var closeTip = function () {
	if (typeof curTip != 'undefined') {
		curTip.remove();
		curTip = undefined;
	}
};

var trackCoords = function (e) {
	var obj = document.getElementById('map-background');
	var pos = mousePos = getMousePosition(e);
	var abs = getAbsolutePosition(obj);
	var isCollided = false;

	pos.x -= abs.x;
	pos.y -= abs.y;

	for (var i in states) {
		var state = states[i];

		if (state.isCollided(pos)) {
			isCollided = true;
			var spos = state.getPosition();

			jQuery('.map-overlay').css({'top': (abs.y + spos.y) + 'px', 'left': (abs.x + spos.x) + 'px'});
			jQuery('.map-overlay a').empty().append(rollovers[i]);
			jQuery('.map-overlay').show();

			if (typeof curState == 'undefined' || state.name != curState.name) {
				curState = state;
				curState.showInfo();
			}
		}
	}

	if (!isCollided) {
		curState = undefined;
		closeTip();
		jQuery('.map-overlay').hide();
	}
};

// Detect Internet Explorer
function map_isIE() {
	return(jQuery.browser.msie);
};

// Detect Firefox
function map_isFX() {
	return(jQuery.browser.mozilla);
};

// Detect Opera
function map_isOP() {
	return(jQuery.browser.opera);
};

// Detect Chrome
function map_isFail1() {
	return((navigator.userAgent.toLowerCase().indexOf('chrome') > -1) ? true : false);
};

// Detect Safari
function map_isFail2() {
	return(jQuery.browser.safari);
};

/********************\
 * System Functions *
\********************/

/************************\
 * System Configuration *
\************************/

var states = [];
var logmsgs = [];
var pluginUrl, curState, curTip, mousePos, rollovers = [], emblems = [];

jQuery(document).ready(function($) {
	pluginUrl = $('#map-pluginUrl').html();

	states[0] = new MapState({
		name: 'Washington', rollover: pluginUrl + 'state-rollovers/washington.png', emblem: pluginUrl + 'state-emblems/washington.png', pos: {x: 88, y: 0},
		outerBox: new MapStateBoundingBox({top: {x: 92, y: 16}, bot: {x: 157, y: 62}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 123, y: 39, d: 18}),
		     new MapStateBoundingCircle({x: 147, y: 40, d: 16})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: -2, y: -5, match: function() { return(map_isIE()); }})
		]
	});
	states[1] = new MapState({
		name: 'Oregon', rollover: pluginUrl + 'state-rollovers/oregon.png', emblem: pluginUrl + 'state-emblems/oregon.png', pos: {x: 69, y: 34},
		outerBox: new MapStateBoundingBox({top: {x: 81, y: 44}, bot: {x: 160, y: 110}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 118, y: 79, d: 23}),
		     new MapStateBoundingCircle({x: 138, y: 100, d: 8})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[2] = new MapState({
		name: 'California',
		rollover: pluginUrl + 'state-rollovers/california.png',
		emblem: pluginUrl + 'state-emblems/california.png',
		pos: {x: 60, y: 83},
		outerBox: new MapStateBoundingBox({top: {x: 74, y: 96}, bot: {x: 146, y: 224}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 87, y: 121, d: 24}),
		     new MapStateBoundingCircle({x: 81, y: 147, d: 28}),
		     new MapStateBoundingCircle({x: 91, y: 183, d: 38}),
		     new MapStateBoundingCircle({x: 112, y: 209, d: 33})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: -5, y: -5, match: function() { return(map_isIE()); }})
		]
	});
	states[3] = new MapState({
		name: 'Idaho',
		rollover: pluginUrl + 'state-rollovers/idaho.png',
		emblem: pluginUrl + 'state-emblems/idaho.png',
		pos: {x: 134, y: 16},
		outerBox: new MapStateBoundingBox({top: {x: 146, y: 29}, bot: {x: 201, y: 119}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 165, y: 98, d: 14}),
		     new MapStateBoundingCircle({x: 187, y: 100, d: 12})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[4] = new MapState({
		name: 'Nevada',
		rollover: pluginUrl + 'state-rollovers/nevada.png',
		emblem: pluginUrl + 'state-emblems/nevada.png',
		pos: {x: 99, y: 93},
		outerBox: new MapStateBoundingBox({top: {x: 110, y: 105}, bot: {x: 170, y: 198}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 138, y: 138, d: 24})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[5] = new MapState({
		name: 'Utah',
		rollover: pluginUrl + 'state-rollovers/utah.png',
		emblem: pluginUrl + 'state-emblems/utah.png',
		pos: {x: 148, y: 106},
		outerBox: new MapStateBoundingBox({top: {x: 160, y: 116}, bot: {x: 213, y: 183}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 185, y: 150, d: 19})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[6] = new MapState({
		name: 'Arizona',
		rollover: pluginUrl + 'state-rollovers/arizona.png',
		emblem: pluginUrl + 'state-emblems/arizona.png',
		pos: {x: 134, y: 163},
		outerBox: new MapStateBoundingBox({top: {x: 141, y: 176}, bot: {x: 208, y: 252}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 175, y: 213, d: 22})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[7] = new MapState({
		name: 'Alaska',
		rollover: pluginUrl + 'state-rollovers/alaska.png',
		emblem: pluginUrl + 'state-emblems/alaska.png',
		pos: {x: 18, y: 245},
		outerBox: new MapStateBoundingBox({top: {x: 32, y: 255}, bot: {x: 200, y: 422}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 149, y: 319, d: 63})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[8] = new MapState({
		name: 'Hawaii',
		rollover: pluginUrl + 'state-rollovers/hawaii.png',
		emblem: pluginUrl + 'state-emblems/hawaii.png',
		pos: {x: 216, y: 354},
		outerBox: new MapStateBoundingBox({top: {x: 222, y: 354}, bot: {x: 301, y: 402}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 270, y: 391, d: 37})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[9] = new MapState({
		name: 'Montana',
		rollover: pluginUrl + 'state-rollovers/montana.png',
		emblem: pluginUrl + 'state-emblems/montana.png',
		pos: {x: 162, y: 21},
		outerBox: new MapStateBoundingBox({top: {x: 169, y: 27}, bot: {x: 262, y: 92}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 217, y: 60, d: 25})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[10] = new MapState({
		name: 'wyoming',
		rollover: pluginUrl + 'state-rollovers/wyoming.png',
		emblem: pluginUrl + 'state-emblems/wyoming.png',
		pos: {x: 186, y: 75},
		outerBox: new MapStateBoundingBox({top: {x: 203, y: 85}, bot: {x: 258, y: 139}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 229, y: 112, d: 21})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[11] = new MapState({
		name: 'Colorado',
		rollover: pluginUrl + 'state-rollovers/colorado.png',
		emblem: pluginUrl + 'state-emblems/colorado.png',
		pos: {x: 205, y: 132},
		outerBox: new MapStateBoundingBox({top: {x: 212, y: 133}, bot: {x: 275, y: 191}}),
		boundingBoxes: [
		     new MapStateBoundingBox({top: {x: 212, y: 133}, bot: {x: 275, y: 191}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[12] = new MapState({
		name: 'New Mexico',
		rollover: pluginUrl + 'state-rollovers/newmexico.png',
		emblem: pluginUrl + 'state-emblems/newmexico.png',
		pos: {x: 182, y: 173},
		outerBox: new MapStateBoundingBox({top: {x: 208, y: 185}, bot: {x: 259, y: 250}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 231, y: 217, d: 27})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[13] = new MapState({
		name: 'Texas',
		rollover: pluginUrl + 'state-rollovers/texas.png',
		emblem: pluginUrl + 'state-emblems/texas.png',
		pos: {x: 203, y: 186},
		outerBox: new MapStateBoundingBox({top: {x: 233, y: 197}, bot: {x: 353, y: 321}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 299, y: 260, d: 30})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[14] = new MapState({
		name: 'Oklahoma',
		rollover: pluginUrl + 'state-rollovers/oklahoma.png',
		emblem: pluginUrl + 'state-emblems/oklahoma.png',
		pos: {x: 252, y: 180},
		outerBox: new MapStateBoundingBox({top: {x: 266, y: 192}, bot: {x: 346, y: 232}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 320, y: 209, d: 16})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[15] = new MapState({
		name: 'Kansas',
		rollover: pluginUrl + 'state-rollovers/kansas.png',
		emblem: pluginUrl + 'state-emblems/kansas.png',
		pos: {x: 267, y: 148},
		outerBox: new MapStateBoundingBox({top: {x: 277, y: 155}, bot: {x: 345, y: 191}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 308, y: 174, d: 16})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[16] = new MapState({
		name: 'Nebraska',
		rollover: pluginUrl + 'state-rollovers/nebraska.png',
		emblem: pluginUrl + 'state-emblems/nebraska.png',
		pos: {x: 252, y: 109},
		outerBox: new MapStateBoundingBox({top: {x: 262, y: 116}, bot: {x: 329, y: 153}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 297, y: 134, d: 19})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[17] = new MapState({
		name: 'South Dakota',
		rollover: pluginUrl + 'state-rollovers/southdakota.png',
		emblem: pluginUrl + 'state-emblems/southdakota.png',
		pos: {x: 255, y: 74},
		outerBox: new MapStateBoundingBox({top: {x: 265, y: 81}, bot: {x: 324, y: 119}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 293, y: 100, d: 15})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[18] = new MapState({
		name: 'North Dakota',
		rollover: pluginUrl + 'state-rollovers/northdakota.png',
		emblem: pluginUrl + 'state-emblems/northdakota.png',
		pos: {x: 255, y: 34},
		outerBox: new MapStateBoundingBox({top: {x: 268, y: 44}, bot: {x: 322, y: 80}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 296, y: 62, d: 18})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[19] = new MapState({
		name: 'Minnesota',
		rollover: pluginUrl + 'state-rollovers/minnesota.png',
		emblem: pluginUrl + 'state-emblems/minnesota.png',
		pos: {x: 313, y: 34},
		outerBox: new MapStateBoundingBox({top: {x: 327, y: 47}, bot: {x: 359, y: 107}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 343, y: 78, d: 16})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[20] = new MapState({
		name: 'Iowa',
		rollover: pluginUrl + 'state-rollovers/iowa.png',
		emblem: pluginUrl + 'state-emblems/iowa.png',
		pos: {x: 321, y: 106},
		outerBox: new MapStateBoundingBox({top: {x: 333, y: 113}, bot: {x: 372, y: 145}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 352, y: 129, d: 16})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[21] = new MapState({
		name: 'Missouri',
		rollover: pluginUrl + 'state-rollovers/missouri.png',
		emblem: pluginUrl + 'state-emblems/missouri.png',
		pos: {x: 330, y: 141},
		outerBox: new MapStateBoundingBox({top: {x: 346, y: 149}, bot: {x: 377, y: 195}}),
		boundingBoxes: [
		     new MapStateBoundingBox({top: {x: 346, y: 149}, bot: {x: 377, y: 195}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[22] = new MapState({
		name: 'Arkansas',
		rollover: pluginUrl + 'state-rollovers/arkansas.png',
		emblem: pluginUrl + 'state-emblems/arkansas.png',
		pos: {x: 339, y: 190},
		outerBox: new MapStateBoundingBox({top: {x: 352, y: 200}, bot: {x: 380, y: 226}}),
		boundingBoxes: [
		     new MapStateBoundingBox({top: {x: 352, y: 200}, bot: {x: 380, y: 226}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[23] = new MapState({
		name: 'Louisiana',
		rollover: pluginUrl + 'state-rollovers/louisiana.png',
		emblem: pluginUrl + 'state-emblems/louisiana.png',
		pos: {x: 344, y: 230},
		outerBox: new MapStateBoundingBox({top: {x: 358, y: 250}, bot: {x: 376, y: 272}}),
		boundingBoxes: [
		     new MapStateBoundingBox({top: {x: 358, y: 250}, bot: {x: 376, y: 272}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[24] = new MapState({
		name: 'Wisconsin',
		rollover: pluginUrl + 'state-rollovers/wisconsin.png',
		emblem: pluginUrl + 'state-emblems/wisconsin.png',
		pos: {x: 354, y: 62},
		outerBox: new MapStateBoundingBox({top: {x: 372, y: 84}, bot: {x: 395, y: 101}}),
		boundingBoxes: [
		     new MapStateBoundingBox({top: {x: 372, y: 84}, bot: {x: 395, y: 101}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[25] = new MapState({
		name: 'Illinois',
		rollover: pluginUrl + 'state-rollovers/illinois.png',
		emblem: pluginUrl + 'state-emblems/illinois.png',
		pos: {x: 366, y: 116},
		outerBox: new MapStateBoundingBox({top: {x: 382, y: 139}, bot: {x: 404, y: 159}}),
		boundingBoxes: [
			new MapStateBoundingBox({top: {x: 382, y: 139}, bot: {x: 404, y: 159}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[26] = new MapState({
		name: 'Mississippi',
		rollover: pluginUrl + 'state-rollovers/mississippi.png',
		emblem: pluginUrl + 'state-emblems/mississippi.png',
		pos: {x: 372, y: 205},
		outerBox: new MapStateBoundingBox({top: {x: 385, y: 233}, bot: {x: 406, y: 248}}),
		boundingBoxes: [
			new MapStateBoundingBox({top: {x: 385, y: 233}, bot: {x: 406, y: 248}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[27] = new MapState({
		name: 'Florida',
		rollover: pluginUrl + 'state-rollovers/florida.png',
		emblem: pluginUrl + 'state-emblems/florida.png',
		pos: {x: 409, y: 254},
		outerBox: new MapStateBoundingBox({top: {x: 449, y: 270}, bot: {x: 512, y: 306}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 488, y: 290, d: 15})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[28] = new MapState({
		name: 'Alabama',
		rollover: pluginUrl + 'state-rollovers/alabama.png',
		emblem: pluginUrl + 'state-emblems/alabama.png',
		pos: {x: 399, y: 203},
		outerBox: new MapStateBoundingBox({top: {x: 412, y: 215}, bot: {x: 436, y: 248}}),
		boundingBoxes: [
			new MapStateBoundingBox({top: {x: 412, y: 215}, bot: {x: 436, y: 248}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[29] = new MapState({
		name: 'Georgia',
		rollover: pluginUrl + 'state-rollovers/georgia.png',
		emblem: pluginUrl + 'state-emblems/georgia.png',
		pos: {x: 429, y: 203},
		outerBox: new MapStateBoundingBox({top: {x: 435, y: 211}, bot: {x: 484, y: 256}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 458, y: 235, d: 13})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[30] = new MapState({
		name: 'South Carolina',
		rollover: pluginUrl + 'state-rollovers/southcarolina.png',
		emblem: pluginUrl + 'state-emblems/southcarolina.png',
		pos: {x: 449, y: 196},
		outerBox: new MapStateBoundingBox({top: {x: 457, y: 206}, bot: {x: 507, y: 238}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 483, y: 218, d: 11})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[31] = new MapState({
		name: 'Tennessee',
		rollover: pluginUrl + 'state-rollovers/tennessee.png',
		emblem: pluginUrl + 'state-emblems/tennessee.png',
		pos: {x: 382, y: 181},
		outerBox: new MapStateBoundingBox({top: {x: 387, y: 196}, bot: {x: 464, y: 210}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 425, y: 201, d: 8})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[32] = new MapState({
		name: 'North Carolina',
		rollover: pluginUrl + 'state-rollovers/northcarolina.png',
		emblem: pluginUrl + 'state-emblems/northcarolina.png',
		pos: {x: 441, y: 172},
		outerBox: new MapStateBoundingBox({top: {x: 448, y: 192}, bot: {x: 526, y: 213}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 495, y: 195, d: 11})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[33] = new MapState({
		name: 'Kentucky',
		rollover: pluginUrl + 'state-rollovers/kentucky.png',
		emblem: pluginUrl + 'state-emblems/kentucky.png',
		pos: {x: 388, y: 150},
		outerBox: new MapStateBoundingBox({top: {x: 394, y: 164}, bot: {x: 465, y: 192}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 436, y: 180, d: 10})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[34] = new MapState({
		name: 'Virginia',
		rollover: pluginUrl + 'state-rollovers/virginia.png',
		emblem: pluginUrl + 'state-emblems/virginia.png',
		pos: {x: 444, y: 140},
		outerBox: new MapStateBoundingBox({top: {x: 452, y: 152}, bot: {x: 525, y: 183}}),
		boundingCircles: [
		     new MapStateBoundingCircle({x: 499, y: 169, d: 11})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[35] = new MapState({
		name: 'Indiana',
		rollover: pluginUrl + 'state-rollovers/indiana.png',
		emblem: pluginUrl + 'state-emblems/indiana.png',
		pos: {x: 402, y: 122},
		outerBox: new MapStateBoundingBox({top: {x: 414, y: 136}, bot: {x: 431, y: 161}}),
		boundingBoxes: [
			new MapStateBoundingBox({top: {x: 414, y: 136}, bot: {x: 431, y: 161}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[36] = new MapState({
		name: 'Michigan',
		rollover: pluginUrl + 'state-rollovers/michigan.png',
		emblem: pluginUrl + 'state-emblems/michigan.png',
		pos: {x: 374, y: 57},
		outerBox: new MapStateBoundingBox({top: {x: 414, y: 95}, bot: {x: 443, y: 118}}),
		boundingBoxes: [
			new MapStateBoundingBox({top: {x: 414, y: 95}, bot: {x: 443, y: 118}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[37] = new MapState({
		name: 'Ohio',
		rollover: pluginUrl + 'state-rollovers/ohio.png',
		emblem: pluginUrl + 'state-emblems/ohio.png',
		pos: {x: 428, y: 116},
		outerBox: new MapStateBoundingBox({top: {x: 442, y: 133}, bot: {x: 464, y: 150}}),
		boundingBoxes: [
			new MapStateBoundingBox({top: {x: 442, y: 133}, bot: {x: 464, y: 150}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[38] = new MapState({
		name: 'West Virginia',
		rollover: pluginUrl + 'state-rollovers/westvirginia.png',
		emblem: pluginUrl + 'state-emblems/westvirginia.png',
		pos: {x: 453, y: 137},
		outerBox: new MapStateBoundingBox({top: {x: 467, y: 154}, bot: {x: 484, y: 161}}),
		boundingBoxes: [
			new MapStateBoundingBox({top: {x: 467, y: 154}, bot: {x: 484, y: 161}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[39] = new MapState({
		name: 'Maryland',
		rollover: pluginUrl + 'state-rollovers/maryland.png',
		emblem: pluginUrl + 'state-emblems/maryland.png',
		pos: {x: 475, y: 136},
		outerBox: new MapStateBoundingBox({top: {x: 527, y: 165}, bot: {x: 544, y: 175}}),
		boundingBoxes: [
			new MapStateBoundingBox({top: {x: 527, y: 165}, bot: {x: 544, y: 175}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[40] = new MapState({
		name: 'Delaware',
		rollover: pluginUrl + 'state-rollovers/delaware.png',
		emblem: pluginUrl + 'state-emblems/delaware.png',
		pos: {x: 515, y: 134},
		outerBox: new MapStateBoundingBox({top: {x: 533, y: 148}, bot: {x: 551, y: 159}}),
		boundingBoxes: [
			new MapStateBoundingBox({top: {x: 533, y: 148}, bot: {x: 551, y: 159}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[41] = new MapState({
		name: 'Dist. of Columbia',
		rollover: pluginUrl + 'state-rollovers/districtofcolumbia.png',
		emblem: pluginUrl + 'state-emblems/districtofcolumbia.png',
		pos: {x: 557, y: 150},
		outerBox: new MapStateBoundingBox({top: {x: 560, y: 153}, bot: {x: 581, y: 168}}),
		boundingBoxes: [
			new MapStateBoundingBox({top: {x: 560, y: 153}, bot: {x: 581, y: 168}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[42] = new MapState({
		name: 'Pennsylvania',
		rollover: pluginUrl + 'state-rollovers/pennsylvania.png',
		emblem: pluginUrl + 'state-emblems/pennsylvania.png',
		pos: {x: 467, y: 103},
		outerBox: new MapStateBoundingBox({top: {x: 470, y: 111}, bot: {x: 525, y: 140}}),
		boundingBoxes: [
			new MapStateBoundingBox({top: {x: 482, y: 119}, bot: {x: 509, y: 132}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[43] = new MapState({
		name: 'New Jersey',
		rollover: pluginUrl + 'state-rollovers/newjersey.png',
		emblem: pluginUrl + 'state-emblems/newjersey.png',
		pos: {x: 514, y: 113},
		outerBox: new MapStateBoundingBox({top: {x: 539, y: 130}, bot: {x: 555, y: 142}}),
		boundingBoxes: [
			new MapStateBoundingBox({top: {x: 539, y: 130}, bot: {x: 555, y: 142}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[44] = new MapState({
		name: 'New York',
		rollover: pluginUrl + 'state-rollovers/newyork.png',
		emblem: pluginUrl + 'state-emblems/newyork.png',
		pos: {x: 470, y: 66},
		outerBox: new MapStateBoundingBox({top: {x: 498, y: 88}, bot: {x: 523, y: 101}}),
		boundingBoxes: [
			new MapStateBoundingBox({top: {x: 498, y: 88}, bot: {x: 523, y: 101}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[45] = new MapState({
		name: 'Connecticut',
		rollover: pluginUrl + 'state-rollovers/connecticut.png',
		emblem: pluginUrl + 'state-emblems/connecticut.png',
		pos: {x: 527, y: 99},
		outerBox: new MapStateBoundingBox({top: {x: 553, y: 114}, bot: {x: 571, y: 126}}),
		boundingBoxes: [
			new MapStateBoundingBox({top: {x: 553, y: 114}, bot: {x: 571, y: 126}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[46] = new MapState({
		name: 'Rhode Island',
		rollover: pluginUrl + 'state-rollovers/rhodeisland.png',
		emblem: pluginUrl + 'state-emblems/rhodeisland.png',
		pos: {x: 541, y: 94},
		outerBox: new MapStateBoundingBox({top: {x: 569, y: 98}, bot: {x: 586, y: 110}}),
		boundingBoxes: [
			new MapStateBoundingBox({top: {x: 569, y: 98}, bot: {x: 586, y: 110}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[47] = new MapState({
		name: 'Massachusetts',
		rollover: pluginUrl + 'state-rollovers/massachusetts.png',
		emblem: pluginUrl + 'state-emblems/massachusetts.png',
		pos: {x: 528, y: 80},
		outerBox: new MapStateBoundingBox({top: {x: 558, y: 82}, bot: {x: 576, y: 93}}),
		boundingBoxes: [
			new MapStateBoundingBox({top: {x: 558, y: 82}, bot: {x: 576, y: 93}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[48] = new MapState({
		name: 'Vermont',
		rollover: pluginUrl + 'state-rollovers/vermont.png',
		emblem: pluginUrl + 'state-emblems/vermont.png',
		pos: {x: 500, y: 45},
		outerBox: new MapStateBoundingBox({top: {x: 507, y: 55}, bot: {x: 525, y: 67}}),
		boundingBoxes: [
			new MapStateBoundingBox({top: {x: 507, y: 55}, bot: {x: 525, y: 67}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[49] = new MapState({
		name: 'New Hampshire',
		rollover: pluginUrl + 'state-rollovers/newhampshire.png',
		emblem: pluginUrl + 'state-emblems/newhampshire.png',
		pos: {x: 521, y: 41},
		outerBox: new MapStateBoundingBox({top: {x: 526, y: 46}, bot: {x: 543, y: 58}}),
		boundingBoxes: [
			new MapStateBoundingBox({top: {x: 526, y: 46}, bot: {x: 543, y: 58}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});
	states[50] = new MapState({
		name: 'Maine', rollover: pluginUrl + 'state-rollovers/maine.png', emblem: pluginUrl + 'state-emblems/maine.png', pos: {x: 535, y: 26},
		outerBox: new MapStateBoundingBox({top: {x: 549, y: 50}, bot: {x: 568, y: 63}}),
		boundingBoxes: [
			new MapStateBoundingBox({top: {x: 549, y: 50}, bot: {x: 568, y: 63}})
		],
		offsets: [
		     new MapStateBrowserAdjustment({x: 0, y: 0, match: function() { return(map_isIE()); }})
		]
	});

	for (var i in states) {
		rollovers[i] = new Image();
		rollovers[i].src = states[i].rollover;

		emblems[i] = new Image();
		emblems[i].src = states[i].emblem;
	}

	$(".map-outer").hover(
		function() { jQuery('.map-outer').mousemove(trackCoords); },
		function() { jQuery('.map-outer').unbind('mousemove'); }
	);
});

/************************\
 * System Configuration *
\************************/