function XHRwrapper(o) {
	var
		 oXHR = false
		,oThis    = this
		;
	/*@cc_on
	@if (@_jscript_version >= 5)
		try {
			oXHR = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				oXHR = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				oXHR = false;
			}
		}
	@end @*/
	if( !oXHR && ( typeof XMLHttpRequest != 'undefined' ) ) {
		try {
			oXHR = new XMLHttpRequest();
		} catch( e ) {
			oXHR = false;
		}
	}
	if( oXHR ) {
		oXHR.onreadystatechange = function() {
			if( oThis.onreturn && oXHR.readyState == 4 && oXHR.status == 200 ) {
					oThis.onreturn( oXHR );
				}
			}
		}

	this.URL      = '';
	this.method   = 'get'; // GET||POST
	this.onsubmit = null;
	this.onreturn = null;
	this.payload  = '';
	this.async    = true;

	// Public variable initialization
	if( o ) { for( var _key in o ) { this[_key] = o[_key]; } }

	// public static method declaration
	this.setAsync = function( boolVal ) {
		oThis.async = boolVal;
	}

	this.setMethod = function( strMethod ) {
		if( !$empty(strMethod) ) {
			strMethod = strMethod.toLowerCase();
			if( strMethod == 'get' || strMethod == 'post' ) {
				oThis.method = strMethod;
			}
		}
		return this;
	}
	this.setOnReturn = function( fnc ) {
		oThis.onreturn = fnc;
		return this;
	}
	this.setOnSubmit = function( fnc ) {
		oThis.onsubmit = fnc;
		return this;
	}
	this.setPayload = function( strPayload ) {
		oThis.payload = strPayload;
		return this;
	}

	this.go = function() {
		oXHR.open( oThis.method, oThis.URL, oThis.async );
		if( oThis.onsubmit ) { oThis.onsubmit(); }
		oXHR.send( oThis.payload );
		return this;
	}
} // XHRwrapper
function getAbsPos( obj ) {
	var curleft = 0;
	var curtop = 0;
	if( obj.offsetParent ) {
		while( obj.offsetParent ) {
			curleft += obj.offsetLeft - obj.scrollLeft;
			curtop  += obj.offsetTop - obj.scrollTop;
			var position = '';
			if( obj.style && obj.style.position ) position = obj.style.position.toLowerCase();
			if( ( position=='absolute' ) || ( position == 'relative' ) ) break;
			while (obj.parentNode!=obj.offsetParent) {
				obj=obj.parentNode;
				curleft -= obj.scrollLeft;
				curtop -= obj.scrollTop;
			}
			obj = obj.offsetParent;
		}
	} else {
		if( obj.x ) curleft += obj.x;
		if( obj.y ) curtop  += obj.y;
	}
	return { left:curleft, top:curtop };
}
function geoNavAdjust( geoNavNode ) {
	var anchorNode = document.getElementById( 'vjbcf' );
	if( typeof( geoNavNode ) === 'undefined' || geoNavNode.type == 'resize' ) {
		geoNavNode = document.getElementById( 'geoNav' );
	}
	if( geoNavNode && anchorNode && anchorNode.parentNode ) {
		var aPos = getAbsPos( anchorNode.parentNode );
		geoNavNode.style.top  = ( aPos.top  +   3 ) + 'px';
		geoNavNode.style.left = ( aPos.left + 170 ) + 'px';
	}
}
function geoNavSetup() {
	var execHostnames = [ 'careerlink.com', 'web.aimlink.org', 'dev.aimlink.org' ];
	var execXHR = false;
	for( var i = 0, l = execHostnames.length; i < l; i++ ) {
		if( execHostnames[i] == document.location.hostname ) {
			execXHR = true;
			break;
		}
	}
	if( execXHR ) {
		var xhr = new XHRwrapper( {
				 'URL':'/geo/geonav.php'
				,'onreturn':function( xhr ) {
						if( xhr.responseText != "none" ) {
							var node = document.createElement( 'div' );
							try {
/* // Careerlink 1.0
								node.id = "geoNav";
								node.style.display     = 'block';
								node.style.width       = '210px';
								node.style.height      = '160px';
								node.style.position    = 'absolute';
								node.style.borderLeft  = '1px solid #d0d0d0';
								node.style.left        = '300px';
								node.style.top         = '127px';
								node.style.color       = '#000000';
								node.style.paddingLeft = '20px';
								node.style.fontSize    = '9pt';
								node.style.fontFamily = 'Arial, sans-serif';
*/
// Careerlink 1.5
								node.id = "geoNav";
								node.style.background  = '#ffffff';
								node.style.border      = '1px solid #d0d0d0';
								node.style.display     = 'block';
								node.style.width       = '115px';
								node.style.height      = '140px';
								node.style.position    = 'absolute';
								node.style.top         = '432px';
								node.style.left         = '230px';
								node.style.color       = '#000000';
								node.style.padding     = '4px';
								node.style.fontSize    = '8pt';
								node.style.fontFamily = 'Arial, sans-serif';
								node.innerHTML = xhr.responseText;
								document.body.insertBefore( node, document.body.firstChild );
								geoNavAdjust( node );
							} catch( node_err ) {
								null; // do nothing on error
							}
						}
					}
				} );
		if( xhr ) { xhr.go(); }
	}
	return;
}

// initialization hook up
if( typeof window.addEventListener != 'undefined' ) {                   // DOM2
	window.addEventListener( 'load', geoNavSetup, false );
	window.addEventListener( 'resize', geoNavAdjust, false );
} else if( typeof window.attachEvent != 'undefined' ) {                   // IE
	window.attachEvent( 'onload', geoNavSetup );
	window.attachEvent( 'onresize', geoNavAdjust );
} else {
	if( window.onload != null ) {
		var oldOnload = window.onload;
		window.onload = function( e ) {
				oldOnload( e );
				geoNavSetup();
			};
	} else {
		window.onload = geoNavSetup;
	}
}
