//firebugx
if (!window.console || !console.firebug)
{
    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
    "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];

    window.console = {};
    for (var i = 0; i < names.length; ++i)
        window.console[names[i]] = function() {}
}


function rando (range) {
	return Math.floor(Math.random() * range);
} 



var wizard_slides;
var wizard_index = -1;
var words = [];

jQuery(function () {

	//stuff
	var $ = jQuery;

	function pazow () {

		for (var i = 0; i < n; i++) {
			html += '<div id="words'+i+'" class="words" style="color:rgb('+rando(256)+','+rando(256)+','+rando(256)+');top:'+h/2+'px;left:'+w/2+'px;font-size:'+rando(10)+'px;">'+words[rando(words.length)]+'</div>';
		}
		$('body').append(html);
	
		$('div').each(function (i) {
			var $this = $(this);
			setTimeout(function(){
				$this.animate({top:rando(h),left:rando(w),fontSize:(10 + rando(50))}, 3000 + rando(20000));
			}, rando(20000));
		});
	
	}

	
	words = [];
	
	var html = '';
	var n = 50+rando(100);
	var w = $(window).width();
	var h = $(window).height();
	
	$('body').append('<div id="dialog" style="display:none"><form id="blog-form"><dl><dt>Select Blog:</dt><dd><select id="blog" name="blog"><option></option><option>http://onehundredpoems.wordpress.com/feed/</option><option>http://steveersinghaus.com/mediaplay/?feed=rss2</option><option>http://onehundredpeople.wordpress.com/feed/</option><option>http://feeds2.feedburner.com/Hypercompendia?format=xml</option></select></dd><dt></dt><dd></dl></form></div>');
	
	$('#blog').change(function () { 
		
		$.get('proxy.php?url=' + $(this).val(), function (feed) {
		
			$('#blog-form dl').append('<dt>Select Post:</dt><dd><select id="posts" name="posts"><option></option></select></dd><dt></dt><dd>');
			
			$(feed).find('item').each(function () {
				$('#posts').append('<option>' + $(this).find('title').text() + '</option>');
			});
			
			$('#posts').change(function () {
				var i = $('#posts').attr('selectedIndex');
				var data = $(feed).find('item').eq(i).find('description').text();
				words = data.replace(/<([^>]+)>/gi, '').split(/[,\.\!\?\-\n]/gi);
				$('#dialog').dialog('destroy');
				pazow();
			});
			
		}, 'xml');
	});
	
	$('#dialog').dialog({
		width : 600,
		title : 'Experiment 20090618'
	});
	
	
});

