$(document).ready(function() {
	$(document).pngFix(); 
	
	//$pag = $('#contentHolderMiddleContentRight');
	/*
	$('.entryVote').live('click', function($ev) {
										   
		$cakeCookie = $.cookie('CAKEPHP');
		
		if(($cakeCookie != "") && ($cakeCookie != null)) {
										   
			$ev.preventDefault(); // breaks the default anchor link action (so page won't change)
			$link = $(this).attr('href').slice(7); // get the add link / entry id
			$.post( 'http://eric.local/VX/floridaflight2/'+$link, '', function( html ) { // sends ajax request
				$b = $('#t' + $link.slice(16)); // creates id var
				$c = $b.find('span.homeEntryVotesNum').html(); // find the votes total
				$('#t' + $link.slice(16)).find('span.homeEntryVotesNum').html( parseInt($c) + 1 ); // increments the votes total
				e = $ev;
				$("#tooltip").attr({style: 'top: '+(10+parseInt(e.pageY))+'px; left: '+(10+parseInt(e.pageX))+'px'}).html(html);
				$("body").mousemove(function(e){ // creates the tooltip
					$("#tooltip").attr({style: 'top: '+(10+parseInt(e.pageY))+'px; left: '+(10+parseInt(e.pageX))+'px'});
				});
				setTimeout(	"$('body').unbind('mousemove')", 3000); // remove the tooltip moving
				setTimeout(	"$('#tooltip').attr({style: 'top: -5000px; left: -5000px;'})", 3000); // move tooltip off the page
			});
			$(this).remove(); // remove vote button
		
		} else {
		
			$ev.preventDefault(); // breaks the default anchor link action (so page won't change)
			$("#tooltip").attr({style: 'top: '+(10+parseInt($ev.pageY))+'px; left: '+(10+parseInt($ev.pageX))+'px'}).html("Sorry, cookies must be <br/> enabled in order to vote");
			// yous needsssss cookiessss!!!
			$("body").mousemove(function(e){ // creates the tooltip
				$("#tooltip").attr({style: 'top: '+(10+parseInt(e.pageY))+'px; left: '+(10+parseInt(e.pageX))+'px'});
			});
			setTimeout(	"$('body').unbind('mousemove')", 3000); // remove the tooltip moving
			setTimeout(	"$('#tooltip').attr({style: 'top: -5000px; left: -5000px;'})", 3000); // move tooltip off the page
		
		}		
	});*/
	
	// Add bounce effect to mouseover of buttons
	// we set direction down so we don't overlap flash elements at top of page
	// loop 25 times, so we don't overload browsers, but seems like a constant animation
	// 500 = 5s
	$('.bounce').mouseover(function() {
					$(this).effect("bounce", { direction: 'down', distance: 10, times: 10 }, 1500 )
				.mouseout(function() {
					$(this).stop({gotoEnd: true}).animate({top: '0px'}, 500);
				});	
 	});
	/*
	$($pag).ready(function(){
		$.post( 'http://eric.local/VX/floridaflight2/entries/paging/', '', function( html ) {
			$($pag).html( html );																   
		});
	});
	
	$('.paging a').live('click', function($ev){
		$ev.preventDefault();
		$link = $(this).attr('href').slice(18); // get the add link / entry id
		$.post( 'http://eric.local/VX/floridaflight2/'+$link, '', function( html ) {
			$($pag).html( html );																		   
		});
	});
	
	function tb_open_new(jThickboxNewLink){
		tb_show(null,jThickboxNewLink,null);
	} */
	
	/* DO NOT UNCOMMENT
		for clearing text box the add entry form text box
	$('#EntryDescription').one("focus", function() {
  		$(this).val("");
	}); */
	
	
	$('#EntryDescription').keyup(function(){
 		limitChars('EntryDescription', 200, 'descCount');
	})
	/*
	$('#entrysubmit').mousedown(function(ev){
 		ev.preventDefault();
		$(this).attr({ style: 'top: 5px; left: 5px;'});
		return false;
	})
	
	$('#EntryAddform div#sumbit').mouseup(function(){
 		$(this).attr({ style: 'top: 0px; left: 0px;'});
	})*/

});

function limitChars(textid, limit, infodiv) {
	var text = $('#'+textid).val(); 
	var textlength = text.length;
	if(textlength > limit) {
		$('#' + infodiv).html('You cannot write more then '+limit+' characters!');
		$('#'+textid).val(text.substr(0,limit));
		return false;
	} else {
		$('#' + infodiv).html('You have '+ (limit - textlength) +' characters left.');
		return true;
	}
}
		