function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function Open(where){
	document.getElementById(where).style.display='block';
}
function Close(where){
	document.getElementById(where).style.display='none';
}
Shadowbox.init();

function validaForm2(){
	form = document.news;
	//Deixa erro em branco para cada operao

	err = '';

	//Verifica campo por campo, e pega o nome para o erro, e foca  o campo;

	if(form.Email.value == ''){
		err = 'Email';
		form.Email.focus();
		}
	if(err==''){
		form.submit();
	}else{//Se tiver erro ele informa o campo vazio
		alert('Campo em branco '+err+'');
		}
}


function validaForm(){
	form = document.associe;
	//Deixa erro em branco para cada operao

	err = '';

	//Verifica campo por campo, e pega o nome para o erro, e foca  o campo;

	if(form.Data_de_fundacao_da_Empresa.value == ''){
		err = 'Data_de_fundacao_da_Empresa';
		form.Data_de_fundacao_da_Empresa.focus();
		}
		


	if(form.CNPJ.value == ''){
		err = 'CNPJ';
		form.CNPJ.focus();
		}
		
		
	if(form.Estado.value == ''){
		err = 'Estado';
		form.Estado.focus();
		}
				
	if(form.Cidade.value == ''){
		err = 'Cidade';
		form.Cidade.focus();
		}


	if(form.CEP.value == ''){
		err = 'CEP';
		form.CEP.focus();
		}
		
	if(form.Bairro.value == ''){
		err = 'Bairro';
		form.Bairro.focus();
		}

		
	if(form.Endereco.value == ''){
		err = 'Endereco';
		form.Endereco.focus();
		}
		
	if(form.Razao_Social.value == ''){
		err = 'Razao_Social';
		form.Razao_Social.focus();
		}
	//Verifica se nao tem erro e envia

	if(err==''){
		form.submit();
	}else{//Se tiver erro ele informa o campo vazio
		alert('Campo em branco '+err+'');
		}

}
function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,'scrollbars=yes,width=550,height=600');
}


function Mascara(o,f)
{
	v_obj=o
	v_fun=f
	setTimeout("execmascara()",1)
}
function execmascara()
{
	v_obj.value=v_fun(v_obj.value)
}
function Data(v)
{
	v=v.replace(/\D/g,"") 
	v=v.replace(/(\d{2})(\d)/,"$1-$2") 
	v=v.replace(/(\d{2})(\d)/,"$1-$2") 
	return v
}	

function Telefone(v){
		v=v.replace(/\D/g,"")                            
		v=v.replace(/^(\d\d)(\d)/g,"($1) $2")
		v=v.replace(/(\d{4})(\d)/,"$1-$2")      
		return v
}
function Cep(v){
		v=v.replace(/D/g,"")                            
		v=v.replace(/^(\d{5})(\d)/,"$1-$2")
		return v
}

	window.onload = function()
	{
		CKEDITOR.replace( 'text',
	    {

	        //toolbar : 'Basic',
		    //forcePasteAsPlainText : true,
		    //entities_latin : false,
	        uiColor : '#B8D8BC',
		    height	: '120',
		    resize_enabled : false,
		    entities : false,
			forcePasteAsPlainText : true,
			//entities_latin : false,


			on :
	        {
	            instanceReady : function( ev )
	            {
					this.dataProcessor.writer.lineBreakChars = '';
		            /*this.dataProcessor.writer.setRules( 'p',
		                    {
		                        indent : false,
		                        breakBeforeOpen : false,
		                        breakAfterOpen : false,
		                        breakBeforeClose : false,
		                        breakAfterClose : false,
		                    });*/
				 }
	        },

	        toolbar : 
			[
				['Source','NewPage'],
		 		['SpellChecker'],
			 	['Undo','Redo'],
			 	['RemoveFormat'],
			 	['Bold','Italic','Underline','Strike'],
			 	['Link','Unlink'],
	    		['NumberedList','BulletedList'],
	    		['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
	    		['Maximize'],
			]

	    });
	};
function loadAssociate(companny,responsible,address,neighborhood,city,cep,tel,mail)
{
	var string = '<p class="empresas">';
	if(companny)
	{
		string += '<strong>' + companny + '</strong><br />';
	}
	if(responsible)
	{
		string += responsible + '<br />';
	}
	if(address)
	{
		string += 'Endereço: ' + address + '<br />';
	}
	if(neighborhood)
	{
		string += 'Bairro: ' + neighborhood + '<br />';
	}
	if(city)
	{
		string += 'Cidade Sede: ' + city + '<br />';
	}
	if(cep)
	{
		string += 'CEP: ' + cep + '<br />';
	}
	if(tel)
	{
		string += 'Telefone: ' + tel + '<br />';
	}
	if(mail)
	{
		string += 'E-mail: <a href="mailto:' + mail + '">' + mail + '</a>';
	}
	return document.write(string);
}
