
$.fn.isEmail = function(){
	if (!/^[a-zA-Z0-9]+[_a-zA-Z0-9-]*(\.[_a-z0-9-]+)*@[a-z?G0-9]+(-[a-z?G0-9]+)*(\.[a-z?G0-9-]+)*(\.[a-z]{2,4})$/.test($(this).val())) return false;
	else return true;
}
$.fn.isDate = function(){
	if (!/^((0?[1-9]|[12]\d)\/(0?[1-9]|1[0-2])|30\/(0?[13-9]|1[0-2])|31\/(0?[13578]|1[02]))\/(19|20)?\d{2}$/.test($(this).val())) return false;
	else return true;
}
$.fn.isHour = function(){
	if (!/^([0-1][0-9]|[2][0-3]):([0-5][0-9])$/.test($(this).val())) return false;
	else return true;
}
$.fn.isHour2 = function(){
	if (!/^([0-1][0-9]|[2][0-3]):([0-5][0-9]):([0-5][0-9])$/.test($(this).val())) return false;
	else return true;
}



/* ************************************************************ */
/* FUNCOES PARA ALERTA */
/* ************************************************************ */
/*
function show_alert(txt){
	//$("select").each(function(){ $(this).hide(); }); //ie6
	$("#bgSite").css('height', $(document).height());
	$("#bgSite").fadeTo("slow", 0.5);
	$("#bgSite").show();
	$("#alertError").html('<ul><li><span>'+txt+'</span></li></ul>');
	$("#alertSite").css('top', (($(window).height()/3)+$(window).scrollTop()));
	$("#alertSite").show();
}

function hide_alert(){
	//$("select").each(function(){ $(this).show(); }); //ie6
	$('#bgSite').hide();
	$("#alertSite").hide();
}
*/
function hide_form_alert(){
	$('#bgSite').hide();
	$('#bgConteudoHtml').hide();
	$("#sucessoAtendimento").hide();
}
/* ************************************************************ */



/* ************************************************************ */
/* FUNCOES PARA FORM BUSCA */
/* ************************************************************ */
var idt = null;
function buscar(a){
	_v = $('#q').val();
	if (_v.replace(/\ /g,'') == '' || _v == 'Digite aqui'){
		$('#q').val('Informe uma palavra, por favor.')
		idt = setTimeout('limpa_busca()', 3000)
		return false;
	}
	if (a==0) $('#cse-search-box').submit();
	return true;
}
function limpa_busca(){
	_v = $('#q').val();
	if (_v != 'Digite aqui' && _v != 'Informe uma palavra, por favor.') return;
	else $('#q').val('Digite aqui');
	clearTimeout(idt);
}
/* ************************************************************ */



/* ************************************************************ */
/* FUNCOES PARA WAITING */
/* ************************************************************ */
/*
function show_waiting(l, bg){
	var loadingAjax = $(l)
	var bg = $(bg)
	loadingAjax.css({
		'left':$(window).width()/2-loadingAjax.width()/2,
		'top':(($(window).height()/2)-(loadingAjax.height()/2))+$(window).scrollTop()
	});
	loadingAjax.show()
	bg.css('height', $(document).height()-5);
	bg.fadeTo("fast", 0.5)
	bg.show()
}

function hide_waiting(l, bg){
	$(l).hide()
	$(bg).hide()
}
*/
/* ************************************************************ */



/* ************************************************************ */
/* FUNCOES PARA FORM INDICAÇÃO (produtos / receitas) */
/* ************************************************************ */
function indicaconteudo(){
	function show_loading_indica(){
		$(".enviando").show()
		$(".block-form-indica").show()
	}

	function form_response_indica(data){
		$(".enviando").hide()
		$(".block-form-indica").hide()

		if(data.sucesso){
			$('#conteudoHtml')
				.html('')
				.hide();

			$("#sucessoAtendimento")
				.css({
					'left': $(window).width()/2-$("#sucessoAtendimento").width()/2,
					'top': (($(window).height()/2)-($("#sucessoAtendimento").height()/2))+$(window).scrollTop()
				})
				.show();

			return false
		}else{
			for(i=0; i<data.length; i++){
				$('#'+data[i].label)
					.val(data[i].message)
					.parent()
						.children('.star')
							.show();
			}

			return false
		}
	}

	$('.form_ajax').ajaxForm({ 
		dataType: 'json',
		beforeSubmit: show_loading_indica,
		success: form_response_indica,
		error: form_response_indica
	})

	var n = $('#id_seunome')
	var e = $('#id_seuemail')
	var na = $('#id_nomeamigo')
	var ea = $('#id_emailamigo')
	n.val((n.val()=='Este campo é obrigatório')?'':n.val())
	n.parent().children('.star').hide()
	e.val((e.val()=='Este campo é obrigatório' || e.val()=='Preencha corretamente este campo')?'':e.val())
	e.parent().children('.star').hide()
	na.val((na.val()=='Este campo é obrigatório')?'':na.val())
	na.parent().children('.star').hide()
	ea.val((ea.val()=='Este campo é obrigatório' || ea.val()=='Preencha corretamente este campo')?'':ea.val())
	ea.parent().children('.star').hide()

	$('.form-indique').submit()
}
function eventosDetalhesIndicar() {
	var n = $('#id_seunome')
	var e = $('#id_seuemail')
	var na = $('#id_nomeamigo')
	var ea = $('#id_emailamigo')
	n.focus(function(){
		n.val(
			(n.val()=='Este campo é obrigatório' || n.val()=='')?'':n.val()
		)
	})
	e.focus(function(){
		e.val(
			(e.val()=='Este campo é obrigatório' || e.val()=='Preencha corretamente este campo' || e.val()=='')?'':e.val()
		)
	})
	na.focus(function(){
		na.val(
			(na.val()=='Este campo é obrigatório' || na.val()=='')?'':na.val()
		)
	})
	ea.focus(function(){
		ea.val(
			(ea.val()=='Este campo é obrigatório' || ea.val()=='Preencha corretamente este campo' || ea.val()=='')?'':ea.val()
		)
	})
}
function cb_html_load_produto(){
	eventosDetalhesIndicar()
}
function cb_html_load_receita(){
	eventosDetalhesIndicar()
}
function cb_html_load_curiosidade(){
	eventosDetalhesIndicar()
}
/* ************************************************************ */









