/* Modified from crossbrowserajax.com */
function cbaDOM() {
	this.removeElement = function(_element) {
		_element.parentNode.removeChild(_element);
	}
	this.createElement = function (_parent, _type, _property, _text) {
		var el = document.createElement(_type);
		// set all properties
		for (var k in _property) {
			var keys = k.split('.');
			// if 'k' - object
			if (keys.length == 2) {
				el[keys[0]][keys[1]] = _property[k];
			}
			else {
				el[k] = _property[k];
			}
		}
		if (_text != '') el.innerHTML = _text;
		_parent.appendChild(el);
		return el;
	}
	this.createScript = function( _parent, _id, _request ) {
		var span = this.createElement( _parent, 'span',{'style.display' : 'none', 'id' : _id}, '%<s' + 'cript></' + 'script>' );
		setTimeout(
				function() {
					var _script = span.getElementsByTagName('script')[0];
					_script.type = 'text/javascript';
					_script.src = _request;
				}, 
				5
			);
	}
}
function cbaRequest() {
	this._init = function() {
		this._handler_error = true;
		if (this._handler_error) {
			window.onerror = this.cbaJsError;
		}
		this._parent_id_name = '_cba_parent_id';
		this._url_id = '_cba_request_id';
		this._id_prefix = '_cba_pack_';
		this.dom = new cbaDOM();
		this._parent_element = this.createParentElement();
		this._requests = new Array();
	}
	this.cbaJsError = function(_message, _url, _line) {
		var _file  = "File: " + _url + " :: " + _line + "\n";
		var _title = "There was an error on this page.\n--------------------------\n";
		var _error = _title;
		_error += "Error: " + _message + "\n";
		_error += _file;
		alert(_error);
	}
	this.createParentElement = function() {
		if (document.getElementById( this._parent_id_name )) {
			return document.getElementById( this._parent_id_name );
		}
		else {
			return this.dom.createElement( document.body, 'div',{'id' : this._parent_id_name}, '' );
		}
	}
	this.query = function( _url , _callback ) {
		var _id = this._requests.push( {'callback' : _callback, 'request' : _url} ) - 1;
		if (_url.indexOf('?') == -1) {
			_url += '?';
		}
		else {
			_url += '&';
		}
		_url += this._url_id + '=' + _id;
		// create < SCRIPT>
		this.dom.createScript( this._parent_element, this._id_prefix + _id, _url );
	}
	this.ready = function(_id, _result ) {
		this.answer = _result;
		// run user function
		if (this._requests[_id].callback instanceof Function) this._requests[_id].callback();
		// remove < SCRIPT>
		if (document.getElementById( this._id_prefix + _id )) {
			this.dom.removeElement( document.getElementById( this._id_prefix + _id ) );
		}
	}
	this._init( arguments );
}

function cbaUpdateElement ( _doc_id, _url ) {
	var _loading_text = (arguments[2]) ? arguments[2] : null;
	var _user_method = (arguments[3]) ? arguments[3] : null;
	
	if (_loading_text) document.getElementById( _doc_id ).innerHTML = _loading_text;

	if (!_cba) _cba = new cbaRequest();

	_cba.query( _url,
			function() {
				document.getElementById( _doc_id ).innerHTML = _cba.answer; 
				if ( _user_method && _user_method instanceof Function ) _user_method();
			}
		);
}
var _cba = null;

function _submitTHIPoll (pollNbr)
{
	var pollPrefix = '_thipoll_' + pollNbr + '_';
	var url = 'http://mv.treehousei.com/Poll.ashx?id=' + pollNbr;
	var data = false;

	var dropdown = document.getElementById(pollPrefix + "DROPDOWN");
	if (dropdown)
	{
		if (dropdown.selectedIndex > 0)
		{
			url += '&vals=' + encodeURIComponent(dropdown.options[dropdown.selectedIndex].value);
			data = true;
		}
	}
	else
	{
		for (var i = 0, elem = document.getElementById(pollPrefix + i); elem != null; i++, elem = document.getElementById(pollPrefix + i))
		{
			if (elem.type == 'checkbox' || elem.type == 'radio')
			{ 
				if (elem.checked)
				{
					url += '&vals=' + encodeURIComponent(elem.value);
					data = true;
				} 
			} 
		}
	}
	
	if (!data)
	{
		alert('Please select a response');
		return;
	}
	cbaUpdateElement('_thipoll_' + pollNbr, url, 'loading ...');
}document.write('\u003cdiv id\u003d\u0022_thipoll_7WQ3NSQWOHG4K\u0022 style\u003d\u0022display: block;\u0022\u003e\u003c?xml version\u003d\u00221.0\u0022 encoding\u003d\u0022utf-16\u0022?\u003e\u003cdiv style\u003d\u0022width: 140px; \u0022 xmlns:Helper\u003d\u0022urn:Helper\u0022\u003e\u003ctable border\u003d\u00220\u0022 width\u003d\u0022100%\u0022\u003e\u003ctr\u003e\u003ctd colspan\u003d\u00222\u0022 align\u003d\u0022center\u0022 style\u003d\u0022padding: 5px 5px 0px 5px; font: bold 11px Verdana, Arial, Helvetica, sans-serif; color: #004395;\u0022\u003eQuestion – What is the number one reason you go to a \u0022globo-gym\u0022?\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd colspan\u003d\u00222\u0022 align\u003d\u0022center\u0022 style\u003d\u0022padding: 0px 5px 2px 5px; font: bold 11px Verdana, Arial, Helvetica, sans-serif; color: #cccccc;\u0022\u003e..........................\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd style\u003d\u0022padding: 2px 5px; width: 10px;\u0022\u003e\u003cinput type\u003d\u0022radio\u0022 name\u003d\u0022_thipoll_7WQ3NSQWOHG4K\u0022 id\u003d\u0022_thipoll_7WQ3NSQWOHG4K_0\u0022 value\u003d\u0022Muscle Gain\u0022 /\u003e\u003c/td\u003e\u003ctd style\u003d\u0022padding: 2px 5px; font: bold 10px Verdana, Arial, Helvetica, sans-serif; color: #404040;\u0022\u003eMuscle Gain\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd style\u003d\u0022padding: 2px 5px; width: 10px;\u0022\u003e\u003cinput type\u003d\u0022radio\u0022 name\u003d\u0022_thipoll_7WQ3NSQWOHG4K\u0022 id\u003d\u0022_thipoll_7WQ3NSQWOHG4K_1\u0022 value\u003d\u0022Find a Date\u0022 /\u003e\u003c/td\u003e\u003ctd style\u003d\u0022padding: 2px 5px; font: bold 10px Verdana, Arial, Helvetica, sans-serif; color: #404040;\u0022\u003eFind a Date\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd style\u003d\u0022padding: 2px 5px; width: 10px;\u0022\u003e\u003cinput type\u003d\u0022radio\u0022 name\u003d\u0022_thipoll_7WQ3NSQWOHG4K\u0022 id\u003d\u0022_thipoll_7WQ3NSQWOHG4K_2\u0022 value\u003d\u0022Lose Weight\u0022 /\u003e\u003c/td\u003e\u003ctd style\u003d\u0022padding: 2px 5px; font: bold 10px Verdana, Arial, Helvetica, sans-serif; color: #404040;\u0022\u003eLose Weight\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd style\u003d\u0022padding: 2px 5px; width: 10px;\u0022\u003e\u003cinput type\u003d\u0022radio\u0022 name\u003d\u0022_thipoll_7WQ3NSQWOHG4K\u0022 id\u003d\u0022_thipoll_7WQ3NSQWOHG4K_3\u0022 value\u003d\u0022Treadmill / Cardio\u0022 /\u003e\u003c/td\u003e\u003ctd style\u003d\u0022padding: 2px 5px; font: bold 10px Verdana, Arial, Helvetica, sans-serif; color: #404040;\u0022\u003eTreadmill / Cardio\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd colspan\u003d\u00222\u0022 align\u003d\u0022center\u0022 style\u003d\u0022padding: 15px 5px 10px 5px;\u0022\u003e\u003ca href\u003d\u0022javascript://\u0022 onClick\u003d\u0022_submitTHIPoll(\u00277WQ3NSQWOHG4K\u0027);\u0022\u003e\u003cimg style\u003d\u0022border-width:0px;\u0022 src\u003d\u0022http://mv.treehousei.com/images/poll/btn_vote_on.gif\u0022 onmouseover\u003d\u0022this.src\u003d\u0027http://mv.treehousei.com/images/poll/btn_vote_on.gif\u0027\u0022 onmouseout\u003d\u0022this.src\u003d\u0027http://mv.treehousei.com/images/poll/btn_vote_on.gif\u0027\u0022 /\u003e\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\u003c/div\u003e\u003c/div\u003e');