$(document).ready(function(){
    $("table.ext").hide();
    $("a.viewAll").click(function(){
        if($(this).attr("all")=="1") {
            $("table.ext").hide("fast");
            $(this).attr("all","0");
            $(this).html("Показать все услуги");
        } else {
            $("table.ext").show("fast");
            $(this).attr("all","1");
            $(this).html("Меньше услуг");
        }
        return false;
    });
    
    $("#subscrButton").click(function(){
    	$.ajax({
    	  url: "remote_call.php",
    	  type: "POST",
    	  dataType: "text",
    	  data: {
    	  	action:"subscribe",
    	  	email:$("#subscrField").val()
	  	},
    	
    	  complete: function() {
    	    //called when complete
    	  },
    	
    	  success: function(res) {
    	  	if(res == "success") {
    	    	$("#subResult").html("Спасибо! Вы подписались на нашу рассылку.");
    	    } else if(res == "exists") {
    	    	$("#subResult").html("Ваш адрес уже подписан на нашу рассылку.");
    	    } else if(res == "incorrect") {
    	    	$("#subResult").html("E-Mail некорректен. Для подписки необходимо ввести корректный E-Mail.");
    	    }
    	 },
    	
    	  error: function() {
    	    //called when there is an error
    	  }
    	});
    	
    	return false;
    });
    $("a.delete").click(function(){
    	$.ajax({
    	  url: "remote_call.php",
    	  type: "POST",
    	  dataType: "text",
    	  data: {
    	  action: "remove_bookmark",
    	  form_id: $(this).attr("form_id")
    	  },
    	
    	  complete: function() {
    	    //called when complete
    	  },
    	
    	  success: function(res) {
    	  	window.location.reload();
    	 },
    	
    	  error: function() {
    	    //called when there is an error
    	  }
    	});
    	
    	return false;
    });
    $("a.add").click(function(){
    	$.ajax({
    	  url: "remote_call.php",
    	  type: "POST",
    	  dataType: "text",
    	  data: {
    	  action: "add_bookmark",
    	  form_id: $(this).attr("form_id")
    	  },
    	
    	  complete: function() {
    	    //called when complete
    	  },
    	
    	  success: function(res) {
    	  	
    	    window.location.reload();
    	 },
    	
    	  error: function() {
    	    //called when there is an error
    	  }
    	});
    	
    	return false;
    });
});
