//sem conflito com outras libs js
jQuery.noConflict();

function setColumnsSize() {

	noticia();
}

function startup() {
	menu();
	rede();
	galeria();
	youtube();
	twitter();
	noticia();
	setColumnsSize();
	jQuery.datepicker.setDefaults(jQuery.datepicker.regional['pt-BR']);
	jQuery('#calendar').datepicker( {
		dayNamesMin : [ 'D', 'S', 'T', 'Q', 'Q', 'S', 'S' ]
	});
}

function rede() {
	jQuery('input[title!=""]').val("");
	jQuery('input.senha[type="password"]').hide();
	jQuery('input.senha[type="text"]').show();
	jQuery('input.senha[type="text"]').bind('focus', function() {
		jQuery('input.senha[type="text"]').hide();
		jQuery('input.senha[type="password"]').show();
		jQuery('input.senha[type="password"]').focus();
		jQuery('input.senha[type="password"]').val("");
	});
	jQuery('input.senha[type="password"]').bind('blur', function() {
		if (jQuery(this).val() == '') {
			jQuery('input.senha[type="password"]').hide();
			jQuery('input.senha[type="text"]').show();
			jQuery('input[title!=""]').hint();
		}
	});
	jQuery('input[title!=""]').hint();
}

function parseTwitterDate(t) {
	t = t.replace(/^(\w{3}\s)(.*)/, "$2");
	t = t.replace(/(.*)(\+\d{4}\s)(.*)/, "$1$3");
	t = t
			.replace(
					/^(\w{3})(\s{1})(\d{2})(\s{1})(\d{2})(:)(\d{2})(:)(\d{2})(\s{1})(\d{4})/,
					"$1 $3 $11 $5 $7 $9");
	ta = t.split(" ");
}

function twitter() {
	return true;
	jQuery(document).ready(
			function() {
				jQuery.jTwitter('silvia_neves', 5, function(data) {
					jQuery('#twitter').empty();
					jQuery.each(data, function(i, post) {
						var timestamp = null;
						jQuery.get("date_facility.php", {
							f : "fdate",
							p : post.created_at
						}, function(data) {
							var p = '<div class="post"><span>' + data
									+ '</span><div class="txt">' + post.text
									+ '</div></div>';
							jQuery('#twitter').append(p);
							setColumnsSize();
						});
					});
				});
			});
}

function menu() {
	jQuery(".menu ul").hide();
	jQuery(".menu li.categoria > span, .menu li.categoria > a").click(
			function() {
				jQuery(this).parent().find('ul').toggle();
				setColumnsSize();
			});
}

function noticia() {

}

function galeria() {
	jQuery(document).ready(loadGaleria);
}

function loadGaleria() {
	Galleria.loadTheme('assets/scripts/themes/lightbox/galleria.lightbox.js');

	jQuery('#content').html("");
	jQuery('#content').html(jQuery('#content-buffer').html());

	jQuery('#galleria').galleria( {
		data_source : '#content',
		keep_source : false,
		data_config : function(img) {
			return {
				description : jQuery(img).next('.caption').html()
			};
		}
	});
}

function loadGaleriaNoticia() {
	jQuery('#images-noticia-content').html("");
	jQuery('#images-noticia-content').html(jQuery('#images-noticia-buffer').html());

	jQuery('#images-noticia-galeria').galleria( {
		data_source : '#images-noticia-content',
		keep_source : false
	});
}

function youtube() {
	jQuery(function() {
		jQuery(".youtube a[rel^='prettyPhoto'], .youtube-galeria a[rel^='prettyPhoto']").prettyPhoto( {
			theme : 'facebook'
		});
	});
}

jQuery(window).bind('resize', setColumnsSize);

jQuery(document).ready(startup);

