function adpResizeFlash(id, newHeight) {
	var fl = document.getElementById('AddpollFlash' + id);
	fl.setAttribute('height', newHeight + 'px');
	
	var embed = fl.getElementsByTagName('embed') || [];
	
	for ( var i = 0; i < embed.length; i++ ) {
		embed[i].setAttribute('height', newHeight + 'px');
	}
	
}
var AddPoll65036 = {
	server: 'http://www.addpoll.com/',
	ownerUserName: 'mattcit',
	html: '',
	id: 65036,
	flash: 1,
	flashHeight: 300,
	resultsHeight: 300,
	flashTheme: 0,
	closed: false,
	otherAnswers: 0,
	pollTypes: {"radio":1,"combobox":2,"checkbox":3},
	pollType: 1,
	protocol: document.location.protocol == "https:" ? "https:" : "http:",
	cssStyle: '',
	selectedAnswers: [],
	otherAnswerText : '',
	audioTimer: null,
	language: {
		'enterSecretKey' : 'Please enter poll secret key.',
		'selectAnswer' : 'Please select a choice to vote for.'
	},
	
	
	customParams: {
		'width' : 0,
		'height' : 0
	},
	
	secure: function() {
		return this.protocol == "https:";
	},
	
	$: function(el) {
		return document.getElementById(el);
	},
	
	urlencode: function(str) {
		str = (str + '').toString();
		
	return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
	},
	
	poweredBy: function(show) {
		if ( show ) {
			this.$('adpPowered-' + this.id).style.display = 'block';
		} else {
			this.$('adpPowered-' + this.id).style.display = 'none';
		}
	},
	
	addEvent: function(el, ev, func) {
		if (!el.addEventListener) {
			el.attachEvent("on" + ev, func);
		} else {
			el.addEventListener(ev, func, false);
		}
	},
	
	removeEvent: function(el, ev, func) {
		if (!el.removeEventListener) {
			el.detachEvent("on" + ev, func);
		} else {
			el.removeEventListener(ev, func, false);
		}
	},
	
	share: function() {
		var self = this;
		var el = this.$('AddPollContainer-' + this.id);
		window.setTimeout(function(){
			el.onclick = function(){
				self.hideShare();
			};
			//self.addEvent(el, 'click', self.hideShare.apply(self));
		}, 500);
		
		var s = this.$('adpShare-' + this.id);
		s.style.display = 'block';
		
		if ( s.src == 'about:blank;' ) {
			s.src = this.server + 'poll/share/q/' + this.id;
		}
	},
	
	hideShare: function() {
		var self = this;
		var el = this.$('AddPollContainer-' + this.id);
		window.setTimeout(function(){
			el.onclick = null;
			//self.removeEvent(el, 'click', self.hideShare.bind(self));
		}, 500);
		
		var s = this.$('adpShare-' + this.id);
		s.style.display = 'none';
	},
	
	elementPosition: function(el) {
		var left = 0;
		var top = 0;
		
		if (el.offsetParent) {
			do {
				left += el.offsetLeft;
				top += el.offsetTop;
			} while (el = el.offsetParent);
		}
		
	return {x: left, y: top};
	},
	
	getScrollXY: function() {
		var scrOfX = 0, scrOfY = 0;
		if( typeof( window.pageYOffset ) == 'number' ) {
			//Netscape compliant
			scrOfY = window.pageYOffset;
			scrOfX = window.pageXOffset;
		} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
			//DOM compliant
			scrOfY = document.body.scrollTop;
			scrOfX = document.body.scrollLeft;
		} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
			//IE6 standards compliant mode
			scrOfY = document.documentElement.scrollTop;
			scrOfX = document.documentElement.scrollLeft;
		}
		
	return {x: scrOfX, y: scrOfY};
	},
	
	scrollToTitle: function() {
		var el = this.$('AddPollContainer-' + this.id);
		var pos = this.elementPosition(el);
		var viewScroll = this.getScrollXY();
		
		if ( pos.y + 30 > viewScroll.y ) {
			return;
		}
		
		this.scrollAnimation(pos.y);
	},
	
	scrollAnimation: function(yPosTo) {
		var viewScroll = this.getScrollXY();
		
		var offset = viewScroll.y - yPosTo;
		
		if ( offset < 0 ) {
			return;
		}
		
		window.scrollBy(0, -10);
		
		var self = this;
		window.setTimeout(function(){
			self.scrollAnimation(yPosTo);
		}, 10);
	},
	
	prepareCustomParams: function(params) {
		if ( typeof params.width != 'undefined' ) {
			this.customParams['width'] = parseInt(params.width);
		}
		
		if ( typeof params.height != 'undefined' ) {
			this.customParams['height'] = parseInt(params.height);
		}
		
		if ( isNaN(this.customParams['width']) || this.customParams['width'] < 0 ) {
			this.customParams['width'] = 0;
		}
		
		if ( this.customParams['width'] > 3000 ) {
			this.customParams['width'] = 3000;
		}
		
		if ( isNaN(this.customParams['height']) || this.customParams['height'] < 0 ) {
			this.customParams['height'] = 0;
		}
		
		if ( this.customParams['height'] > 3000 ) {
			this.customParams['height'] = 3000;
		}
	},
	
	init: function() {
		
		var el = this.$('AddPollContainer-' + this.id) || null;
		
		if ( el === null ) {
			document.write('<div id="AddPollContainer-' + this.id + '"><span style="font-family: arial, verdana, tahoma; font-size: 16px; color: #2F6894; display: block; padding: 5px 0; background-color: #F1F1F1; border: 1px solid #DDD; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; text-align: center;">Loading...</span></div>');
		}
		
		if ( typeof adpCustomParams65036 != 'undefined' ) {
			this.prepareCustomParams(adpCustomParams65036);
		}
		
		this.loadAudio();
		
		this.loadCss('addpoll.css');
		this.loadCss(null, this.cssStyle);
		
		if ( this.flash == 0 ) {
			this.loadCss('fonts.css');
		}
		
		var self = this;
		this.audioTimer = window.setTimeout(function(){
			self.checkReady();
		}, 400);
	},
	
	checkReady: function() {
		if ( typeof AddPollSwfObject != 'undefined' && typeof AudioPlayer != 'undefined' ) {
			clearTimeout(this.audioTimer);
			
			this.ready();
		} else {
			var self = this;
			this.audioTimer = window.setTimeout(function(){
				self.checkReady();
			}, 400);
		}
	},
	
	ready: function() {
		var el = this.$('AddPollContainer-' + this.id) || null;
		
		if ( el === null ) {
			return false;
		}
		
		if ( this.customParams['width'] > 0 ) {
			el.style.width = this.customParams['width'] + 'px';
		}
		
		if ( this.customParams['height'] > 0 ) {
			el.style.height = this.customParams['height'] + 'px';
		}
		
		el.innerHTML = this.html;
		
		this.listenEvents();
		
		if ( this.flash == 1 ) {
			return this.initFlash();
		}
		
		var self = this;
		window.setTimeout(function() {
			self.parseJs(self.html);
		}, 800);
		
	},
	
	listenEvents: function() {
		this.listenOtherText();
	},
	
	listenOtherText: function() {
		var self = this;
		var ansOther = this.$('answerOther-' + this.id) || null;
	
		if ( ansOther !== null ) {
			ansOther.onfocus = function(){
				self.$('answersOtherCheck-' + self.id).checked = true;
			};
		}
	},
	
	parseJs: function(html) {
		var code = '';
		var el = this.$('AddPollContainer-' + this.id);
		
		if ( typeof html == 'undefined' ) {
			html = el.innerHTML;
		}
		
		html.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(){
			code += arguments[1] + '\n';
		return '';
		});
		
		if ( code == '' ) {
			return false;
		}
		
		var elementToRemove = this.$('customJs-' + this.id) || null;
		
		if ( elementToRemove != null ) {
			el.removeChild(elementToRemove);
		}
		
		var script = document.createElement('script');
		script.setAttribute('type', 'text/javascript');
		script.setAttribute('id', 'customJs-' + this.id);
		
		if ( script.canHaveChildren == null || script.canHaveChildren ) {
			script.appendChild(document.createTextNode(code));
		} else {
			script.text = code;
		}
		
		el.insertBefore(script, el.firstChild);
	},
	
	initFlash: function() {
		
		var div = document.createElement('div');
		var divId = document.createAttribute('id');
		divId.nodeValue = 'adpFlashPollContent' + this.id;
		div.setAttributeNode(divId);
		
		this.$('AddPollContainer-' + this.id).appendChild(div);
		
		var adpFlashVars = {
			questionId: this.id,
			theme: this.flashTheme,
			resultsHeight : this.resultsHeight,
			ref: escape(location.href)
		};
		
		var adpParams = {
			allowScriptAccess: "always",
			wmode: "transparent"
		};
		
		var adpAttributes = {
			id: "AddpollFlash" + this.id,
			name: "AddpollFlash" + this.id
		};
		
		AddPollSwfObject.embedSWF(this.server + "flashPoll.swf?" + new Date().getTime(), "adpFlashPollContent" + this.id, (this.customParams['width'] > 0 ? this.customParams['width'] : 300), this.customParams['height'] > 0 ? this.customParams['height'] : this.flashHeight, "9.0.0", false, adpFlashVars, adpParams, adpAttributes);
	},
	
	loadCss: function(url, code) {
		url = url || null;
		code = code || '';
		
		var head = document.getElementsByTagName('head')[0].firstChild;
		
		if ( head == null ) {
			head = document.getElementsByTagName('script')[0];
		}
		
		if ( url != null ) {
			var styleEl = document.createElement('link');
			styleEl.setAttribute('id', 'css-' + this.id);
			styleEl.setAttribute('type', 'text/css');
			styleEl.setAttribute('rel', 'stylesheet');
			styleEl.setAttribute('media', 'screen');
			
			styleEl.setAttribute('href', this.server + 'css/' + url);
		}else if ( code != '' ) {
			var styleEl = document.createElement('style');
			styleEl.setAttribute('type', 'text/css');
			
			if (styleEl.styleSheet) {
				styleEl.styleSheet.cssText = code;
			} else {
				styleEl.appendChild(document.createTextNode(code))
			}
		}
		
		if ( styleEl == null ) {
			return false;
		}
		
		head.parentNode.insertBefore(styleEl, head);
	},
	
	audioWidth: 260,
	loadAudio: function() {
		
		if ( typeof AddPollSwfObject != 'undefined' ) {
			return true;
		}
		
		var sc = document.getElementsByTagName('script')[0];
		var script = document.createElement('script');
		
		script.setAttribute('type', 'text/javascript');
		script.setAttribute('src', this.server + 'js/audio-player.js');
		
		var self = this;
		
		if ( script.readyState ) {  // IE
			script.onreadystatechange = function() {
				if ( this.readyState == 'loaded' || this.readyState == 'complete' ) {
					self.setupAudio(sc);
					script.onreadystatechange = null;
				}
			}
		} else { // Others
			script.onload = function() {
				self.setupAudio(sc);
				script.onload = null;
			}
		}
		
		sc.parentNode.insertBefore(script, sc);
	},
	
	setupAudio: function(sc) {
		if ( this.flash == 1 ) {
			return false;
		}
		
		var audioScript = document.createElement('script');
		audioScript.setAttribute('type', 'text/javascript');
		
		var audioCode = 'AudioPlayer.setup("' + this.server + 'swf/audioplayer.swf",{width:' + this.audioWidth + '});';
		
		if ( audioScript.canHaveChildren == null || audioScript.canHaveChildren ) {
			audioScript.appendChild(document.createTextNode(audioCode));
		} else {
			audioScript.text = audioCode;
		}
		
		sc.parentNode.insertBefore(audioScript, sc);
		
	return true;
	},
	
	removeOldScript: function() {
		var head = document.getElementsByTagName('head')[0];
		var elementToRemove = this.$('vote-' + this.id) || null;
		
		if ( elementToRemove == null ) {
			return;
		}
		
		head.removeChild(elementToRemove);
	},
	
	setSecret: function(form) {
		
		if ( !form.secretKey || form.secretKey.value == '' ) {
			this.setError(this.language.enterSecretKey);
		return false;
		}
		
		this.removeOldScript();
		
		var head = document.getElementsByTagName('head')[0];
		var script = document.createElement('script');
		script.setAttribute('id', 'vote-' + this.id);
		script.setAttribute('charset', 'utf-8');
		script.setAttribute('src', this.server + 'poll/embed/q/' + this.id + '?setSecret=' + this.urlencode(form.secretKey.value));
		
		head.appendChild(script);
	},
	
	showResults: function(success) {
		this.removeOldScript();
		
		success = success || false;
		
		var head = document.getElementsByTagName('head')[0];
		var script = document.createElement('script');
		script.setAttribute('id', 'vote-' + this.id);
		script.setAttribute('charset', 'utf-8');
		script.setAttribute('src', this.server + 'poll/embed/q/' + this.id + '?results' + (success ? '&success' : ''));
		
		head.appendChild(script);
	},
	
	showPoll: function() {
		this.removeOldScript();
		
		var head = document.getElementsByTagName('head')[0];
		var script = document.createElement('script');
		script.setAttribute('id', 'vote-' + this.id);
		script.setAttribute('charset', 'utf-8');
		script.setAttribute('src', this.server + 'poll/embed/q/' + this.id + '?back=poll');
		
		head.appendChild(script);
	},
	
	showComments: function() {
		window.location = this.server + this.ownerUserName + '/poll/' + this.id + '#comments';
	},
	
	vote: function() {
		
		this.getSelectedAnswer();
		
		if ( this.selectedAnswers.length == 0 ) {
			this.setError(this.language.selectAnswer);
		return false;
		}
		
		var answer = this.selectedAnswers.join(',');
		var other = this.urlencode(this.otherAnswerText);
		var tags = '';
		var ref = escape(location.href);
		
		this.removeOldScript();
		
		var head = document.getElementsByTagName('head')[0];
		var script = document.createElement('script');
		script.setAttribute('id', 'vote-' + this.id);
		script.setAttribute('charset', 'utf-8');
		script.setAttribute('src', this.server + 'poll/embed/q/' + this.id + '?voting=1&answer=' + answer + '&other=' + other + '&ref=' + ref + '&tags=' + tags);
		
		head.appendChild(script);
		
	return true;
	},
	
	hotOrNotVote: function(el) {
		var id = el.id;
		var elem = this.$(id);
		var score = parseInt(elem.getElementsByTagName('input')[0].value);
		
		if ( isNaN(score) || score <= 0 ) {
			this.setError('Please select a score.');
		return false;
		}
		
		var tags = '';
		var ref = escape(location.href);
		
		this.removeOldScript();
		
		var head = document.getElementsByTagName('head')[0];
		var script = document.createElement('script');
		script.setAttribute('id', 'vote-' + this.id);
		script.setAttribute('charset', 'utf-8');
		script.setAttribute('src', this.server + 'poll/embed/q/' + this.id + '?voting=1&hotscore=' + score + '&ref=' + ref + '&tags=' + tags);
		
		head.appendChild(script);
		
	return true;
	},
	
	getSelectedAnswer: function() {
		this.resetVote();
		
		var name = 'answerId';
		
		var ans = this.$('adpQuestionAnswers' + this.id).getElementsByTagName('input');
		
		if ( this.pollType == this.pollTypes['checkbox'] ) {
			name += '[]';
		}
		
		for ( var i = 0, j = ans.length; i < j; i++ ) {
			if ( ans[i].getAttribute('name') == name && ans[i].checked == true ) {
				var v = parseInt(ans[i].value);
				
				if ( isNaN(v) || v == 0 || v < -1 ) {
					continue;
				}
				
				if ( v == -1 ) {
					this.getOtherAnswer();
				}
				
				this.selectedAnswers.push(v);
			}
		}
		
		if ( this.pollType == this.pollTypes['combobox'] ) {
			var ans = this.$('adpQuestionAnswers' + this.id).getElementsByTagName('select');
			
			for ( var i = 0, j = ans.length; i < j; i++ ) {
				if ( ans[i].getAttribute('name') == name ) {
					var v = parseInt(ans[i].options[ans[i].selectedIndex].value);
					
					if ( isNaN(v) || v <= 0 ) {
						continue;
					}
					
					this.selectedAnswers.push(v);
				}
			}
		}
	},
	
	getOtherAnswer: function() {
		if ( this.otherAnswers != 1 ) {
			return false;
		}
		var el = this.$('answerOther-' + this.id) || null;
		
		this.otherAnswerText = el !== null ? el.value : '';
	},
	
	resetVote: function() {
		this.selectedAnswers = [];
		this.otherAnswerText = '';
	},
	
	errorTimer: null,
	setError: function(text) {
		if ( this.errorTimer != null ) {
			clearTimeout(this.errorTimer);
		}
		
		var el = this.$('adpError' + this.id);
		el.innerHTML = text;
		el.style.display = 'block';
		
		var cont = this.$('AddPollContainer-' + this.id);
		var pos = this.elementPosition(cont);
		var viewScroll = this.getScrollXY();
		
		if ( pos.y < viewScroll.y ) {
			el.style.top = (viewScroll.y - pos.y) + 10 + 'px';
		} else {
			el.style.top = '1%';
		}
		
		var self = this;
		this.errorTimer = window.setTimeout(function(){
			var el = self.$('adpError' + self.id);
			el.style.display = 'none';
			el.innerHTML = '';
		}, 5000);
	},
	
	successTimer: null,
	setSuccess: function(text) {
		if ( this.successTimer != null ) {
			clearTimeout(this.successTimer);
		}

		var el = this.$('adpSuccess' + this.id);
		
		el.innerHTML = text;
		el.style.display = 'block';
		
		var cont = this.$('AddPollContainer-' + this.id);
		var pos = this.elementPosition(cont);
		var viewScroll = this.getScrollXY();
		
		/*if ( pos.y < viewScroll.y ) {
			el.style.top = (viewScroll.y - pos.y) + 10 + 'px';
		} else {
			el.style.top = '1%';
		}*/
		
		el.style.top = '1%';
		
		var self = this;
		this.successTimer = window.setTimeout(function(){
			var el = self.$('adpSuccess' + self.id);
			el.style.display = 'none';
			el.innerHTML = '';
		}, 5000);
	},
	getElementsByClassName : function (className, tag, elm){
		if (document.getElementsByClassName) {
			getElementsByClassName = function (className, tag, elm) {
				elm = elm || document;
				var elements = elm.getElementsByClassName(className),
					nodeName = (tag)? new RegExp("\\b" + tag + "\\b", "i") : null,
					returnElements = [],
					current;
				for(var i=0, il=elements.length; i < il; i+=1){
					current = elements[i];
					if(!nodeName || nodeName.test(current.nodeName)) {
						returnElements.push(current);
					}
				}
				return returnElements;
			};
		} else if (document.evaluate) {
			getElementsByClassName = function (className, tag, elm) {
				tag = tag || "*";
				elm = elm || document;
				var classes = className.split(" "),
					classesToCheck = "",
					xhtmlNamespace = "http://www.w3.org/1999/xhtml",
					namespaceResolver = (document.documentElement.namespaceURI === xhtmlNamespace)? xhtmlNamespace : null,
					returnElements = [],
					elements,
					node;
				for(var j=0, jl=classes.length; j < jl; j+=1){
					classesToCheck += "[contains(concat(' ', @class, ' '), ' " + classes[j] + " ')]";
				}
				try	{
					elements = document.evaluate(".//" + tag + classesToCheck, elm, namespaceResolver, 0, null);
				}
				catch (e) {
					elements = document.evaluate(".//" + tag + classesToCheck, elm, null, 0, null);
				}
				while ((node = elements.iterateNext())) {
					returnElements.push(node);
				}
				return returnElements;
			};
		}
		else {
			getElementsByClassName = function (className, tag, elm) {
				tag = tag || "*";
				elm = elm || document;
				var classes = className.split(" "),
					classesToCheck = [],
					elements = (tag === "*" && elm.all)? elm.all : elm.getElementsByTagName(tag),
					current,
					returnElements = [],
					match;
				for(var k=0, kl=classes.length; k < kl; k+=1){
					classesToCheck.push(new RegExp("(^|\\s)" + classes[k] + "(\\s|$)"));
				}
				for(var l=0, ll=elements.length; l < ll; l+=1){
					current = elements[l];
					match = false;
					for(var m=0, ml=classesToCheck.length; m < ml; m+=1){
						match = classesToCheck[m].test(current.className);
						if (!match) {
							break;
						}
					}
					if (match) {
						returnElements.push(current);
					}
				}
				return returnElements;
			};
		}
	return getElementsByClassName(className, tag, elm);
	}
}

AddPoll65036.init();
