// JavaScript Document
jQuery.noConflict();
jQuery(function() {
	jQuery('.mask_date').mask('99/99/9999');
});

var Riva = {
	Proposicoes : {
		Comments : {
			View : function(id, page) 
			{
				jQuery.get("proposicoes.asset.php", {act:'view',id:id,page:page}, function(data) {
					commentbox = jQuery("#comment"+id);
					commentbox.html(data);
					commentbox.slideDown("slow");
				});
			},
			
			Form : function(id) 
			{
				jQuery('#proposituras_dialog').html('Carregando...');
				jQuery.get("proposicoes.asset.php", {act:'form',id:id}, function(data){
					jQuery('#proposituras_dialog').dialog({
						modal:true,
						width:300,
						height:450,
						title:'Comentar'
					});
					
					jQuery('#proposituras_dialog').html(data);
				});
				
			},
			
			TextNumDig : function()
			{
				var limite = 300;
				var atual  = jQuery('#texto').val().length;
				
				if(atual > limite) {
					jQuery('#texto').val(jQuery('#texto').val().substring(0, limite));
				}
				
				jQuery('#texto_limite').val(limite - jQuery('#texto').val().length);
			},
			
			Save : function() 
			{				
				var data = {
					act					: 'save',
					cp_proposituras_id 	: jQuery("#cp_proposituras_id").val(),
					nome  	 			: jQuery("#nome").val(),
					email 	 			: jQuery("#email").val(),
					telefone 			: jQuery("#telefone").val(),
					texto 	 			: jQuery("#texto").val()
				};
				
				jQuery.getJSON('proposicoes.asset.php', data, function(json) {
					if(json.response == true) {
						jQuery('#prop_form_msg').html(json.msg);
						jQuery('#prop_form_msg').show('slow');
					} else {
						jQuery('#prop_form_msg').html(json.msg);
						jQuery('#prop_form_msg').show('slow');
					}
				});
			}
		}
	}
};
