var tam = 12;



function mudaFonte(tipo) {
	if (tipo == "mais") {
		if (tam < 20) tam += 2;
		createCookie('fonte', tam, 365);
	} else {
		if (tam > 11) tam -= 2;
		createCookie('fonte', tam, 365);
	}
	document.getElementById('centro_conteudo').style.fontSize = tam + 'px';
}

jQuery(document).ready(function() {

	jQuery('.west').tipsy({
		gravity: 'w',
		fade: true
	});

	jQuery("#slider").easySlider({
		auto: true,
		continuous: true
	});

	jQuery("#curtinhas").easySlider({
		auto: true,
		continuous: true,
		speed: 500,
		pause: 20000,
		nextId: "curtinhassetas_next",
		prevId: "curtinhassetas_prev"
	});

	jQuery("#video_banners").easySlider({
		auto: true,
		continuous: true,
		speed: 500,
		pause: 30000,
		nextId: "curtinhassetas_next",
		prevId: "curtinhassetas_prev"
	});

	jQuery("#curtinhas_vertical").easySlider({
		prevText: 'UP',
		nextText: 'DOWN',
		orientation: 'vertical'
	});

	jQuery("#sentamigo").click(function(e) {
		jQuery("#sentAmigoDialog").dialog('open');
		return false;
	});

	jQuery("#share").click(function() {
		jQuery("#shareDialog").dialog('open');
		return false;
	});

	jQuery("#newsletter, #newsletter_topo").click(function() {
		jQuery("#newsletterDialog").dialog('open');
		return false;
	});

	jQuery("#contato, #contato_topo, #contato_rodape").click(function() {
		jQuery("#contatoDialog").dialog('open');
		return false;
	});

	jQuery("#sentAmigoDialog").dialog({
		autoOpen: false,
		bgiframe: true,
		resizable: false,
		draggable: false,
		width: 400,
		height: 420,
		modal: true,
		overlay: {
			backgroundColor: '#000',
			opacity: 1
		},
		buttons: {
			'ENVIAR': function() {
				if ((jQuery("#amigo_seu_nome").val() === "") || (jQuery("#amigo_seu_email").val() === "") || (jQuery("#amigo_nome_amigo").val() === "") || (jQuery("#amigo_email_amigo").val() === "")) {
					jQuery("#erros").remove();
					jQuery("#amigoForm").append("<span id='erros'>Todos os campos são necessários!</span>");
				} else {
					jQuery.ajax({
						url: "/amigo",
						type: "POST",
						dataType: "text",
						data: jQuery("#amigoForm").serialize(),
						complete: function(data, textStatus) {
							texto = "<span id='erros'>" + data.responseText + "</span>";
							jQuery("#erros").remove();
							jQuery("#amigoForm").append(texto);
						}
					});
				}
			},
			'FECHAR': function() {
				jQuery(this).dialog('close');
			}
		}
	});

	jQuery("#shareDialog").dialog({
		autoOpen: false,
		bgiframe: true,
		resizable: false,
		draggable: false,
		width: 500,
		height: 300,
		modal: true,
		overlay: {
			backgroundColor: '#000',
			opacity: 1
		},
		buttons: {
			'FECHAR': function() {
				jQuery(this).dialog('close');
			}
		}
	});

	jQuery("#newsletterDialog").dialog({
		autoOpen: false,
		bgiframe: true,
		resizable: false,
		draggable: false,
		width: 400,
		height: 250,
		modal: true,
		overlay: {
			backgroundColor: '#000',
			opacity: 1
		},
		buttons: {
			'CADASTRAR': function() {
				if ((jQuery("#newsletter_nome").val() === "") || (jQuery("#newsletter_email").val() === "")) {
					jQuery("#erros").remove();
					jQuery("#newsletterForm").append("<span id='erros'>Todos os campos são necessários!</span>");
				} else {
					jQuery.ajax({
						url: "/newsletter",
						type: "POST",
						dataType: "text",
						data: jQuery("#newsletterForm").serialize(),
						complete: function(data, textStatus) {
							texto = "<span id='erros'>" + data.responseText + "</span>";
							jQuery("#erros").remove();
							jQuery("#newsletterForm").append(texto);
						}
					});
				}
			},
			'FECHAR': function() {
				jQuery(this).dialog('close');
			}
		}
	});

	jQuery("#contatoDialog").dialog({
		autoOpen: false,
		bgiframe: true,
		resizable: false,
		draggable: false,
		width: 400,
		height: 430,
		modal: true,
		overlay: {
			backgroundColor: '#000',
			opacity: 1
		},
		buttons: {
			'ENVIAR': function() {
				if ((jQuery("#contato_seu_nome").val() === "") || (jQuery("#contato_seu_email").val() === "") || (jQuery("#contato_mensagem").val() === "")) {
					jQuery("#erros").remove();
					jQuery("#contatoForm").append("<span id='erros'>Todos os campos são necessários!</span>");
				} else {
					jQuery.ajax({
						url: "/contato",
						type: "POST",
						dataType: "text",
						data: jQuery("#contatoForm").serialize(),
						complete: function(data, textStatus) {
							texto = "<span id='erros'>" + data.responseText + "</span>";
							jQuery("#erros").remove();
							jQuery("#contatoForm").append(texto);
						}
					});
				}
			},
			'FECHAR': function() {
				jQuery(this).dialog('close');
			}
		}
	});

	// Add pdf icons to pdf links
	jQuery("a[href*='.pdf?']").addClass("pdf");

	// Add txt icons to document links (doc, rtf, txt)
	jQuery("a[href*='.doc?'], a[href*='.txt?'], a[href*='.rft?']").addClass("txt");

	// Add zip icons to Zip file links (zip, rar)
	jQuery("a[href*='.zip?'], a[href*='.rar?']").addClass("zip");

	// Add email icons to email links
	jQuery("a[href^='mailto:']").addClass("email");

	// generic icon
	jQuery("a[href*='.png?'], a[href*='.jpg?'], a[href*='.gif?']").addClass("external");

});
