$(function(){
	
	$('.target-blank').click(function(){
		$(this).attr('target', '_blank').click();
		return false;
	});
	
	/**
	 * DEFAULTS
	 **/
	
	// Alert/Flash Message
	setTimeout(hideAlert,4000);
	$("#alert-message").click(function(){
	    hideAlert();
	});
	function hideAlert(){
	    if ($("#alert-message")[0]) { $("#alert-message").slideUp('fast'); }
	}
	
	// END
    /* Gallery TV Home */
    //highlight

	
	//thumbs
	$("ul.thumb-video li a").click(function(){
		var self = $(this);
		var url = self.attr("rel");
		$('#video-highlight').html('');
		$('#video-highlight').youTubeEmbed({
		video			: url,
		width			: 309, 		// Height is calculated automatically
		height          : 193,
		progressBar	: true		// Hide the progress bar
	});
		return false;
	});
	/* End Gallery TV Home */
	
	//destaque
	$("div#mygaltwo").slideView({}); 
	$("div#mygaltree").slideView({});
	//$("div#mygalone").slideView();
	
	window.time_time = setTimeout(function(){
		$(".stripTransmitter ul li a:first").click();
	},5000);

	var v = $("#contact-form").jcheck({language: 'pt-br'});
 	v.validates("name", "destination", "fone", "message", {presence: true});
	v.validates("email", {format: {"with": "email", message: "Utilize um e-mail válido"}});


	var vvv = $("#SignupForm").jcheck({language: 'pt-br'});
  vvv.validates("name", "info_cpf","other_names","state","city","type_job","approved_job","title_work","upload","your_name","type_sex","profession","where_work","birth","rg","race","address","address_number","district","info_phone_cel","deficient","as_event","what_relevance",{presence: true});
	vvv.validates("email", {format: {"with": "email", message: "Utilize um e-mail válido"}});

	var vv_suggest = $(".suggest-form").jcheck({language: 'pt-br'});
	vv_suggest.validates("suggested_name", "local_job", "sector","your_name","your_email", {presence: true});


	var val = $(".form-update").jcheck({language: 'pt-br'});
	val.validates("name","address","number","neighborhood","city","state","local_job",
	"membership_father","membership_mother","homertown","age","emitting_organ","cpf","", {presence: true});
	val.validates("email", {format: {"with": "email", message: "Utilize um e-mail válido"}});
	val.validates("cep", {length: {minimum: 8, maximum: 8}});
	val.validates("fone_home","fone_cell","fone_other", {length: {minimum: 8, maximum: 100}});
	
	var complaint = $(".form-complaint").jcheck({language: 'pt-br'});
	complaint.validates("name-complaint","institution-reported-complaint","county-complaint", "fone-complaint", {presence: true});
	complaint.validates("email-complaint", {format: {"with": "email", message: "Utilize um e-mail válido"}});
	complaint.validates("messenger-description-complaint", {length: {minimum: 8, maximum: 10000}});
	
	
	$("input[type='text'], input[type='password']").each(function(index) {
		var valor_previous = $(this).val();
		$(this).focusin(function() {
			var self = $(this);
			var valor = self.val();
			if(valor == valor_previous){
				self.val("");
			}

		}).focusout(function() {
			var valor = $(this).val();
			if(valor == ''){
				$(this).val(valor_previous);
			}
		});
	});
	
});



