var expansivo_usando = false;
var expansivo_usando_novo = false;
var tempoExpirar = new Date();
var browser = navigator.appName;
var arr_permite_script = new Array();
arr_permite_script["0"] = 1;
arr_permite_script["meucook_meuperfil_dados.php"] = 1;
arr_permite_script["frame_meuperfil_dados.php"] = 1;
arr_permite_script["cadastro_completo.php"] =	1;
arr_permite_script["comunidade_receita_privada.php"] =	1;

var tp_buscag = new Array();
tp_buscag[0] = "";
tp_buscag[1] = "cybercook.terra.com.br/ver_dica";
tp_buscag[2] = "cybercook.terra.com.br/culinaria";
tp_buscag[3] = '"cybercook.terra.com.br/receita-de" -"na-comunidade.html"';
tp_buscag[4] = '"na-comunidade.html"';
tp_buscag[5] = "";

var arr_busca_topo = new Array();
arr_busca_topo[1] = new Array();
arr_busca_topo[1]['tipo'] = 'radio';
arr_busca_topo[1]['html'] = '' +
'						<form action="result.php" method="get" name="fBuscaGoogle" onSubmit="return manda_busca_google();" id="cse-search-box" style="margin: 0px; padding:0px;">\n' +
'							<input type="hidden" name="tp_busca_g" value="" />\n' +
'							<input type="hidden" name="cx" value="partner-pub-7443276122216115:suspy9-tyq1" />\n' +
'							<input type="hidden" name="cof" value="FORID:9" />\n' +
'							<input type="hidden" name="ie" value="ISO-8859-1" />\n' +
'							<input type="text" name="q" size="31" style="height:30px; width:280;font-size:16px; font-weight: bolder; vertical-align: middle; padding: 5px; float:left;" />\n' +
'							<input type="submit" name="sa" value="BUSCAR" class="botaovermelho" style="width: 80px; height: 30px; font-size: 14px; margin-left: 10px; margin-bottom: 10px;" />\n' +
'							<br />\n' +
'							<input name="tp_buscag" type="radio" class="semborda" id="tipo_busca_g1" value="" checked="checked" />\n' +
'							<label for="tipo_busca_g1" class="texto10">Todo o site</label>\n' +
'							<input type="radio" name="tp_buscag" class="semborda" id="tipo_busca_g2" value="cybercook.terra.com.br/ver_dica" />\n' +
'							<label for="tipo_busca_g2" class="texto10">Dicas</label>\n' +
'							<input type="radio" name="tp_buscag" class="semborda" id="tipo_busca_g3" value="cybercook.terra.com.br/culinaria" />\n' +
'							<label for="tipo_busca_g3" class="texto10">Mat&eacute;rias</label>\n' +
'							<input type="radio" name="tp_buscag" class="semborda" id="tipo_busca_g4" value="&quot;cybercook.terra.com.br/receita-de&quot; -&quot;na-comunidade.html&quot;" />\n' +
'							<label for="tipo_busca_g4" class="texto10">Acervo</label>\n' +
'							<input type="radio" name="tp_buscag" class="semborda" id="tipo_busca_g5" value="&quot;na-comunidade.html&quot;" />\n' +
'							<label for="tipo_busca_g5" class="texto10">Comunidade</label>\n' +
'							<input type="radio" name="tp_buscag" class="semborda" id="tipo_busca_g6" value="" />\n' +
'							<label for="tipo_busca_g6" class="texto10">Produtos</label>\n' +
'						</form>\n';
arr_busca_topo[0] = new Array();
arr_busca_topo[0]['tipo'] = 'aba';
arr_busca_topo[0]['html'] = '' +
'						<ul id="tab-busca">\n' +
'							<li class="ativo" id="li-busca-google-aba-0"><a href="javascript: void(0);" onClick="muda_busca_google_aba(0);">Todo o site</a></li>\n' +
'							<li id="li-busca-google-aba-1"><a href="javascript: void(0);" onClick="muda_busca_google_aba(1);">Dicas</a></li>\n' +
'							<li id="li-busca-google-aba-2"><a href="javascript: void(0);" onClick="muda_busca_google_aba(2);">Mat&eacute;rias</a></li>\n' +
'							<li id="li-busca-google-aba-3"><a href="javascript: void(0);" onClick="muda_busca_google_aba(3);">Acervo</a></li>\n' +
'							<li id="li-busca-google-aba-4"><a href="javascript: void(0);" onClick="muda_busca_google_aba(4);">Comunidade</a></li>\n' +
'							<li id="li-busca-google-aba-5"><a href="javascript: void(0);" onClick="muda_busca_google_aba(5);">Produtos</a></li>\n' +
'						</ul>\n' +
'						<div class="clear"></div>\n' +
'						<div style="background: #FFF; padding: 10px 20px 0px 20px; border: 1px SOLID  #D1D1D1;">\n' +
'							<form action="result.php" method="get" name="fBuscaGoogle" onSubmit="return manda_busca_google_aba();" id="cse-search-box" style="margin: 0px; padding:0px;">\n' +
'								<input type="hidden" name="tp_buscag" value="0" />\n' +
'								<input type="hidden" name="tp_busca_g" value="" />\n' +
'								<input type="hidden" name="cx" value="partner-pub-7443276122216115:suspy9-tyq1" />\n' +
'								<input type="hidden" name="cof" value="FORID:9" />\n' +
'								<input type="hidden" name="ie" value="ISO-8859-1" />\n' +
'								<input type="text" name="q" size="31" style="height:30px; width:280;font-size:16px; font-weight: bolder; vertical-align: middle; padding: 5px; float:left;" />\n' +
'								<input type="submit" name="sa" value="BUSCAR" class="botaovermelho" style="width: 80px; height: 30px; font-size: 14px; margin-left: 10px; margin-bottom: 10px;" />\n' +
'								<br />\n' +
'							</form>\n' +
'						</div>\n';



/* 
var bodyalpha_texto_favorito = '';
var bodyalpha_texto_comida_boa = '<form name="comida_boa_indica" action="frame_indica_comida_boa.php" method="post" target="server">' +
	'<input type="hidden" name="acao" value="indicar_comida_boa" />' +
	'<input type="hidden" name="cod_cadastro_cooknauta" value="0" />' +
	'<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">' +
	'<tr height="1"><td align="center">&nbsp;</td></tr>' +
	'<tr height="1"><td align="center"><h2><strong>Este blog tem comida da boa</strong></h2></td></tr>' +
	'<tr height="1"><td>indicar este blog para a &aacute;rea "aqui tem comida da boa"</td></tr>' +
	'<tr height="1"><td align="center">&nbsp;</td></tr>' +
	'<tr><td valign="top">' +
	'<strong>coment&aacute;rio:</strong><br />' +
	'<span style="font-size: 9px;">(n&atilde;o &eacute; obrigat&oacute;rio)</span><br />' +
	'<textarea name="comentario" style="width: 100%; height: 170px";></textarea>' +
	'</td></tr>' +
	'<tr height="1"><td align="center">&nbsp;</td></tr>' +
	'<tr height="1"><td align="center"><input type="submit" value="indicar este blog para comida boa"/></td></tr>' +
	'<tr height="1"><td align="center">&nbsp;</td></tr>' +
	'<tr height="1"><td align="right"><a href="javascript: comida_boa_indicacao(1);" onclick="this.blur();">cancelar</a></td></tr>' +
	'</table>' +
	'</form>'
*/

function safari () {
	var browser_safari = (navigator.appVersion.indexOf("AppleWebKit") > -1 ? true : false);
	var cookies_safari = (getCookie("safari") == "S" ? true : false);
	return (!cookies_safari && browser_safari);
}

function logado_js () {
	if (document.cookie.indexOf("usercodi") != -1) {
		return (getCookie("usercodi") > 0);
	}
	return false;
}


function shuffle(o){
	for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
	return o;
}


function getCookie( name ) {
	var start = document.cookie.indexOf(name + "=");
	var len = start + name.length + 1;
	if ((!start) && (name != document.cookie.substring(0 , name.length))) {
		return null;
	}
	if (start == -1) {
		return null;
	}
	var end = document.cookie.indexOf(";" , len);
	if (end == -1) {
		end = document.cookie.length;
	}
	return unescape(document.cookie.substring(len , end));
}

function setcookie (name , value , expires , path , domain , secure) {
	unsetcookie (name , path , domain);
	var today = new Date();
	today.setTime(today.getTime());
	if (expires)	{
		//	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date(today.getTime() + expires);
	document.cookie = name + "=" + escape(value) +
	(expires ? ";expires=" + expires_date.toGMTString() : "") +
	(path ? ";path=" + path : "") +
	(domain ? ";domain=" + domain : "") +
	(secure ? ";secure" : "");
}

function unsetcookie (name , path , domain) {
	if (getCookie(name)) {
		document.cookie = name + "=" +
		((path) ? ";path=" + path : "") +
		((domain) ? ";domain=" + domain : "" ) +
		";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	}
}

function obj(oid) {
	if (document.layers) {
		return document.layers(oid);
	}
	else if (document.all) {
		return document.all(oid);
	}
	else {
		return document.getElementById(oid);
	}
}

function sky_exp(){
	try {
		skyexp = obj("senac");
		skyexp_p = obj("senac_p");
	}
	catch(e) {
	}
}

function comida_boa_muda_data (tipo) {
	var min_dia = 17;
	var min_mes = 6;
	var min_ano = 2008;
	var temp_data = new Date();
	var ano = temp_data.getFullYear();
	var mes = temp_data.getMonth() + 1;
	var dia = temp_data.getDate();
	oid_y = "data-y-" + tipo;
	oid_m = "data-m-" + tipo;
	oid_d = "data-d-" + tipo;
	dy = document.getElementById(oid_y).value;
	dm = document.getElementById(oid_m).value;
	dd = document.getElementById(oid_d).value;
	ty = parseInt(dy);
	td = (dd == "08" ? 8 : (dd == "09" ? 9 : parseInt(dd)));
	tm = (dm == "08" ? 8 : (dm == "09" ? 9 : parseInt(dm)));
	var arr_mes = new Array();
	arr_mes["01"] = 31;
	arr_mes["02"] = 28 + ((ty % 4) == 0);
	arr_mes["03"] = 31;
	arr_mes["04"] = 30;
	arr_mes["05"] = 31;
	arr_mes["06"] = 30;
	arr_mes["07"] = 31;
	arr_mes["08"] = 31;
	arr_mes["09"] = 30;
	arr_mes["10"] = 31;
	arr_mes["11"] = 30;
	arr_mes["12"] = 31;

	if (dy.length != 4 || dm.length != 2 || dd.length != 2) {
		alert("a data deve estar no formato dd/mm/aaaa, ex.: 02/04/2008");
		return false;
	}
	if (ty < 2008 || ty > ano) {
		var texto = "ano inválido";
		if (ty < 2008) {
			texto += ": esta página entrou em 2008 e esse é o ano mínimo";
		}
		else {
			texto += ": ainda não chegamos em " + ty;
		}
		alert(texto);
		return false;
	}
	if (arr_mes[dm] === null || arr_mes[dm] === undefined || arr_mes[dm] === false) {
		alert("mês inválido");
		return false;
	}
	if (td > arr_mes[dm]) {
		alert("dia inválido");
		return false;
	}
	if (ty == ano) {
		if (tm > mes || (tm == mes && td > dia)) {
			alert("data inválida. a data não deve ser maior que a data atual");
			return false;
		}
	}
	if (ty == min_ano) {
		if (tm < min_mes || (tm == min_mes && td < min_dia)) {
			alert("data inválida. a data não deve ser menor que " + (min_dia < 10 ? "0" : "") + min_dia + "/" + (min_mes < 10 ? "0" : "") + min_mes + "/" + min_ano);
			return false;
		}
	}
	dt = dy + "-" + dm + "-" + dd;
	document.comida_boa_data.data.value = dt;
	document.comida_boa_data.submit();
}

/*
function comida_boa_muda_data (data_ym) {
	document.getElementById("comida-boa-destaques").innerHTML = '<center><strong class="vermelho">aguarde...</strong></center>';
	document.getElementById("server").src = "frame-comida-da-boa.php?acao=pega_destaques&data_ym=" + data_ym;
}
*/

function manda (acao) {
	agora = new Date();
	document.geral.nocache.value = agora;
	document.geral.action = acao;
	document.geral.submit();
}

function expansivo_vai(j_objid,j_width,j_height,j_flag) {
	if (document.getElementById(j_objid) !== null) {
		var obj = document.getElementbyId(j_objid).style;
		if (obj.clip.left) {
			obj.clip.top = 0;
			obj.clip.right = j_width;
			obj.clip.bottom = j_height;
			obj.clip.left = 0;
		}
		obj.clip = 'rect(0 ' + j_width + ' ' + j_height + ' 0)';
		expansivo_usando = false;
	}
}

function expansivo_muda (j_objid,j_width,j_height,j_flag) {
	if (!expansivo_usando) {
		expansivo_usando = true;
		if (j_flag == true) {
			expansivo_vai(j_objid,j_width,j_height,j_flag);
		}
		else {
			expansivo_vai(j_objid,j_width,j_height,j_flag);
		}
		expansivo_usando = false;
	}
}

function expansivo_muda_timeout (j_objid,j_width,j_height,j_flag) {
	if (j_flag == true) {
		setTimeout("expansivo_vai('"+j_objid+"' , "+j_width+" , "+j_height+" , "+j_flag+")" , 2000);
	}
	else {
		expansivo_vai(j_objid,j_width,j_height,j_flag);
	}
}

function expansivo_vai_novo (j_objid , j_top , j_right , j_botton , j_left , j_flag) {
	if (document.getElementById(j_objid) !== null) {
		var obj = document.getElementById(j_objid).style;
		if (obj.clip.left) {
			obj.clip.top = j_top;
			obj.clip.right = j_right;
			obj.clip.bottom = j_botton;
			obj.clip.left = j_left;
		}
		obj.clip = 'rect(' + j_top + 'px ' + j_right + 'px ' + j_botton + 'px ' + j_left + 'px)';
		expansivo_usando_novo = false;
	}
}

function expansivo_muda_novo (j_objid , j_top , j_right , j_botton , j_left , j_flag) {
	if (!expansivo_usando_novo) {
		expansivo_usando_novo = true;
		if (j_flag == true) {
			expansivo_vai_novo(j_objid , j_top , j_right , j_botton , j_left , j_flag);
		}
		else {
			expansivo_vai_novo(j_objid , j_top , j_right , j_botton , j_left , j_flag);
		}
		expansivo_usando_novo = false;
	}
}

function expansivo_muda_timeout_novo (j_objid , j_top , j_right , j_botton , j_left , j_flag) {
	if (j_flag == true) {
		setTimeout("expansivo_vai_novo('" + j_objid + "' , " + j_top + " , " + j_right + " , " + j_botton + " , " + j_left + " , " + j_flag + ")" , 2000);
	}
	else {
		expansivo_vai_novo(j_objid , j_top , j_right , j_botton , j_left , j_flag);
	}
}

function sh_google_frames(val) { // sh = show & hidden | mostra ou apaga o iframe do google abaixo do e-commerce
	iframes = document.getElementsByTagName("iframe");
	for(var i = 0 ; i < iframes.length ; i++) {
		var vid = iframes[i].id.substr(0 , 6);
		var vnm = iframes[i].name.substr(0 , 6);
		vid = vid.toUpperCase();
		vnm = vnm.toUpperCase();
		vsr = iframes[i].src.toUpperCase();
		if (vid == "GOOGLE" || vnm == "GOOGLE") {
			if (vsr.match("RECEITA_SKY_LINKS")) {
				iframes[i].style.visibility = val;
			}
		}
	}
}

function tam_10 () {
	document.styleSheets.estilo.addRule('#meuccook .texto11','font-size: 10px;');
	document.styleSheets.estilo.addRule('#meuccook .texto11b','font-size: 10px;');
	document.styleSheets.estilo.addRule('#cont_total td','font-size: 10px;');
}

function tam_12 () {
	document.styleSheets.estilo.addRule('#meuccook .texto11','font-size: 12px;');
	document.styleSheets.estilo.addRule('#meuccook .texto11b','font-size: 12px;');
	document.styleSheets.estilo.addRule('#cont_total td','font-size: 12px;');
}

function tam_14 () {
	document.styleSheets.estilo.addRule('#meuccook .texto11','font-size: 14px;');
	document.styleSheets.estilo.addRule('#meuccook .texto11b','font-size: 14px;');
	document.styleSheets.estilo.addRule('#cont_total td','font-size: 14px;');
}

function verifica_safari () {
	/*
	if (safari()) {
		setcookie ("safari" , "S" , (tempoExpirar.getTime() + (3600 * 24)) , "/" , ".terra.com.br");
		obj_ts = document.getElementById("tela_safari");
		obj_ts.style.top = "100px";
		obj_ts.style.left = ((document.width - 600) / 2) + "px";
		obj_ts.style.display = "block";
	}
	*/
}

function fecha_tela_safari () {
	document.getElementById("tela_safari").style.display = "none";
}

// mostra o balão da ajuda
function ajuda (cod , nm_obj , xx , yy) {
	obj = document[nm_obj];
	vars = "codigo=" + cod + "&ativa=1";
	temp = 0;
	if (yy == "0" && xx == "0") {
		if (obj.x == undefined) {
			xx =  window.event.x;
			yy =  window.event.y;
			yy += obj.offsetTop + document.body.scrollTop - 15;
		}
		else {
			yy = obj.y;
			xx = obj.x;
		}
	}
	if (obj.x == undefined) {
		xx -= 7;
		yy -= 5;
	}
	yy -= 137;
	xx -= 262 / 2;
	yy = (yy < 0 ? 0 : yy);
	xx = (xx < 0 ? 0 : xx);
	yy += "px";
	xx += "px";
	mostraflash (1 , "ajudaswf");
	document.getElementById("ajudaswf").style.top = yy;
	document.getElementById("ajudaswf").style.left = xx;
	document.getElementById("flashajuda").src = "livroreceita_ajudabalao.php?ajuda=" + cod;
	setFlashVariables("flashajuda" , vars);
}

/* mostra ou esconde o flash de acordo com o valor 1 ou 0... o parametro divid é o id da div que está para mostrar ou esconder */
function mostraflash ( valor , divid ) {
	visibilidade = (valor == 0 ? "hidden" : "visible");
	document.getElementById( divid ).style.visibility = visibilidade;
}

function trim (texto) {
	var tirar = new Array();
	tirar[0] = "T";
	tirar[9] = "T";
	tirar[10] = "T";
	tirar[11] = "T";
	tirar[13] = "T";
	tirar[32] = "T";
	if (texto != "") {
		flag = true;
		while (flag) {
			if (tirar[texto.charCodeAt(0)] == "T") {
				texto = texto.substr(1);
			} else {
				flag = false;
			}
		}
		flag = true;
		while (flag) {
			if (tirar[texto.charCodeAt(texto.length - 1)] == "T") {
				texto = texto.substr(0 , (texto.length - 1));
			} else {
				flag = false;
			}
		}
	}
	return texto;
}

TrimJS2 = trim;

/*
function TrimJS2(texto){
	while (texto.charCodeAt(0) == 32) {
		texto = texto.substring(1);
	}
	while(texto.charCodeAt(texto.length - 1) == 32) {
		texto = texto.substring(0 , (texto.length - 1));
	}
	return texto;
}
*/

function sembrancos2(valor , rotulo) {
	if (TrimJS2(valor) == "") {
		alert("O " + rotulo + " está em branco") ;
		return false;
	}
	return true;
}

function manda_busca() {
	texto = document.fBusca.palavra.value;
	if (sembrancos2(texto , "campo de busca") && texto != "Digite aqui. Ex: Leite, ovo, farinha" && texto != "Digite aqui. Ex: Bolo de chocolate") {
		window.top.document.location.href= document.fBusca.action + "&palavra=" + document.fBusca.palavra.value;
	}
	return false;
}

function manda_busca_avancada() {
	f = document.fBuscaAvancada
	texto = f.plv.value;
	campo1 = document.getElementById('tipo_categoria');
	campo2 = document.getElementById('tipo_coz');
	campo3 = document.getElementById('tipo_selo');
	if ((sembrancos2(texto , "campo de busca") && texto != "Digite aqui. Ex.: Leite, ovo, farinha" && texto != "Digite aqui. Ex.: Bolo de Chocolate") || campo1.selectedIndex > 0 || campo2.selectedIndex > 0 || campo3.selectedIndex > 0) {
		//alert('manda!');
		palavra_busca_avancada('focus', null);
		//alert(campo1.name);
		action = f.action
		if (campo1.selectedIndex == 0 && campo2.selectedIndex == 0 && campo3.selectedIndex == 0) {
			action = action.replace('ctr_busca=detalhada&tp_busca_a=0', 'ctr_busca=rapida&tp_busca_a=0');
		}
		location.href= action + "&plv=" + f.plv.value + (campo1.selectedIndex > 0? '&' + campo1.name + '=' + campo1.options[campo1.selectedIndex].value: '') + (campo2.selectedIndex > 0? '&' + campo2.name + '=' + campo2.options[campo2.selectedIndex].value: '') + (campo3.selectedIndex > 0? '&' + campo3.name + '=' + campo3.options[campo3.selectedIndex].value: '');
	}
	return false;
}

function manda_busca_google() {
	f = document.fBuscaGoogle;
	campo = f.q;
	texto = campo.value;
	if (f.tp_buscag[0].checked == true) {
		texto_busca = f.tp_buscag[0].value;
		tp_busca = 0;
	}
	if (f.tp_buscag[1].checked == true) {
		texto_busca = f.tp_buscag[1].value;
		tp_busca = 1;
	}
	if (f.tp_buscag[2].checked == true) {
		texto_busca = f.tp_buscag[2].value;
		tp_busca = 2;
	}
	if (f.tp_buscag[3].checked == true) {
		texto_busca = f.tp_buscag[3].value;
		tp_busca = 3;
	}
	if (f.tp_buscag[4].checked == true) {
		texto_busca = f.tp_buscag[4].value;
		tp_busca = 4;
	}
	if (f.tp_buscag[5].checked == true) {
		texto_busca = f.tp_buscag[5].value;
		tp_busca = 5;
		b = document.form_aux_busca_buscape;
		b.produto.value = texto;
		b.submit();
		return false;
	}
	if (sembrancos2(texto, "campo de busca")) {
		campo.value = campo.value + " " + texto_busca;
		//alert(campo.value);
		f.tp_busca_g.value = tp_busca;
		//alert(f.tp_busca_g.value);
		f.submit();
		campo.value = texto;
	}
	return false;
}

function manda_busca_google_aba() {
	f = document.fBuscaGoogle;
	campo = f.q;
	texto = campo.value;
	if (f.tp_buscag.value == 0) {
		texto_busca = tp_buscag[0];
		tp_busca = 0;
	}
	if (f.tp_buscag.value == 1) {
		texto_busca = tp_buscag[1];
		tp_busca = 1;
	}
	if (f.tp_buscag.value == 2) {
		texto_busca = tp_buscag[2];
		tp_busca = 2;
	}
	if (f.tp_buscag.value == 3) {
		if (sembrancos2(texto, "campo de busca")) {
			texto_busca = tp_buscag[3];
			tp_busca = 3;
			b = document.form_aux_busca_receita;
			b.plv.value = texto;
			b.submit();
		}
		return false;
		
		
	}
	if (f.tp_buscag.value == 4) {
		texto_busca = tp_buscag[4];
		tp_busca = 4;
	}
	if (f.tp_buscag.value == 5) {
		if (sembrancos2(texto, "campo de busca")) {
			texto_busca = tp_buscag[5];
			tp_busca = 5;
			b = document.form_aux_busca_buscape;
			b.produto.value = texto;
			b.submit();
		}
		return false;
	}
	if (sembrancos2(texto, "campo de busca")) {
		campo.value = campo.value + " " + texto_busca;
		//alert(campo.value);
		f.tp_busca_g.value = tp_busca;
		//alert(f.tp_busca_g.value);
		f.submit();
		campo.value = texto;
	}
	return false;
}

function muda_busca_google_aba(aba) {
	f = document.fBuscaGoogle;
	aba_atual = f.tp_buscag.value;
	f.tp_buscag.value = aba;
	oid = 'li-busca-google-aba-' + aba_atual;
	document.getElementById(oid).className = "";
	oid = 'li-busca-google-aba-' + aba;
	document.getElementById(oid).className = "ativo";
	if (aba == '3') {
		f.q.style.background = "#FFF";
		f.q.onfocus = function() {palavra_busca_google('focus');};
 		f.q.onblur = function() {palavra_busca_google('blur');};
	}
	else {
		if (f.q.value == " ") {
			f.q.value = '';
		}
		f.q.style.color='#000';
		if (aba == '5') {
			f.q.style.background = "#FFF";
			f.q.onfocus = function() {};
			f.q.onblur = function() {};
		}
		else {
			f.q.onfocus = qonfocus;
			f.q.onblur = qonblur;
			f.q.focus();
			f.q.blur();
		}
	}
	palavra_busca_google('blur');
}

function palavra_busca_google(acao) {
	fbusca = document.fBuscaGoogle;
	if (fbusca.tp_buscag.value != '3')
		return true;
	campo = fbusca.q;
	texto_campo = trim(campo.value);
	texto = "";
	if(fbusca.tp_buscag.value == '3') {
		texto = " ";
	}
	else {
//		texto = "Digite aqui. Ex: Bolo de chocolate";
//		texto_2 = "Digite aqui. Ex: Leite, ovo, farinha";
	}
	if (acao == 'focus' && texto_campo == texto) {
		campo.value = "";
		//campo.style.color='#000';
	}
	if (acao == 'blur' && texto_campo == "") {
		campo.value = texto;
		//campo.style.color='#CCC';
	}
}



function palavra_busca(acao, radio) {
	fbusca = document.fBusca;
	campo = fbusca.palavra;
	texto_campo = trim(campo.value);
	if(fbusca.tp_busca[2].checked == true) {
		texto = "Digite aqui. Ex: Leite, ovo, farinha";
		texto_2 = "Digite aqui. Ex: Bolo de chocolate";
	}
	else {
		texto = "Digite aqui. Ex: Bolo de chocolate";
		texto_2 = "Digite aqui. Ex: Leite, ovo, farinha";
	}
	if (acao == 'focus' && (texto_campo == texto || texto_campo == texto_2)) {
		campo.value = "";
		campo.style.color='#000';
	}
	if (acao == 'blur' && (texto_campo == "" || texto_campo == texto_2)) {
		campo.value = texto;
		campo.style.color='#CCC';
	}
	if (radio !== null) {
		action = fbusca.action;
		action = action.substr(0, action.indexOf('?') == -1? action.length: action.indexOf('?'));
		fbusca.action = action + "?" + fbusca.tp_busca[radio].value;
	}
}

function palavra_busca_avancada(acao, radio) {
	fbusca = document.fBuscaAvancada;
	campo = fbusca.plv;
	texto_campo = trim(campo.value);
	if(fbusca.tp_busca_a[2].checked == true) {
		texto = "Digite aqui. Ex.: Leite, ovo, farinha";
		texto_2 = "Digite aqui. Ex.: Bolo de Chocolate";
	}
	else {
		texto = "Digite aqui. Ex.: Bolo de Chocolate";
		texto_2 = "Digite aqui. Ex.: Leite, ovo, farinha";
	}
	status_disabled = false;
	if (fbusca.tp_busca_a[1].checked == true) {
		status_disabled = true;
	}
//alert(texto_campo);
	if (acao == 'focus' && (texto_campo == texto || texto_campo == texto_2)) {
		campo.value = "";
	}
	if (acao == 'blur' && (texto_campo == "" || texto_campo == texto_2)) {
		campo.value = texto;
	}
	if (campo.value == texto || texto_campo == texto_2) {
		cor = '#CCC';
	}
	else {
		cor = '#000';
	}
	campo.style.color = cor;
	if (radio !== null) {
		action = fbusca.action;
		action = action.substr(0, action.indexOf('?') == -1? action.length: action.indexOf('?'));
		fbusca.action = action + "?" + fbusca.tp_busca_a[radio].value;
		campo1 = document.getElementById('tipo_categoria');
		campo2 = document.getElementById('tipo_coz');
		campo3 = document.getElementById('tipo_selo');
		campo1.selectedIndex = 0;
		campo2.selectedIndex = 0;
		campo3.selectedIndex = 0;
		campo1.disabled = status_disabled;
		campo2.disabled = status_disabled;
		campo3.disabled = status_disabled;
	}

}

function seta_busca(google) {
	campo_form = google? document.fBuscaGoogle.tp_buscag: document.fBusca.tp_busca;
	campo_get = google? 'tp_busca_g=': 'tp_busca=';
	var loc = document.location.href
	var pos_ini = loc.indexOf(campo_get);
	if (pos_ini > -1) {
		var pos_fim = loc.indexOf('&', pos_ini);
		if (pos_fim == -1) {
			pos_fim = loc.length;
		}
		var tp_busca = parseInt(loc.substr(pos_ini, pos_fim - pos_ini).replace(campo_get, ''));
		//alert(tp_busca);
		if (!isNaN(tp_busca) && campo_form[tp_busca] !== null) {
			if (google && arr_busca_topo[0]['tipo'] == 'aba') {
				muda_busca_google_aba(tp_busca);
			}
			else {
				campo_form[tp_busca].checked = true;
			}
			if (!google) {
				palavra_busca('blur', tp_busca);
			}
			else {
				palavra_busca_google('blur', tp_busca);
			}
		}
	}
}

/*
function comida_boa_indicacao_posicao () {
	if (navigator.appName == "Microsoft Internet Explorer") {
		_wid = document.body.clientWidth;
		_hei = document.body.clientHeight;
		_top = document.body.scrollTop;
		document.getElementById("body_alpha").style.top = _top + "px";
	}
	else {
		_wid = document.body.clientWidth;
		_hei = document.body.clientHeight;
		_top = document.body.scrollTop;
	}
	document.getElementById("add_favorito").style.left = ((_wid - 380) / 2) + "px";
	document.getElementById("add_favorito").style.top = (_top - 50) + ((_hei - 300) / 2) + "px";
	bodyalpha_texto_favorito = document.getElementById("add_favorito").innerHTML;
	document.getElementById("add_favorito").innerHTML = bodyalpha_texto_comida_boa;
}

function comida_boa_indicacao (flag) {
	url_login = URL_PALADAR + "login.php?vai=comunidade_cooknauta_perfil.php[i]cooknauta_codigo=2590357";
	if (logado_js() || flag == 1) {
		switch (flag) {
			case 0:
				comida_boa_indicacao_posicao();
				document.getElementById("tira_combo").href = "css/tira_combo.css";
				document.getElementById("body_alpha").style.display = "block";
				document.getElementById("add_favorito").style.display = "block";
			break;
			case 1:
				document.getElementById("tira_combo").href = "css/branco.css";
				document.getElementById("body_alpha").style.display = "none";
				document.getElementById("add_favorito").style.display = "none";
				document.getElementById("add_favorito").innerHTML = bodyalpha_texto_favorito;
			break;
		}
	}
	else {
		location.href = url_login;
	}
}
*/
function add_favorito () {
	var url = "http://www.cybercook.com.br";
	var title = "Cybercook - Receitas, culinária e o melhor da cozinha na internet";
	if (window.sidebar) {
		window.sidebar.addPanel(title , url , "");
	}
	else if(window.opera && window.print) {
		var mbm = document.createElement("a");
		mbm.setAttribute("rel" , "sidebar");
		mbm.setAttribute("href" , url);
		mbm.setAttribute("title" , title);
		mbm.click();
	}
	else if (document.all) {
		window.external.AddFavorite(url , title);
	}
	/* window.external.AddFavorite("http://cybercook.terra.com.br" , "Cyber Cook - Receitas mais saborosas"); */
}

function add_inicial () {
	oHomePage.setHomePage("http://cybercook.terra.com.br");
}

function startList () {
	if (document.all && document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i = 0 ; i < navRoot.childNodes.length ; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName == "LI") {
				node.onmouseover = function () {
					this.className += " over";
				}
				node.onmouseout = function () {
					this.className = this.className.replace(" over" , "");
				}
			}
		}
	}
}

function verifica_form_login (formulario) {
	v_login = formulario.login.value;
	v_senha = formulario.senha.value;
	if (v_login.length == 0 || v_senha.length == 0) {
		alert("Você deve digitar seu login e senha antes de continuar!");
		return false;
	}
	else {
		return true;
	}
}

function barra_topo_no_inc_exibir_receita_a (barra_topo_src) {
	if (document.getElementById("barra_topo") != null) {
		document.getElementById("barra_topo").src = barra_topo_src;
	}
}

function barra_topo_no_inc_exibir_receita_b (span , url_volta_primeira) {
	if (document.getElementById("barra_topo") != null) {
		document.getElementById("barra_topo").parentNode.innerHTML = "";
	}
	document.write(span);
	if (document.getElementById("barra_topo2") != null) {
		document.getElementById("barra_topo2").parentNode.innerHTML = "<a href='" + url_volta_primeira + "'>" + document.getElementById("barra_topo2").parentNode.innerHTML + "</a>";
	}
}

function barra_topo_no_inc_exibir_receita_c (url_volta_primeira) {
	if (document.getElementById("barra_topo") != null) {
		document.getElementById("barra_topo").parentNode.innerHTML = "<a href='" + url_volta_primeira + "'>" + document.getElementById("barra_topo").parentNode.innerHTML + "</a>";
	}
}

function grava_rank_exibir_receita (GRAVARANK , CODIGO) {
	var referrer = document.referrer;
	if (referrer.length > 0 && referrer.indexOf("//") != -1 && referrer.indexOf("/receitas-de-") < 0 && referrer.indexOf("/ranking") < 0 ) {            
		document.write('<img src="' + GRAVARANK + 'grava_rank.php?codigo=' + CODIGO + '" width="1" height="1" border="0">');
	}
}

function telas (cod , nm_obj , yy) {
	obj = document[nm_obj];
	vars = "codigo=" + cod + "&ativa=1";
	tempor = document.body.scrollTop + document.body.clientHeight - 265;
	if (yy == 0) {
		if (obj.y == undefined) {
			yy = window.event.y;
			yy += document.body.scrollTop - 15;
		} else {
			yy = obj.y;
		}
	}
	yy += 20;
	yy = (yy < 0 ? 0 : yy);
	yy = (yy >= tempor ? tempor : yy);
	yy += "px";
	document.getElementById("telasimg").src = "about:blank";
	document.getElementById("telasswf").style.top = yy;
	document.getElementById("telasswf").style.left = 300;
	mostraflash ( 1 , "telasswf" );
	document.getElementById("telasimg").src = telasArr[cod];
}

function aba_destaque(tipo) {
	switch(tipo) {
		case 0:
		default:
			document.getElementById("li_aba_mais_populares").className = "";
			document.getElementById("li_aba_destaque").className = "ativo";
			document.getElementById("div_destaque").style.display = "block";
			document.getElementById("div_mais_populares").style.display = "none";
			document.getElementById("div_mais_populares").innerHTML = "";
		break
		case 1:
		case 2:
			document.getElementById("li_aba_destaque").className = "";
			document.getElementById("li_aba_mais_populares").className = "ativo";
			document.getElementById("div_destaque").style.display = "none";
			document.getElementById("div_mais_populares").style.display = "block";
			document.getElementById("frm_mais_populares").src="frame_comunidade_cooknauta_mais_populares.php?tipo="+tipo;
		break;
	}
}

function permite_acesso_js (script) {
	if (logado_js() && getCookie("permite_frontend") == "S" && arr_permite_script[script] != 1) {
		return false;
	}
	else {
		return true;
	}
}

function email_confirmado(script) {
	if (getCookie("email_confirmado") == "N") {
		return false;
	}
	return true;
}


function muda_janela_destaque (flag) {
	jmd = document.getElementById("janela_menu_destaque");
	jmo = document.getElementById("janela_menu_outros");
	jcd = document.getElementById("janela_destaque");
	jco = document.getElementById("janela_outros");
	if (flag == 0) {
		jmd.className = "ativo";
		jmo.className = "";
		jcd.style.display = "block";
		jco.style.display = "none";
	} else {
		jmd.className = "";
		jmo.className = "ativo";
		jcd.style.display = "none";
		jco.style.display = "block";
		document.getElementById("janela_outros_server").src = "frame_comunidade_blogs.php";
	}
}

function muda_dez (flag) {
	tma = document.getElementById("tma_a");
	tmc = document.getElementById("tmc_c");
	tup = document.getElementById("tup_p");
	tuc = document.getElementById("tuc_c");

	mm = document.getElementById("menu_mais");
	mu = document.getElementById("menu_ultimos");

	dma = document.getElementById("dez_mais_atualizados");
	dmc = document.getElementById("dez_mais_comentadas");
	dm_menu = document.getElementById("dez_mais_menu");
	dma_menu = document.getElementById("dez_mais_atualizados_menu");
	dmc_menu = document.getElementById("dez_mais_comentados_menu");

	dup = document.getElementById("dez_ultimos_postagens");
	duc = document.getElementById("dez_ultimos_criados");
	du_menu = document.getElementById("dez_ultimos_menu");
	dup_menu = document.getElementById("dez_ultimos_postagens_menu");
	duc_menu = document.getElementById("dez_ultimos_criados_menu");

	switch(flag) {
		case 1:
			mm.className = "ativo";
			mu.className = "";

			dma.style.display = "block";
			dmc.style.display = "none";
			dm_menu.style.display = "block";
			dma_menu.className = "ativo";
			dmc_menu.className = "";

			dup.style.display = "none";
			duc.style.display = "none";
			du_menu.style.display = "none";
			dup_menu.className = "ativo";
			duc_menu.className = "";

			tma.style.display = "block";
			tmc.style.display = "none";
			tup.style.display = "none";
			tuc.style.display = "none";
		break;

		case 2:
			mm.className = "ativo";
			mu.className = "";

			dma.style.display = "none";
			dmc.style.display = "block";
			dm_menu.style.display = "block";
			dma_menu.className = "";
			dmc_menu.className = "ativo";

			dup.style.display = "none";
			duc.style.display = "none";
			du_menu.style.display = "none";
			dup_menu.className = "ativo";
			duc_menu.className = "";

			tma.style.display = "none";
			tmc.style.display = "block";
			tup.style.display = "none";
			tuc.style.display = "none";
		break;

		case 3:
			mm.className = "";
			mu.className = "ativo";

			dma.style.display = "none";
			dmc.style.display = "none";
			dm_menu.style.display = "none";
			dma_menu.className = "ativo";
			dmc_menu.className = "";

			dup.style.display = "block";
			duc.style.display = "none";
			du_menu.style.display = "block";
			dup_menu.className = "ativo";
			duc_menu.className = "";

			tma.style.display = "none";
			tmc.style.display = "none";
			tup.style.display = "block";
			tuc.style.display = "none";
		break;

		case 4:
			mm.className = "";
			mu.className = "ativo";

			dma.style.display = "none";
			dmc.style.display = "none";
			dm_menu.style.display = "none";
			dma_menu.className = "ativo";
			dmc_menu.className = "";

			dup.style.display = "none";
			duc.style.display = "block";
			du_menu.style.display = "block";
			dup_menu.className = "";
			duc_menu.className = "ativo";

			tma.style.display = "none";
			tmc.style.display = "none";
			tup.style.display = "none";
			tuc.style.display = "block";
		break;
	}
}

function expansivo_vai(j_objid,j_width,j_height,j_flag) {
	if (document.getElementById(j_objid) !== null) {
		var obj = document.getElementById(j_objid).style;
		if (obj.clip.left) {
			obj.clip.top = 0;
			obj.clip.right = j_width;
			obj.clip.bottom = j_height;
			obj.clip.left = 0;
		}
		obj.clip = 'rect(0 ' + j_width + 'px ' + j_height + 'px 0)';
		expansivo_usando = false;
	}
}

function expansivo_muda (j_objid,j_width,j_height,j_flag) {
	if (!expansivo_usando) {
		expansivo_usando = true;
		if (j_flag == true) {
			expansivo_vai(j_objid,j_width,j_height,j_flag);
		} else {
			expansivo_vai(j_objid,j_width,j_height,j_flag);
		}
		expansivo_usando = false;
	}
}

function expansivo_muda_timeout (j_objid,j_width,j_height,j_flag) {
	if (j_flag == true) {
		setTimeout("expansivo_vai('"+j_objid+"' , "+j_width+" , "+j_height+" , "+j_flag+")" , 2000);
	} else {
		expansivo_vai(j_objid,j_width,j_height,j_flag);
	}
}

function buscar () {
	if (document.glossarioBusca.busca.value.length < 3) {
		alert ("a busca deve conter no mínimo três letras");
		return false;
	} else {
		return true;
	}
}

function muda_patrocinador ( imagem ) {
	document.getElementById("patrocinador").src = imagem;
}

/* Google Serarch */
var googleSearchIframeName = "cse-search-results";
var googleSearchFormName = "cse-search-box";
var googleSearchFrameWidth = 795;
var googleSearchDomain = "www.google.com.br";
var googleSearchPath = "/cse";
/* Google Serarch - FIM */

/* Google ADS */
var google_ad_client = "";
var google_ad_width = 0;
var google_ad_height = 0;
var google_ad_format = "";
var google_ad_type = "";
var google_color_border = "";
var google_color_bg = "";
var google_color_link = "";
var google_color_url = "";
var google_color_text = "";

google_ads = new Object();
google_ads.topo = function () {
	google_ad_client = "pub-7443276122216115";
	google_ad_width = 120;
	google_ad_height = 130;
	google_ad_format = "120x90_0ads_al";
	google_ad_type = "";
	google_color_border = "fff7ec";
	google_color_bg = "fff7ec";
	google_color_link = "dd5444";
	google_color_url = "ff9933";
	google_color_text = "232323";
}

google_ads.direita = function () {
	google_ad_client = "pub-7443276122216115";
	google_ad_width = 120;
	google_ad_height = 240;
	google_ad_format = "120x240_as";
	google_ad_type = "text_image";
	google_color_border = "ffffff";
	google_color_bg = "ffffff";
	google_color_link = "dd5444";
	google_color_url = "ff9933";
	google_color_text = "232323";
}

google_ads.exibir_receita = function () {
	google_ad_client = "pub-7443276122216115";
	google_ad_width = 336;
	google_ad_height = 280;
	google_ad_format = "336x280_as";
	google_ad_type = "text_image";
	google_color_border = "ffffff";
	google_color_bg = "ffffff";
	google_color_link = "dd5444";
	google_color_url = "ff9933";
	google_color_text = "232323";
}

google_ads.topo.a = function () {
	google_ads.topo();
	document.write(google_ads.monta("Receita_Sky_links"));
}

google_ads.topo.b = function () {
	google_ads.topo();
	document.write(google_ads.monta("Cooknauta_linksdireita"));
}

google_ads.topo.c = function () {
	google_ads.topo();
	document.write(google_ads.monta("Materia_linksdireita"));
}

google_ads.direita.a = function () {
	google_ads.direita();
	document.write(google_ads.monta("Receita_Sky_dentro"));
}

google_ads.direita.a = function () {
	google_ads.direita();
	document.write(google_ads.monta("Materia_skydentro"));
}

google_ads.exibir_receita.a = function () {
	google_ads.exibir_receita();
	document.write(google_ads.monta("Receita_Rodape"));
}

google_ads.monta = function (google_ad_channel) {
	var texto = '<sc' + 'ript type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></scr' + 'ipt>';
	return texto;
}
/* Google ADS - FIM */
function fjanela(jnr,jact) {
	jobj0 = document.getElementById("vejamais_"+jnr);
	jobj1 = document.getElementById("vejamenos_"+jnr);
	jobj2 = document.getElementById("invisivel_"+jnr);
	jfoc = document.getElementById("forum_"+jnr);
	jobj0.style.display = jact=="A"? "none":"inline";
	jobj1.style.display = jact=="A"? "inline":"none";
	jobj2.style.display = jact=="A"? "inline":"none";			
	if (jact=="F") {
		jfoc.focus();
	}
}
function createXMLHttpRequestObject() {
	// xmlHttp will store the reference to the XMLHttpRequest object
	var xmlHttp;
	// try to instantiate the native XMLHttpRequest object
	try {
		// create an XMLHttpRequest object
		xmlHttp = new XMLHttpRequest();
	}
	catch(e) {
		// assume IE6 or older
		try {
			xmlHttp = new ActiveXObject("Microsoft.XMLHttp");
		}
		catch(e) { }
	}
	// return the created object or display an error message
	if (!xmlHttp) {
		//alert("Arrume um navegador decente com menos de 50 anos!");
	}
	else 
		return xmlHttp;
}

function atualiza_div(nome_obj_destino, url_request) {
	var obj_destino = document.getElementById(nome_obj_destino);

	var request =  new createXMLHttpRequestObject();
	request.open("GET", url_request, true);
	request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	request.setRequestHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT");
	
	request.onreadystatechange = function() {
		if (request.readyState == 4 && request.status == 200) {
			var txt = request.responseText;
			if ( txt != "" ) {
				obj_destino.innerHTML = txt;
				if (typeof processa_atualiza_div == 'function')
					processa_atualiza_div();
			}	
		}
	};
	request.send(null);
}

function limpa_div(nome_obj) {
	obj = document.getElementById(nome_obj);
	obj.innerHTML = "";
}
function mostra_busca_topo() {
	arr_busca_topo = shuffle(arr_busca_topo);
	document.write(arr_busca_topo[0]['html']);
	document.write(
'						<form action="http://busca.buscape.com.br/cprocura" method="get" name="form_aux_busca_buscape" target="_top">\n' +
'							<input name="produto" type="hidden" />\n' +
'							<input type="hidden" name="site_origem" value="0">\n' +
'							<input type="hidden" name="iad" value="0">\n' +
'							<input type="hidden" name="pr" value="2358">\n' +
'						</form>\n');
	document.write('<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&amp;lang=pt"><\/script>\n');
	seta_busca(true);
}


/*MENU JQUERY*/
var timeout = 300;
var closetimer = 0;
var ddmenuitem = 0;

$(function() {
	$("#link-logon").load(URL_CYBERCOOK4 + 'frame_moldura.php?tipo=link-logon');
	$("#frm_menu_comunidade").load(URL_CYBERCOOK4 + 'frame_moldura.php');

	function menu_novo_ccook_open() {
		menu_novo_ccook_canceltimer();
		menu_novo_ccook_close();
		ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');
	}
	
	function menu_novo_ccook_close() {
		if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');
	}
	
	function menu_novo_ccook_timer() {
		closetimer = window.setTimeout(menu_novo_ccook_close, timeout);
	}
	
	function menu_novo_ccook_canceltimer() {
		if(closetimer) {
			window.clearTimeout(closetimer);
			closetimer = null;
		}
	}
			
	$('#menu_novo_ccook > li').bind('mouseover', menu_novo_ccook_open);
	$('#menu_novo_ccook > li').bind('mouseout',  menu_novo_ccook_timer);
	document.onclick = menu_novo_ccook_close;


	$('a.jt').cluetip({
		cluetipClass: 'jtip',
		width: '432px' ,
		height: '435px' ,
		activation: 'click' ,
		arrows: true ,
		dropShadow: true ,
		hoverIntent: false ,
		sticky: true ,
		mouseOutClose: false ,
		closePosition: 'top' ,
		closeText: '<img src="http://cybercook2.terra.com.br/img/home/cooktv/icone_fechar.gif" alt="fechar" />'
	});

});