jQuery(document).ready(function(){

	if(jQuery('div.footer').hasClass('closed')) window.setTimeout(openFooter, 1500);

	jQuery('a.handle').mousedown(function(){
		if(jQuery('div.footer').hasClass('closed')) {
			openFooter();
		} else {
			closeFooter();
		}
	} )
	jQuery('li.search a:first-child').bind('click',function(){
		var li=jQuery(this).parent();
		var input=li.find('input[type=text]');
		if(li.hasClass('open')){
			li.stop();
			li.animate({width:32},200);
			li.removeClass('open')
		} else {
			li.stop();
			li.animate({width:238},200,function(){
				input[0].select();
			})
			li.addClass('open')
		}
	});

	jQuery('div.rotation a').each(function(){
		var images=jQuery(this).children('img');
		var activeIndex=0;
		images.css('display','none');
		window.setInterval(function(){
			jQuery(images[activeIndex]).fadeOut(800,function(){
				activeIndex++;
				if(typeof(images[activeIndex])=='undefined') activeIndex=0;
				jQuery(images[activeIndex]).fadeIn(900);
			});

		},3000);
	});
	adjustWindow();
	window.onresize=adjustWindow;
	window.setTimeout(adjustWindow, 500);
});

function adjustWindow(){
	var height = (jQuery('div.container_standard').height());
	jQuery('div.container_sidebar').css({height:height});
/*	var newsdiv = jQuery('div.news');
	var foundiv = jQuery('div.founder.rotation');

	if ($(window).height()-358-newsdiv.height() < 0) {
		newsdiv.css({bottom:'auto',top:3});
		foundiv.css({bottom:'auto',top:6+newsdiv.height()});
	} else {
		newsdiv.css({bottom:358,top:'auto'});
		foundiv.css({bottom:179,top:'auto'});
	} */
}
function openFooter(){
	jQuery('div.footer').animate({bottom: 0}, 'slow').removeClass('closed');
}
function closeFooter(){
	jQuery('div.footer').animate({bottom: -115}, 'slow').addClass('closed');
}

/**************************** DEBUGGING *********************************************/
var jsPromptPre = "";

jQuery(document).ready(function(){
	jQuery('head').append('<style>#jsPrompt p{font-family:arial;font-style:normal;font-size:9px;background:white;padding:0px;margin:0px;}#jsPrompt{position:fixed;left:0px;bottom:0px;z-index:9999;overflow:visible;width:auto;}</style>');
	jQuery('body').append('<div id="jsPrompt"></div>');
	if(jsPromptPre != "")jp(jsPromptPre);
});

function jp(promptTXT){
	promptTXT +=' ';
	if(document.getElementById('jsPrompt')){
		lines=promptTXT.split("\n");
		for (i=0;i<lines.length;i++){
			var newP = document.createElement("p");
			var newTXT = document.createTextNode(lines[i]);
			newP.appendChild(newTXT);
			document.getElementById('jsPrompt').appendChild(newP);
		}
	} else jsPromptPre+="\n"+promptTXT;
}
function jd(obj){
	var text ='';
	if (typeof(obj)=='object'){
		for(var key in obj) {
			if (key!='channel'){
				if (obj[key])
					var string=""+obj[key];
					if(typeof(obj[key])!='function') text+=key+" => "+string+"\n";
					else text+=key+" => "+string.substring(0,string.indexOf('{'))+"\n";
			}
//			if (obj[key]) text+=key+" => "+obj[key]+"\n";
		}
		jp(text);
	}
}
function jc(){
	if(document.getElementById('jsPrompt')){
		document.getElementById('jsPrompt').innerHTML='';
	} else jsPromptPre="";

}




