$(document).ready(function(event){ 					   
	/*Carrega todos os Formatadores ===================================================================
	setInterval("copia_rodape()", 250);
	setTimeout("window.top.formatar_banner()", 5);
	setTimeout("window.top.formata_menu_principal()", 5);
	setTimeout("window.top.processador_tema()", 5);						   
	setTimeout("display_links()", 5);
	
	//Caso Especial de Banner Profisional ===========================================================
	if(window.top.document.getElementById('usar_banner_profissional').checked == true){
	var tipo = window.top.document.getElementById('tipo_banner').value;
	var url = window.top.document.getElementById('url_banner').value;
	setTimeout('window.top.inserir_banner_profissional("'+tipo+'","'+url+'")', 5);
	}
	//================================================================================================*/


});


function editor_menu_principal(cor_fundo,cor_borda,cor_fonte,cor_submenu,tipo_fonte,tamanho_fonte){	
	//Menu principal =================================================================================
	//$("#div_menu_principal li").css({"background-color" : "#CCCCCC"});
	$("#div_menu_principal").css({"background-color" : cor_fundo});
	$("#div_menu_principal").css({"border-color" : cor_borda});
	$("#div_menu_principal li div").css({"border-color" : cor_borda});
	$("#div_submenu").css({"border-color" : cor_borda});
	$("#div_menu_principal li").css({"color" : cor_fonte});
	$("#div_menu_principal li a").css({"color" : cor_fonte, "text-decoration" : "none"});
	$(".div_submenu").css({"background" : cor_submenu});
	$("#div_menu_principal li").css({"font-family" : tipo_fonte});
	$("#div_menu_principal li a").css({"font-family" : tipo_fonte});
	$("#div_menu_principal li").css({"font-size" : tamanho_fonte+'px'});
	$("#div_menu_principal li a").css({"font-size" : tamanho_fonte+'px'});
	//Outros apps =====================================================================================
	$(".btn_detalhes , #div_busca_rodape").css({"background-color" : cor_fundo , "color" : cor_fonte});
	$("#div_busca_rodape .texto_busca").css({"color" : cor_fonte});

}

//Renomera ===================================================================
window.top.document.getElementById('link1').onkeyup = renomear_menu_principal;
window.top.document.getElementById('link2').onkeyup = renomear_menu_principal;
window.top.document.getElementById('link3').onkeyup = renomear_menu_principal;
window.top.document.getElementById('link4').onkeyup = renomear_menu_principal;
window.top.document.getElementById('link5').onkeyup = renomear_menu_principal;
window.top.document.getElementById('link6').onkeyup = renomear_menu_principal;
window.top.document.getElementById('link7').onkeyup = renomear_menu_principal;
window.top.document.getElementById('link8').onkeyup = renomear_menu_principal;
window.top.document.getElementById('link9').onkeyup = renomear_menu_principal;
window.top.document.getElementById('link10').onkeyup = renomear_menu_principal;
window.top.document.getElementById('link11').onkeyup = renomear_menu_principal;

function renomear_menu_principal(){
	//Link1 =====================================================================
	if(window.top.document.getElementById('link1').value != ''){	
		var link1 = window.top.document.getElementById('link1').value	
	} else {
		var link1 = '';		
	}
	
	//Link2 =====================================================================
	if(window.top.document.getElementById('link2').value != ''){	
		var link2 = window.top.document.getElementById('link2').value;	
	} else {
		var link2 = '';		
	}
	
	//Link3 =====================================================================
	if(window.top.document.getElementById('link3').value != ''){	
		var link3 = window.top.document.getElementById('link3').value;	
	} else {
		var link3 = '';		
	}
	
	//Link3 =====================================================================
	if(window.top.document.getElementById('link4').value != ''){	
		var link4 = window.top.document.getElementById('link4').value;	
	} else {
		var link4 = '';		
	}
	
	//Link4 =====================================================================
	if(window.top.document.getElementById('link5').value != ''){	
		var link5 = window.top.document.getElementById('link5').value;	
	} else {
	var link5 = '';		
	}
	
	//Link5 =====================================================================
	if(window.top.document.getElementById('link6').value != ''){	
		var link6 = window.top.document.getElementById('link6').value;	
	} else {
		var link6 = '';		
	}
	
	//Link6 =====================================================================
	if(window.top.document.getElementById('link7').value != ''){	
		var link7 = window.top.document.getElementById('link7').value;	
	} else {
		var link7 = '';		
	}
	
	//Link7 =====================================================================
	if(window.top.document.getElementById('link8').value != ''){	
		var link8 = window.top.document.getElementById('link8').value;	
	} else {
		var link8 = '';		
	}
	
	//Link8 =====================================================================
	if(window.top.document.getElementById('link9').value != ''){	
		var link9 = window.top.document.getElementById('link9').value;	
	} else {
		var link9 = '';		
	}
	
	//Link10 =====================================================================
	if(window.top.document.getElementById('link10').value != ''){	
		var link10 = window.top.document.getElementById('link10').value;	
	} else {
		var link10 = '';		
	}
	
	//Link11 =====================================================================
	if(window.top.document.getElementById('link11').value != ''){	
		var link11 = window.top.document.getElementById('link11').value;	
	} else {
		var link11 = '';		
	}
	
	//Escreve ====================================================================
	$("#li1 .div").text(link1);
	$("#li2 .div").text(link2);
	$("#li3 .div").text(link3);
	$("#li4 .div").text(link4);
	$("#li5 .div").text(link5);
	$("#li6 .div").text(link6);
	$("#li7 .div").text(link7);
	$("#li8 .div").text(link8);
	$("#li9 .div").text(link9);
	$("#li10 .div").text(link10);
	$("#li11 .div").text(link11);

}


//Display Links Menu =========================================================
window.top.document.getElementById('display_link1').onclick = display_links;
window.top.document.getElementById('display_link2').onclick = display_links;
window.top.document.getElementById('display_link3').onclick = display_links;
window.top.document.getElementById('display_link4').onclick = display_links;
window.top.document.getElementById('display_link5').onclick = display_links;
window.top.document.getElementById('display_link6').onclick = display_links;
window.top.document.getElementById('display_link7').onclick = display_links;
window.top.document.getElementById('display_link8').onclick = display_links;
window.top.document.getElementById('display_link9').onclick = display_links;
window.top.document.getElementById('display_link10').onclick = display_links;
window.top.document.getElementById('display_link11').onclick = display_links;

function display_links(){
//============================================================================
if(window.top.document.getElementById('display_link1').checked == false){
$("#li1").fadeOut('slow');
} else {
$("#li1").fadeIn('slow');
}

//============================================================================
if(window.top.document.getElementById('display_link2').checked == false){
$("#li2").fadeOut('slow');
} else {
$("#li2").fadeIn('slow');
}
//============================================================================
if(window.top.document.getElementById('display_link3').checked == false){
$("#li3").fadeOut('slow');
} else {
$("#li3").fadeIn('slow');
}
//============================================================================
if(window.top.document.getElementById('display_link4').checked == false){
$("#li4").fadeOut('slow');
} else {
$("#li4").fadeIn('slow');
}
//============================================================================
if(window.top.document.getElementById('display_link5').checked == false){
$("#li5").fadeOut('slow');
} else {
$("#li5").fadeIn('slow');
}
//============================================================================
if(window.top.document.getElementById('display_link6').checked == false){
$("#li6").fadeOut('slow');
} else {
$("#li6").fadeIn('slow');
}
//============================================================================
if(window.top.document.getElementById('display_link7').checked == false){
$("#li7").fadeOut('slow');
} else {
$("#li7").fadeIn('slow');
}
//============================================================================
if(window.top.document.getElementById('display_link8').checked == false){
$("#li8").fadeOut('slow');
} else {
$("#li8").fadeIn('slow');
}
//============================================================================
if(window.top.document.getElementById('display_link9').checked == false){
$("#li9").fadeOut('slow');
} else {
$("#li9").fadeIn('slow');
}
//============================================================================
if(window.top.document.getElementById('display_link10').checked == false){
$("#li10").fadeOut('slow');
} else {
$("#li10").fadeIn('slow');
}
//============================================================================
if(window.top.document.getElementById('display_link11').checked == false){
$("#li11").fadeOut('slow');
} else {
$("#li11").fadeIn('slow');
}

}

//Display recursos laterais ==========================================================
window.top.document.getElementById('display_lado1').onclick = display_recursos_laterais;
window.top.document.getElementById('display_recurso_lateral1').onclick = display_recursos_laterais;
window.top.document.getElementById('display_recurso_lateral2').onclick = display_recursos_laterais;
window.top.document.getElementById('display_recurso_lateral3').onclick = display_recursos_laterais;
window.top.document.getElementById('display_recurso_lateral4').onclick = display_recursos_laterais;
//============================================================================
function display_recursos_laterais(){
	//Displa recursos laterias ===================================================
	if(window.top.document.getElementById('display_lado1').checked == false){
		$("#div_lado1").slideUp('normal', function(){
		document.getElementById('div_lado1').style.display = 'none';										  										
	});	
	
	} else {	
		$("#div_lado1").fadeIn('normal', function(){
		document.getElementById('div_lado1').style.display = 'block';			
	});		
	
	}
	//============================================================================
	if(window.top.document.getElementById('display_recurso_lateral1').checked == false){
		$("#div_lado_recurso1").slideUp('normal');		
	} else {
		$("#div_lado_recurso1").show('normal');		
	}
	//============================================================================
	if(window.top.document.getElementById('display_recurso_lateral2').checked == false){
		$("#div_lado_recurso2").slideUp('normal');		
	} else {
		$("#div_lado_recurso2").show('normal');		
	}
	//============================================================================
	if(window.top.document.getElementById('display_recurso_lateral3').checked == false){
		$("#div_lado_recurso3").slideUp('normal');		
	} else {
		$("#div_lado_recurso3").show('normal');		
	}
	//============================================================================
	if(window.top.document.getElementById('display_recurso_lateral4').checked == false){
		$("#div_lado_recurso4").slideUp('normal');		
	} else {
		$("#div_lado_recurso4").show('normal');		
	}

}

//Renomear recursos Laterais ================================================
window.top.document.getElementById('nome_lado_recurso1').onkeyup = renomear_recursos_laterais;
window.top.document.getElementById('nome_lado_recurso2').onkeyup = renomear_recursos_laterais;
window.top.document.getElementById('nome_lado_recurso3').onkeyup = renomear_recursos_laterais;
window.top.document.getElementById('nome_lado_recurso4').onkeyup = renomear_recursos_laterais;

//===========================================================================
function renomear_recursos_laterais(){
var nome_dep1 = window.top.document.getElementById('nome_lado_recurso1').value;
var nome_dep2 = window.top.document.getElementById('nome_lado_recurso2').value;
var nome_dep3 = window.top.document.getElementById('nome_lado_recurso3').value;

//===========================================================================
$("#nome_lado1").text(nome_dep1);
$("#nome_lado2").text(nome_dep2);
$("#nome_lado3").text(nome_dep3);

}

//Formatar modulos laterais ================================================
function formatar_modulos_lado1(){
	var cor_modulos = window.top.document.getElementById('cor_fundo_modulos_lado1').value;
	var cor_fonte_modulos = window.top.document.getElementById('cor_fonte_modulos_lado1').value;
	//==========================================================================
	$(".divs_laterais .tables_lado_site").css({"border" : "1px solid "+cor_modulos});
	$(".divs_laterais .tables_lado_site .td").css({"background" : cor_modulos});
	$(".divs_laterais .tables_lado_site .td").css({"color" : cor_fonte_modulos});
	$(".divs_laterais .table_busca").css({"border-color" : cor_modulos});
	$(".divs_laterais .bnt_busca").css({"background" : cor_modulos, "color" : cor_fonte_modulos});
	
	//Função para outros templates ==============================================
	//Tp3 =======================================================================
	$('.box_lateral1').css({"background" : cor_modulos});
	$('.box_lateral1 a').css({"color" : cor_fonte_modulos});
	$('.titulo_news').css({"color" : cor_fonte_modulos});
	$('.table_parceiros').css({"background" : cor_modulos , "color" : cor_fonte_modulos , "border-color" : cor_modulos});
	
	//Tp4 =======================================================================
	$('.table_busca').css({"background" : cor_modulos});
	$('.tables_lateral').css({"border" : "1px solid "+cor_modulos});
	$('.tables_lateral .cab , .ul_categoria_produtos a').css({"background-color" : cor_modulos , "color" : cor_fonte_modulos});
	$(".div_busca_lado").css({"background-color" : cor_modulos , "border-color" : cor_modulos});
	
	//Tp5 =======================================================================
	$('.tbl_menu_lateral2 , .tbl_menu_lateral2 .td , .tbl_menu_lateral2 ul , .td_menu_news2').css({"background" : cor_modulos});
	$('.tbl_menu_lateral2 .td , .tbl_menu_lateral2 a').css({"color" : cor_fonte_modulos});
	
}




//Formata Modulos Index =====================================================
function formatar_modulos_index(){
	var cor_modulo = window.top. document.getElementById('cor_modulo_index').value;	
	var cor_fonte_modulo = window.top. document.getElementById('cor_fonte_modulo_index').value;	
	//=======================================================================
	$(".div_destaques_principais").css({"border-color" : cor_modulo});
	$(".cab_destaques").css({"background-color" : cor_modulo, "color" : cor_fonte_modulo, "border-color" : cor_modulo});
	$(".div_recursos_index").css({"border-color" : cor_modulo});
	$(".cab_recurso_index").css({"background-color" : cor_modulo, "color" : cor_fonte_modulo, "border-color" : cor_modulo});
	$(".links_titulo_modulos_index").css({"color" : cor_fonte_modulo});
	$(".h_titulo_destaques").css({"color" : cor_fonte_modulo});
	
	//Tp4 ===================================================================
	$(".table_conteudos").css({"border-color" : cor_modulo});
	$(".table_conteudos .cab").css({"background-color" : cor_modulo , "color" : cor_fonte_modulo});
	// #blocoDestaques div.paginas a//
	
	//Tp5 ===================================================================
	$(".bnt_link .span , .mini_bnt_link .span").css({"background-color" : cor_modulo});
	$(".tables_estruturas .cab").css({"background-color" : cor_modulo , "color" : cor_fonte_modulo});
	$('.bnt_link, .mini_bnt_link').css({"color" : cor_fonte_modulo});
	$(".tables_estruturas").css({"border-color" : cor_modulo});
	$(".ofertas_titulo").css({"color" : cor_modulo});
	$('.titulo_categorias a').css({"color" : cor_fonte_modulo});
};
	
//Renomear Estrutura do Site ================================================
window.top.document.getElementById('nome_modulo_index1').onkeyup = renomear_modulos_index;
window.top.document.getElementById('nome_modulo_index2').onkeyup = renomear_modulos_index;
window.top.document.getElementById('nome_modulo_index3').onkeyup = renomear_modulos_index;
window.top.document.getElementById('nome_modulo_index4').onkeyup = renomear_modulos_index;
window.top.document.getElementById('nome_modulo_index5').onkeyup = renomear_modulos_index;
window.top.document.getElementById('nome_modulo_index6').onkeyup = renomear_modulos_index;
	
function renomear_modulos_index(){	
	var modulos1 = window.top.document.getElementById('nome_modulo_index1').value;
	var modulos2 = window.top.document.getElementById('nome_modulo_index2').value;
	var modulos3 = window.top.document.getElementById('nome_modulo_index3').value;
	var modulos4 = window.top.document.getElementById('nome_modulo_index4').value;
	var modulos5 = window.top.document.getElementById('nome_modulo_index5').value;
	var modulos6 = window.top.document.getElementById('nome_modulo_index6').value;
	
	//===========================================================================
	$('#nome_modulo_index1').html(modulos1);
	$('#nome_modulo_index2').html(modulos2);
	$('#nome_modulo_index3').html(modulos3);
	$('#nome_modulo_index4').html(modulos4);
	$('#nome_modulo_index5').html(modulos5);
	$('#nome_modulo_index6').html(modulos6);

}

//Troca a Estrutura da Pagina Inicial =======================================
function troca_estrutura(estrutura,protocolo){
	var status = Math.random();
	var url = estrutura;
	var largura_corpo = window.top.document.getElementById('largura_corpo').value;
	$.get(url, {status : status, p : protocolo, largura_corpo : largura_corpo}, function(html){
		document.getElementById('estrutura_index').innerHTML = html;		
		formatar_modulos_lado1();
		formatar_modulos_index();
	});

}

//Copia conteudo rodape =====================================================
function copia_rodape(){
var cor_fundo_rodape = window.top.document.getElementById('cor_fundo_rodape').value;
var cor_fonte_rodape = window.top.document.getElementById('cor_fonte_rodape').value;
var tipo_fonte_rodape = window.top.document.getElementById('tipo_fonte_rodape').value;
var tamanho_fonte_rodape = window.top.document.getElementById('tamanho_fonte_rodape').value;
var alinhamento_rodape = window.top.document.getElementById('alinhamento_rodape').value;
//===========================================================================
$("#div_rodape a").css({"color":cor_fonte_rodape});
document.getElementById('div_rodape').innerHTML = window.top.win_rodape.document.body.innerHTML;
document.getElementById('div_rodape').style.background = cor_fundo_rodape;
document.getElementById('div_rodape').style.color = cor_fonte_rodape;
document.getElementById('div_rodape').style.fontFamily = tipo_fonte_rodape;
document.getElementById('div_rodape').style.fontSize = tamanho_fonte_rodape;
document.getElementById('div_rodape').style.textAlign = alinhamento_rodape;
$('.div_master_rodape').css({"background" : cor_fundo_rodape});

}




