
$(document).ready(function(){
	
	// Load feedback
	$(".feedback-link").fancybox({
			'width'						: 580,
			'height'					: 300,
	    'autoScale'     	: false,
	    'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'						: 'iframe',
			'modal' 					: true,
			'overlayOpacity'	: 0.6
			
		});
	
	$("#lovepersha").click(function(){
		
		$("#like-counter").load("/misc/ilike.php?like");
		
		$("#ilike").fadeIn("normal");
		//like-counter
		return false;
	});
	
	$("#calc-form").submit(function(){
		
		//var old_val = $("#form-submit").val();
		$("#form-submit").attr("disabled","true");
		
		var _get = $(this).serialize(); 
		$("#calc-summ").html("");

		$.get("/misc/calculate.php?" + _get, function(data){

			if(data > 0){
				$("#calc-summ").html(data);
				$("#calc-good").show();
				$("#calc-bad").hide();
				
			}else{
				$("#calc-good").hide();
				$("#calc-bad").show();
			}
			$("#calc-form").slideToggle();
			$("#calc-result").show();
			$("#form-submit").removeAttr("disabled");
			
		});
		
		return false;
	});
	
	$("#vote-form").submit(function(){
		
		//var old_val = $("#form-submit").val();
		//$("#form-submit").attr("disabled","true");
		$("#vote-submit").attr("disabled","true");
		var _get = $(this).serialize();
		
		$.get("/misc/vote.php?" + _get, function(data){
			
			if( data == "good"){
				
				$("#vote-form").fadeOut("fast", function(){
					$("#vote-thanx").fadeIn("normal");
				});
			}
			$("#vote-submit").removeAttr("disabled");
		});
		
		return false;
	});
	
});

function switch_content(){

	if( $.cookie('content_type') != "detail" ){
		$("#link-short").show();
		$("#link-full").hide();
		$.cookie('content_type', 'detail');
	}else{
		$("#link-short").hide();
		$("#link-full").show();
		$.cookie('content_type', 'short');
	}
	
	$("#content-active").slideToggle();
	$("#content-deactive").slideToggle();
	
}

