var jizzVote = 
{
	
	votedImg: "http://static.jizzradio.com/images/likeb.png",
	voteImg: "http://static.jizzradio.com/images/like.png",
	canU:true,
	songId:"",
	songName: "",
	div:"#like",	
	init:function()
	{
		//$("#like").click(jizzVote.vote);
	},
	vote:function()
	{
		
		$.ajax({
		  dataType: 'jsonp',
		  jsonp: 'callback',
		  data:{songId:jizzVote.songId,vote:"1",key:"7b19387e831664365dd2e79414c1dfb1"},
		  url: 'http://jizz.192.cl/vote/makevote.php?jsonp=?',
		  success: function () {
		  	jizzVote.canU = false;
			jizzVote.setVoting();	
		  }
		});	
	},
	setSong:function(id,name)
	{
		this.songId = id;
		this.songName = name;
		this.canVote();
	},
	canVote:function()
	{
		$.ajax({
		  dataType: 'jsonp',
		  jsonp: 'callback',
		  data:{songId:jizzVote.songId,songName:jizzVote.songName},
		  url: 'http://jizz.192.cl/vote/getvotes.php?jsonp=?',
		  success: function (data) {
		  	jizzVote.canU = data.can;
			jizzVote.setVoting();	
		  }
		});	
	},
	setVoting: function()
	{
		if(this.canU == true)
		{
			$(this.div).unbind("click").click(jizzVote.vote).children("img").fadeOut("fast",function(){ $(this).attr("src",jizzVote.voteImg).fadeIn("fast"); });
		}
		else
		{
			$(this.div).unbind("click").children("img").fadeOut("fast",function(){ $(this).attr("src",jizzVote.votedImg).fadeIn("fast"); });
		}
	}
}

$(document).ready(function(){

	jizzVote.init();

});