
/*function tinyInit(){

	tinyMCE.init({
		// General options
		mode : "textareas",
		theme : "advanced",
		plugins : "youtube,safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
	
		// Theme options
		theme_advanced_buttons1 : "youtube,save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
		theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
		theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,
		
		relative_urls : false,
		file_browser_callback : "ezfilemanager",
	
		// Example content CSS (should be your site CSS)
		content_css : "css/content.css",
	
		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",
	
		// Replace values for the template plugin
		template_replace_values : {
			username : "Some User",
			staffid : "991234"
		},
	
		extended_valid_elements : "iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]"
		
	});

}*/

function ezfilemanager (field_name, url, type, win) {
//Change the var pluginPath to reflect your installation path
var PluginPath = "/public/cms/scripts/tiny_mce/plugins/ezfilemanager/ezfilemanager.php"; 
       if (PluginPath.indexOf("?") < 0) 
	   		{
            PluginPath = PluginPath + "?type=" + type;
       		}
       else {
            PluginPath = PluginPath + "&type=" + type;
       		}

       tinyMCE.activeEditor.windowManager.open({
           file : PluginPath,
           title : '',
           width : 650, 
           height : 440,
           resizable : "yes",
           scrollbars : "yes",
           inline : "yes", 
           close_previous : "no"
       		}, {
           window : win,
           input : field_name
       		});
       return false;
     }

function checkedAll(){
	
	if( $("#checkMaster").attr("checked") ){		
		$("input[type=checkbox]").attr("checked","checked");
	  }else{
		$("input[type=checkbox]").attr("checked","");	
	  }
	
}
jQuery.validator.addMethod("verificaCPF", function(value, element) {  
    value = value.replace('.','');  
    value = value.replace('.','');  
    cpf = value.replace('-','');  
    while(cpf.length < 11) cpf = "0"+ cpf;  
    var expReg = /^0+$|^1+$|^2+$|^3+$|^4+$|^5+$|^6+$|^7+$|^8+$|^9+$/;  
    var a = [];  
    var b = new Number;  
    var c = 11;  
    for (i=0; i<11; i++){  
        a[i] = cpf.charAt(i);  
        if (i < 9) b += (a[i] * --c);  
    }  
    if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }  
    b = 0;  
    c = 11;  
    for (y=0; y<10; y++) b += (a[y] * c--);  
    if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }  
    if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10]) || cpf.match(expReg)) return false;  
    return true;  
}, "Informe um CPF válido."); 

jQuery.validator.addMethod("dateBR", function(value, element) {  
        //contando chars  
       if(value.length!=10) return false;  
       // verificando data  
       var data        = value;  
       var dia         = data.substr(0,2);  
       var barra1      = data.substr(2,1);  
       var mes         = data.substr(3,2);  
       var barra2      = data.substr(5,1);  
      var ano         = data.substr(6,4);  
      if(data.length!=10||barra1!="/"||barra2!="/"||isNaN(dia)||isNaN(mes)||isNaN(ano)||dia>31||mes>12)return false;  
      if((mes==4||mes==6||mes==9||mes==11)&&dia==31)return false;  
      if(mes==2 && (dia>29||(dia==29&&ano%4!=0)))return false;  
      if(ano < 1900)return false;  
      return true;  
 }, "Informe uma data válida");  // Mensagem padrão   



/*
 *     24 - 08 - 2009
 */

//<img alt="pago" src="/public/images/flag.png">
//<img alt="não atendido" src="/public/images/flag_disable.png">
function setStatus( idIn , ck , tipo ){

    var img = "";

        if( ck == 1 ){
            img = "<img alt=\"pago\" src=\"/public/images/flag.png\" onclick=\"setStatus( '"+idIn+"' , 0 , '"+tipo+"' )\" >";
        }else{
            img = "<img alt=\"não atendido\" src=\"/public/images/flag_disable.png\" onclick=\"setStatus( '"+idIn+"' , 1 , '"+tipo+"' )\" >";
        }

    if( confirm("Deseja mudar o status de "+tipo+"?") ){
        $("#"+tipo+"_"+idIn).html("<img alt=\"pago\" src=\"/public/images/ajax-loader.gif\" >");
        $.post("http://www.revistamissoes.org.br/assinaturas/status/",
              {id:idIn,
               valor:ck,
               acao:tipo},
              function ( result ){

                   $("#"+tipo+"_"+idIn).html(img);
                   alert("Alterado com sucesso.");

              });

    }

}


