﻿var randomsentence 			= new Array(2);
randomsentence[0] 			= new Array("","Sometimes","I think","Oh yeah, right,","Because","Well,");
randomsentence[1] 			= new Array("you can","you don't","that'll be","my wife","the government");
randomsentence[1]['x']		= new Array(0,0,0,1,1);
randomsentence[2]				= new Array();
randomsentence[2][0] 			= new Array("use","do","want","pay","nice");
randomsentence[2][1] 			= new Array("uses","does","wants","pays","nice");
randomsentence[3] 			= new Array("more attention","it in the same way","to know","a lot more for that information","the method for free");
var randomlevel				= new Array();
randomlevel[1]				= new Array('0,1,2,3,4','0,1,2,3,4','0,1,2,3,4','0,1,2,3,4','0,1,2,3,4','0,1,2,3,4');
randomlevel[2]				= new Array('0,1,3','0,1,2,3','4','0,1,2,3','0,1,2,3');
randomlevel[3]				= new Array('0,1,4','1','0,1,2,3,4','0,2,3','2');

function printanswer(fi) {
answer				= new Array();
rand				= new Array();
list				= new Array();
option				= new Array();

list[0]				= new Array(0,1,2,3,4,5);
rand[0]				= Math.floor(Math.random() * list[0].length);
answer[0]			= randomsentence[0][rand[0]];
option[0]			= -1;
for (n=1;n<randomsentence.length;n++) {
	list[n]			= randomlevel[n][list[n-1][rand[n-1]]].split(',');
	rand[n]			= Math.floor(Math.random() * list[n].length);
	if (option[n-1] == -1) {
		x			= randomsentence[n][list[n][rand[n]]]; }
	else {
		x			= randomsentence[n][option[n-1]][list[n][rand[n]]];
		}
	if (answer[n-1]	== "") { 
		answer[n] 	= x.charAt(0).toUpperCase() + x.substr(1); 
		}
	else { 
		answer[n] 	= x; 
		}
	option[n]		= -1;
	if (randomsentence[n]['x']) { option[n] = randomsentence[n]['x'][list[n][rand[n]]]; }
	}
changeproperty(fi,'','innerHTML',answer.join(" ") + '.','td');
}
function tweetWidget(twitterAccount,rpp,width,height) {
	if (!twitterAccount) return
	if (width!='auto') width = parseInt(width);
	new TWTR.Widget({
		version: 2,
		type: 'profile',
		rpp: rpp,
		interval: 6000,
		width: width,
		height: height,
		theme: {
			shell: {
				background: '#9aa5b0',
				color: '#393939'
			},
			tweets: {
				background: '#d6dbdf',
				color: '#393949',
				links: '#0a68cc'
			}
			},
		features: {
			scrollbar: false,
			loop: false,
			live: false,
			hashtags: true,
			timestamp: true,
			avatars: false,
			behavior: 'all'
			}
		}).render().setUser(twitterAccount).start();
	}

function toggleClass(o,a) {
	o = jQuery(o)
	var result = true, c = o.attr('class');
	if (o.hasClass(a)) o.removeClass(a)
	else o.addClass(a);
	}
jQuery(document).ready(function(){
	setObjectRatios();
	//alignColumn('neurals')
	})
jQuery(window).resize(function(){
	setObjectRatios();
	})
var objectRatios = {}
function setObjectRatios() {
	if (!objectRatios) return
	for (id in objectRatios) {
		var dim = objectRatios[id]
		jQuery(jqId(id)).css('height',parseInt(dim[1]*jQuery(jqId(id)).width()/dim[0]));
		}
	}
function alignColumn(id) {
	// Get jQuery object with the id,
	// and save the css overflow to re-set the value
	var farright, o, p = jQuery((id.charAt(0)=='#')?id:'#'+id);
	var of = p.css('overflow');

	// set the variable c - the maximum loops allowed to be sure it won't run 
	// infinite. I've chosen 20, but it could be highr depending on the amount of lines.
	// And define a random id for a (dump) child that will be appended the JQ object
	var c = 20, last=(parseInt(Math.random()*1000000000)).toString();

	// Append the "flag" child at the end.
	p.append('<div id="'+last+'" display="none"></div>');
	flag = jQuery('#'+last)
	
	// Loop until the x position of the flag is less than the width of the columns block.
	rightOfColumns = p.width()+p.offset().left
	while (flag.offset().left>rightOfColumns&&c>0) {
		p.css('height',p.height()+10);
		c-=1;
		}
	}
