$(document).ready(function() {

/*	$('.starit').rating({
		callback: function(value, link){
			if (value == 'on') {
				alert(value);
				$(this).rating('select', '');
			} else {
				alert(value);
				$(this).rating('select', 1);
			}
		}
	});
*/


	$('.approveFriend').click(function() {
		var thishref = $(this).attr('href');
		var thisdiv = $(this).parent().attr('id');
		$.ajax({
			type: "POST",
			url: thishref,
			success: function(msg){
				$('#'+thisdiv).fadeOut();
			}		   
		});	
		return false;
	});
	
	$('.star a').click(function() {
		var thishref = $(this).attr('href');
		$.ajax({
			type: "POST",
			url: thishref
			//success: function(msg){}		   
		});
		if ($(this).is('.checked'))
			$(this).removeClass('checked');
		else 
			$(this).addClass('checked');
		return false;		 
	});
	
	
	
	

	$('.starit').click(function() {
//		alert($(this).attr('id'));
		var GiftID = $(this).attr('id').replace('star-', '');
		$.ajax({
		   type: "POST",
		   url: "/_handlers/addstar.php",
		   data: "GiftID=" + GiftID,
		   //success: function(msg){
		   //  alert( "Data Saved: " + msg );
		   //}		   
		 });		
		
	});
	
	
	
	// set onblur/onclick elements for form inputs
/* these are broken, why??

	$('#search-for-friend').clearLabel();
	$('#search-for-friend').addClass('error');
	$('#loginForm #Email').clearLabel();
*/	
	// various form validation's
	
/*	$.validator.setDefaults({
		submitHandler: function() { }
	});
*/	

	
	// validate signup form on keyup and submit
	$("#addcommentform").validate({
		rules: {
			Comment: "required"
		},
		messages: {
			Comment: "You must enter a comment!"
		}
	});




  $(".itemDelete .delete").bind("click", function() { 
    var agree=confirm("Are you sure you want to delete this item?");
    if (agree) {
  		var GiftID = $(this).attr('id').replace('itemDelete-', '');
  
      $.ajax({
        type: "POST",
        url: "/_handlers/deleteBuyListItem.php",
        data: "GiftID=" + GiftID,
        success: function(msg){
          //alert( "Data Saved: " + msg );
          $("#itemContainer-"+GiftID).fadeOut('slow', function() {});
        }		   
      });
      return false;
    
    } else return false;
  });
	


				
});


