$(function(){
	if($('.star').length > 1) {
		var userstars = $('#readerstars');
		if (userstars.length > 0)
			userstars.append($('#ratingform'));
		else {
			$('#ratingform').show();
			$('#noratings').show();
		}
		userstars.hover(
			function() {
				$(this).children('.blackstars').hide();
				$(this).children('form').show();
			},
			function() {
				$(this).children('.blackstars').show();
				$(this).children('form').hide();
			}
		);
	}
	
	var starlinks = $('#ratingform .star');
	starlinks.hover(
		function() {
			$('#ratingform .star:lt('+(starlinks.index(this)+1)+')').addClass('star-on');
		},
		function() {starlinks.removeClass('star-on');}
	);
	starlinks.click(function(){
		document.forms['ratingform'].rating.value = starlinks.index(this)+1;
		document.forms['ratingform'].submit();
		return false;
	});
	
	if($("#codeform").length > 0) {
		$("#codeform").submit(function() {
			var action = $("#codeform").attr('action');
 			$("#codeform").attr('action',action+$("#thecode").attr('value'));
		});
	}

//modal
//    $("#app-modal").modal({
//		overlayClose: 'true',
//		closeClass: 'closemodal',
//		close: 'false'
//	});

});