function alerta(title, msg){
	jAlert(msg, title, function(r) {});
}

/*POSTAR FORMULARIO*/
function postaForm(form, dest){

	//alert( jQuery(form).attr("action"));
	//alert(jQuery("input, textarea, select, checkbox, radio").serialize());
	//if (!vazios()){

				carregar(true);

				$.ajax({

				  type: jQuery(form).attr("method"), 
                  //scriptCharset: "ISO-8859-15",
				  url: jQuery(form).attr("action"), 
				  data: jQuery("input, textarea, select, checkbox, radio").serialize(),
				  dataType: "html",
                  beforeSend: function(xhr) {
                    //xhr.setRequestHeader("Accept-Charset","ISO-8859-15");
                    //xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded; charset=ISO-8859-15");
                  },
				  success: function(msg){ 

					carregar(false);

					jQuery(dest).html("");

					jQuery(dest).html(msg);

				  } ,

				  error: function(msg,txt){

					  carregar(false);
                      //alert(msg.responseText);
					  alert("[postagem]: erro na requisição.");

				  }

				});

	//}	

	return false;

}



/*  VERIFICA SE OS CAMPOS SETADOS COM empty ESTÃO VAZIOS  */

function vazios(){

	var err = "";

		

	jQuery(".formContainer .empty").each(function(){
		var id = jQuery(this).attr("id");
		var txt = jQuery(id).val();
		var err = "";
		alert(txt);
		if(jQuery(this).attr("type") == 'radio'){
			txt = jQuery(this).attr("checked");
			if ((txt == false) || (txt == undefined)){
				err = "Os campos obrigatórios estão vazios.\n";
			}
		}else{
			if (txt == ""){
				err = "Os campos obrigatórios estão vazios.\n";
			}
		}
	});

	

	if (err == ""){

		return false;	

	}else{

		alert(err);

		return true;

	}

}



/*CARREGANDO*/

function carregar(bol){

	if (bol){

		$(document.body).append("<div id='carregando'><img src=\"../imagens/ajax-loader.gif\" border=\"0\">Carregando...</div>");

		$("#carregando").fadeIn("slow");

	}else{

		$("#carregando").fadeOut("slow");

		$("#carregando").remove();

	}

}
/* banners em flash*/
jQuery(document).ready(function(){

    $(function() {

		$('a.superbanner_topo').media({ 

			autoplay:  true, 

			caption:   false, // supress caption text 

			width: 560, 

			height: 190,

			bgColor: 'transparent',

			flashVersion:  '9',

			attrs:{wmode: 'transparent'}

		}); 
        
       	$('a.banner_popup').media({ 
			autoplay:  true, 
			caption:   false, // supress caption text 
			bgColor: 'transparent',
			flashVersion:  '9',
			attrs:{wmode: 'transparent'}

		}); 
    });

});
/*ABRIR LINK*/

function abrirLink(str, dest){

	$(dest).html("<div id=\"carregando\"> Carregando... <img src=\"../imagens/ajax-loader.gif\" border=\"0\"></div>");

	$(dest).load(str,{},function(){

	});

}

/*ANIMA RESULTADO ENQUETE*/
function animateResults(){
  $("#poll-results div").each(function(){
      var percentage = $(this).next().text();
      $(this).css({width: "0%"}).animate({
				width: percentage}, 'slow');
  });
}

/*Modal simples*/
jQuery.fn.toolList = function(options){
	var jQuerythis = jQuery(this);
	
	var defaults = {
		link: ''
	};

	var opts = jQuery.extend(defaults, options);
	
	var link = defaults.link;

	//init();
	jQuerythis.click(function(evt){ abreJanela(evt); });
    
    function init(){
    }
    
    function abreJanela(evt){
            if($("#toolList").length == 0){
                jQuery("body").prepend("<div id=\"toolList\"></div>");
                jQuery("#toolList").css("border-top","1px solid #000");
                jQuery("#toolList").css("border-left","1px solid #000");
                jQuery("#toolList").css("border-bottom","2px solid #000");
                jQuery("#toolList").css("border-right","2px solid #000");
                jQuery("#toolList").css("background-color","#FFF");        
                jQuery("#toolList").css("position","absolute");
                jQuery("#toolList").css("top",evt.pageY);
                jQuery("#toolList").css("left",evt.pageX);
                //jQuery("#toolList").mouseleave(function(){ jQuery(this).remove(); });
                jQuery("#toolList").css("z-index","999999");
                abrirLink(defaults.link,"#toolList");
            }
    }
 }
