function flashvote() {
	flashMovie.flash(
		function() {
			this.GotoFrame(2);
		}
	);
}

function sharepopnow() {

}

$(function(){

	$('.sharepop').hide();
	
	$('.sharepopnothanks').click(function(){
		$('.sharepop').fadeOut();
	});

	// Cufon Control
	
	Cufon.replace('h2', {hover: true, fontFamily: 'DIN' });
	Cufon.replace('h3', {hover: true, fontFamily: 'DIN' });

	$('#tutorial').hover(function(){
	$(this).fadeOut(500, function() { $(this).remove(); });
	});

	
	// -------- Add Another Friends Email Address ------
	// Set initial Count 
	var count = 2;
	// On Add Field Click
	$('p#add_field').click(function(){
		// upp the initial count by + 1
		count += 1;
		// Append the additional text-input
		$('#addnames').append(
				'<p><label>Another Friends email</label>' 
				+ '<input id="field_' + count + '" name="fields[]' + '" class="text-input" type="text" /></p>' );
	
	});
	
	// -------- Like Button Functionality AJAX PHP JQUERY ------
	// when the like button is pressed
	$(".likebutton").click(function() {  
		//flashvote();
		//get the id
		var the_id = $(this).attr('id');
		$('#likeholder'+the_id).html('<a href="javascript:;" class="likebutton">...</a>');    
		// THE URL TO SEND TO
		var theurl =  '/process_vote/ajax/' + the_id ;
		//var theurl =  'http://www.blackjetinteractive.com/madtesting/random_return/return.php';
		//the main ajax request
			$.ajax({
			   type: "POST",
			   url: theurl,
			   success: function(msg){
				$('#likeholder'+the_id).html('<a href="javascript:;" class="likebutton_used">VOTED</a>');  
				$('#likenumber'+the_id).html(msg + ' VOTES');  
			   }
			});
	});
	
	$("a.likebutton2").click(function() {  
		//flashvote();
	var the_id = $(this).attr('id');
	$('#likeholder'+the_id).html(' <a href="javascript:;" class="button">...</a></span>');  
	var theurl =  '/process_vote/ajax/' + the_id ;
	
	//var theurl =  'http://www.blackjetinteractive.com/madtesting/random_return/return.php';
	//the main ajax request
		$.ajax({
		   type: "POST",
		   url: theurl,
		   success: function(msg){
			$('#likeholder'+the_id).html(' <a href="javascript:;" class="button_used">VOTED</a></span>');  
			$('#likenumber'+the_id).html(msg + ' VOTES');  
				$('.sharepop').fadeOut();
				$('#sharepop'+the_id).fadeIn();
		   }
		});


	});
	
	$("a.reporter").live('click',function() {  
	var the_id = $(this).attr('id');
	//alert(the_id);
	$(this).addClass("abusive");
	$('#reportnumber'+the_id).html('report this name as abusive <a href="javascript:;" id="'+the_id+'" class="abusive report_yes">yes </a>/ <a href="javascript:;" id="'+the_id+'" class="abusive report_no">no</a>');  
	});
		
	$("a.report_yes").live('click',function() {  
		var the_id = $(this).attr('id');
		//alert('REPORT ' + the_id);
		$.ajax({
		   type: "POST",
		   url: '/ajax/report/entry/' + the_id,
		   success: function(msg){
				$('#reportnumber'+the_id).html('reported!');
		   }
		});	
	  
	});
	
	$("a.report_no").live('click',function() {  
	var the_id = $(this).attr('id');
	$('#reportnumber'+the_id).html('<a class="reporter" id="'+the_id+'" href="javascript:;">Report</a>');  
	});
	

});





