$(document).ready(function() {
	//aesthetic change to the width of the select since it's 10px short when calculated dynamically.
	var width = $('form.skeleton select').width();
	$('form.skeleton select').width(width + 20);
	
	
	
	$("#tvbanner").fitText(1);
	$("#fittext").fitText(1.3);
	
	/* TODO: Cookie check menubar
	 * 
	 * Check to see if user has been on the site before.
	 * If not new, then start the menu hidden, otherwise
	 * start with it visible and hide it to give them a hint
	 * to it's existance.
	 * 
	 * We should also check if this is a small device (iPhone)
	 * since the hover effect will not be compatible. This is
	 * combined with the fact that the menubar doesn't scale
	 * well on the smaller responsive-layout sizes. Currently
	 * we kill the menubar on anything below 960px.
	 */
	//$('#susumenu').delay(1000).animate({top:'-22'},750);
	
	$('#susumenu').mouseover(function(){
		$(this).stop(true,false).animate({top:'23'},250);
	}).mouseout(function(){
		$(this).stop(true,false).delay(1000).animate({top:'0'},750);
	});
});


function makeHttpObject() {
	try {return new XMLHttpRequest();}
	catch (error) {}
}

function statIpad(video_id) {
	var request = makeHttpObject();
	request.open("GET", "http://www.susu.tv/videos/stats/"+video_id, false);
	request.send(null);
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
