/// <reference path="jquery-1.4.1-vsdoc.js" />
$(document).ready(function() {
// Default definitions
	$("head").prepend('<style>.rounded {position:relative;}.lt, .lb, .rt, .rb {position:absolute;z-index:100;display:block;text-indent:-9999px;height:6px !important;width:6px !important;background-repeat:no-repeat}.lt {left:0;top:0;background-position:left top}.lb {left:0;bottom:0;background-position:left bottom}.rt {right:0;top:0;background-position:right top}.rb {right:0;bottom:0;background-position:right bottom}.top, .bottom {position:absolute;display:block;left:0;z-index:100;text-indent:-9999px;height:10px;width:100%;background-repeat:no-repeat;}.top {top:0;background-position:left top;}.bottom {bottom:0;background-position:left bottom;} .left, .right {position:absolute;display:block;top:0;z-index:100;text-indent:-9999px;height:22px;width:4px;background-repeat:no-repeat;}.left {left:0;background-position:left top;}.right {right:0;background-position:right top;}</style>');
	$(".rounded").prepend('<span class="lt" /><span class="rt" /><span class="rb" /><span class="lb" />');
	$(".left-right").prepend('<span class="left" /><span class="right" />');
	$(".top-bottom").prepend('<span class="top" /><span class="bottom" />');
	$(".append-top").prepend('<span class="top png_bg" />');
	$(".append-bottom").prepend('<span class="bottom png_bg" />');

	$(".nav .nav-content ul li div").prepend('<span class="ico png_bg" />');
	$("ul.abas li").find("a").prepend('<span class="left" /><span class="right" />');
	$(".w767").find(".box-content").prepend('<span class="lt" /><span class="rt" /><span class="rb" /><span class="lb" />');

// Adding css class automaticly.
	$("input[type='radio']").addClass("radio");
	$("input[type='checkbox']").addClass("checkbox");
	$("input[type='button']").addClass("button");
	$("input[type='submit']").addClass("button");
	$("input[class|=btn]").addClass("button");
	$("a[class|=btn]").addClass("button");
	$("ul li:last-child").addClass("last");

// Insert tag SPAN inside link on submenu active
	$('ul.submenu li').find("a").prepend('<span class="top" />');

// Increase Font Size
	var lb = $('#container .w767');
	$("a.aumentar").click(function() {
		var size = $(lb).css("font-size");
		var newSize = parseInt(size.replace(/px/, "")) + 1;
		$(lb).css("font-size", newSize + "px");
	});
// Decrease Font Size
	$("a.diminuir").click(function() {
		var size = $(lb).css("font-size");
		var newSize = parseInt(size.replace(/px/, "")) - 1;
		$(lb).css("font-size", newSize + "px");
	});

// Nav Icons balloons
	var navIcons = $(".nav .nav-content ul li");
	navIcons.hover(function() {
		$(this).children("div").css("display", "block");
		$(this).children("a").css("background-position", "center bottom");
	},
	function() {
		$(this).children("div").css("display", "none");
		$(this).children("a").css("background-position", "center top");
	});
// Tabs
	var abas = $("ul.abas li a");
	abas.click(function() {
		var css = $(this).attr("class").split(' ');
		$(".box_abas").hide();
		$("." + css[1]).show();
		$.each(abas, function(index, item) {
			var current = $(item).attr("class");
			$(item).attr("class", current.replace("on", "off"));
		});
		$(this).attr("class", css.join(" ").replace("off", "on"))
		return false;
	});
	
// Aplicando z-index submenu 
	$('ul.submenu li').each(function(index) {
		//$(this).addClass("li_" + index);
		var cssZindex = 100+index;
		$(this).children("a").css("z-index",cssZindex);
	});
	
// Replace text on fields
	$(".campo").addClass("idleField");
	$(".campo").focus(function() {
		$(this).removeClass("idleField").addClass("focusField");
		if (this.value == this.defaultValue) {
			this.value = '';
		}
		if (this.value != this.defaultValue) {
			this.select();
		}
	});
	$(".campo").blur(function() {
		$(this).removeClass("focusField").addClass("idleField");
		if ($.trim(this.value) == '') {
			this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});
	
});
