$(document).ready(function(){
	//global vars
	var resultValue = $("#IlikeValues");
	var iLikeCode= $("#IlikeCode");
	var clicked = 0;	
	//functions
	function updateIlike(loadURL){
		//just for the fade effect
		//resultValue.hide();
		var code = iLikeCode.html();
				resultValue.fadeIn(2000);
		//send the post to shoutbox.php
		$.ajax({
			type: "POST", url: loadURL, data: "code="+code,
			complete: function(data){
				resultValue.fadeOut();
				resultValue.html(data.responseText);
				resultValue.show();
			}
		});
	}
	//check if all fields are filled
	function checkIlike(){
		
	}
	//Load for the first time the shoutbox data
	//updateShoutbox();
	
	//on submit event
	$("#Ilike").click(function(){
		
		if(clicked==0){
			//	var buttonValue = $("#faqs_button").attr("value");
			var code = iLikeCode.html();
			likeInProgress();
			  $.ajax({
					type: "POST", url: "xml.php?action=ilike&", data: "type=1&value=1&code="+code,
					complete: function(data){
						$("#Ilike").html(data.responseText);
						likeFinished();
					}
				 });
		}
	});
	function likeInProgress(){
		$("#ilike2").html('<img src="images/loading.gif" border="0" />');
		$("#Ilike").html('<img src="images/loading.gif" border="0" />');	
	}
	function likeFinished(){
					$("#ilike2").html('Таны дуртай нийтлэл');
					$("#ilike2").css('cursor','default');
					clicked++;
					window.location='#';
	
	}
	$("#ilike2").click(function(){
		
		//	var buttonValue = $("#faqs_button").attr("value");
		if(clicked==0){
			var code = iLikeCode.html();
			likeInProgress();
			  $.ajax({
					type: "POST", url: "xml.php?action=ilike&", data: "type=1&value=1&code="+code,
					complete: function(data){
						//resultValue.html(data.responseText);
						$("#Ilike").html(data.responseText);
						likeFinished();
					}
				 });
		}
	});
	$("#IlikeDown").click(function(){
		var code = iLikeCode.html();
		  $.ajax({
				type: "POST", url: "xml.php?action=ilike&", data: "type=-1&value=1&code="+code,
				complete: function(data){
					resultValue.html(data.responseText);
				}
			 });
								  
	});
	
});