// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function limitChars(texto, limite, info){
  var text = $('#'+texto).val();
  var textlength = text.length;

  if(textlength > limite){
    $('#' + info).html('Você já chegou no limite de <span class="big-font">'+limite+'</span> caracteres');
    $('#'+texto).val(text.substr(0,limite));
    return false;
  }else{
    $('#' + info).html('Você ainda pode escrever mais <span class="big-font">'+ (limite - textlength) +'</span> caracteres');
    return true;
  }
}


function completeValueInput(obj,strVerificacao){
	
	if(obj.value == strVerificacao){
		obj.value = '';
	}else{
		if(obj.value == ''){
			obj.value = strVerificacao;
		}
	}
}

function validate_form_newsletter(form){
	var bReturn = true;
	emailRegExp = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.([a-z]){2,4})$/;


	if($('#newsletter_nome').val() == "" || $('#newsletter_nome').val() == "Digite seu nome"){
		alert('Informe por favor o seu nome.');
		bReturn = false;
	}else{

		if($('#newsletter_email').val() == "" || $('#newsletter_email').val() == "Digite seu e-mail"){
			alert('Informe por favor o seu endereço de e-mail.');
			bReturn = false;
		}else{

			if( !emailRegExp.test($('#newsletter_email').val()) ){
				alert('Informe por favor um endereço de e-mail válido.');
				bReturn = false;
			}

		}
	}
	return bReturn;

}



function validate_form_comment(form){
	var bReturn = true;
	emailRegExp = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.([a-z]){2,4})$/;

	if($('#comment_usuario_nome').val() == "" || $('#comment_usuario_nome').val() == "Nome completo"){
		alert('Informe por favor o seu nome.');
		bReturn = false;
	}else{

		if($('#comment_usuario_email').val() == "" || $('#comment_usuario_email').val() == "E-mail"){
			alert('Informe por favor o seu endereço de e-mail.');
			bReturn = false;
		}else{

			if( !emailRegExp.test($('#comment_usuario_email').val()) ){
				alert('Informe por favor um endereço de e-mail válido.');
				bReturn = false;
			}else{
				if($('#texto').val() == "" || $('#texto').val() == ""){
					alert('Informe por favor o comentário.');
					bReturn = false;
				}

			}

		}
	}
	return bReturn;

}

function validate_form_contato(form){
	var bReturn = true;
	emailRegExp = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.([a-z]){2,4})$/;

	if($('#contato_nome').val() == "" || $('#contato_nome').val() == "Nome completo"){
		alert('Informe por favor o seu nome.');
		bReturn = false;
	}else{

		if($('#contato_email').val() == "" || $('#contato_email').val() == "E-mail"){
			alert('Informe por favor o seu endereço de e-mail.');
			bReturn = false;
		}else{

			if( !emailRegExp.test($('#contato_email').val()) ){
				alert('Informe por favor um endereço de e-mail válido.');
				bReturn = false;
			}else{
				if($('#contato_texto').val() == "" || $('#contato_texto').val() == ""){
					alert('Informe por favor o texto.');
					bReturn = false;
				}

			}

		}
	}
	return bReturn;

}




function videoshow(id, codigo, titulo){
	
	$('#video_'+id).html("<strong class=\"title_foto\"><h3>"+ titulo +"</h3></strong><br><center><object width=\"450\" height=\"355\"><param name=\"movie\" value=\"http://www.youtube.com/v/"+ codigo +"&fs=1&autoplay=1\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/"+ codigo +"&hl=pt_BR&fs=1&autoplay=1\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"450\" height=\"355\"></embed></object></center><br>");
	//bazinga

}


