﻿urlTransfer();

//////////////////////////////
// JQuery Effects and Code. //
//////////////////////////////
$(document).ready(function() {


	// PRELOAD IMAGES
	var preLoadImages = new Array(
			"./assets/images/contact-us-on.png",
			"./assets/images/bg-blog-active.png",
			"./assets/images/scroll-left-active.png",
			"./assets/images/scroll-right-active.png"
		);

	preload(preLoadImages);



	// SIDEBAR FADE EFFECT
	$("div#header").append("<div id='fade'></div>");



	// EXTERNAL LINKS
	$("*.external").attr("target", "_blank");



	// LOGIN TEXT INPUT CONTROL
	$("input#Login").numeric();

	$("input#Login").focus(function() {
		if ($(this).attr("value") == "Login")
			$(this).attr("value", "");
	});

	$("input#Login").blur(function() {
		if ($(this).attr("value") == "")
			$(this).attr("value", "Login");
	});



	// REGISTRATION TEXT INPUT CONTROL
	$("input#user_email").focus(function() {
		if ($(this).attr("value") == "Seu e-mail")
			$(this).attr("value", "");
	});

	$("input#user_email").blur(function() {
		if ($(this).attr("value") == "")
			$(this).attr("value", "Seu e-mail");
	});



	// NAVIGATION MENU EFFECTS (HOVER)
	$("div#navigation ul li a").hover(
		function() {
			if (!$(this).hasClass("active")) {
				$(this).parent().addClass("hover");
				$(this).parent().append("<span class='shadow'></span>");
			}
		},
		function() {
			$(this).parent().removeClass("hover");
			$("span.shadow").remove();
		}
	);



	// NAVIGATION MENU LINK ACTIVATION
	var blogLink = "blog";
	var activehref = parent.document.URL;

	if (activehref.indexOf(blogLink) == -1) {
		// Home link activation
		$("div#navigation ul li a.active").parent().addClass("active");
		$("div#navigation ul li a.active").parent().append("<span class='activeShadow'></span>");
		$("div#portal_sidebar").css("display", "none");

		// Content slider
		codaslider();

		// Scroll Adjustment
		$(window)._scrollable();
		$(window).scrollTo(0,0);
	}
	else {
		// Blog link activation
		$(".menu_links").removeClass("active");
		$(".menu_links[accesskey='b']").addClass("active");
		$(".menu_links[accesskey='b']").parent().addClass("active");
		$(".menu_links[accesskey='b']").parent().append("<span class='activeShadow'></span>");
		$("div#portal").before("<iframe src='http://megaminas.globo.com/barra_megaminas.php?parceiro=APISINVESTIMENTOS' height='33' width='100%' scrolling='no' frameborder='0'></iframe>");
		$("div#portal").css("margin-top", "-2px");

		// Blog area
		//activehref = activehref.substring(activehref.indexOf(blogLink) + blogLink.length, activehref.length);
	};



	// BLOG LINK MENU EFFECT
	$("div#navigation ul li a[accesskey='b']").addClass("blog");



	// CONTACT FORM ACTIVATION
	$("div#contact_form h3 span").toggle(
		function() {
			$(this).attr("title", "Clique para suprimir.");
			$(this).parent().parent().removeClass("inactive");
			$(this).parent().parent().addClass("active");
			$("div#validationSummary").removeClass("hidden");
		},
		function() {
			$(this).attr("title", "Clique para expandir.");
			$(this).parent().parent().removeClass("active");
			$(this).parent().parent().addClass("inactive");
			$("div#validationSummary").addClass("hidden");
		}
	);



	// CLIENT CONTACT FORM VALIDATION
	$("#emailContactForm").validate({
		rules: {
			nomeTextBox: { required: true, minlength: 3 },
			emailTextBox: { required: true, email: true },
			telefoneTextBox: { required: false },
			mensagemTextBox: { required: true }
		},

		messages: {
			nomeTextBox: "<div class='pointer'></div><div class='errorNote'><span>Por gentileza, digite seu nome completo neste campo.</span></div>",
			emailTextBox: "<div class='pointer'></div><div class='errorNote'><span>Favor inserir um endereço de e-mail válido para que possamos lhe dar o retorno.</span></div>",
			mensagemTextBox: "<div class='pointer'></div><div class='errorNote'><span>Nenhuma mensagem inserida.</span></div>"
		},

		errorContainer: $("#validationSummary")

		//,success: "valid"
	});



	// FORM MASKS
	$("#nomeTextBox").alpha({ allow: " '-,." });
	$("#telefoneTextBox").mask("(99) 9999-9999");



	// LIMITS TEXT INPUT TO 500 CHARACTERS
	$("#mensagemTextBox").bind("keydown keyup", function() {
		limitChars(this, 500);
	});



	// LABEL HITS CHECKBOX
	$("#receiveCopy").click(function() {
		var checked = $("#ccCheckBox").attr("checked");

		if (!checked)
			$("#ccCheckBox").attr("checked", true);
		else
			$("#ccCheckBox").attr("checked", false);
	});



	// HOME BILLBOARDS
	$("div.billboards").hover(
		function() {
			$(this).addClass("active");
		},
		function() {
			$(this).removeClass("active");
		}
	);



	// TWITTER LINK DEACTIVATION
	$("div#news ul li > a").remove();



	// PALESTRAS > MORE INFO
	$("h3.palestra_titulo").click(function() {
		$(this).nextAll("p.palestra_info:first").slideToggle("slow");
		$(this).nextAll("p.curso_valor:first").slideToggle("slow");
	});

	$("h3.palestra_titulo").toggle(
		function() {
			$(this).attr("title", "Interessado? Então inscreva-se já!");
		},
		function() {
			$(this).attr("title", "Saiba mais...");
		}
	);



	// PARTNERS LINK DEACTIVATION
	$("div#parceiros ul li a[href='']").remove();



	// MSN LIVE CHAT
	$(function() {
		$("a.msn").click(function() {
			window.open($(this).attr("href"), "msn", "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,width=350,height=400")
			return false
		})
	});



	// LINKS BLUR
	$("a").click(function() {
		$(this).blur();
	});



	// IE6 PNG FIX
	$("body").supersleight({ shim: "./assets/images/_.gif" });

});
