/*------------ Função para onmouseover da HOME ------------ */

function bt_over(x){
	var imagem = $(x).find('img').attr('src').slice(0, -4);
	var over = imagem + '_over.jpg';
	var out = imagem + '.jpg';
	$(x).find('img').attr({ src: over});
	x.onmouseout = function onmouseout(event){
		$(x).find('img').attr({ src: out});
		}; 
}

/*------------ Função para o menu / submenu ------------ */	
$(".sub_menu").hover(function(){ //Hover effects on list-item
	$(this).addClass('active');
	$(this).find('.cont_sub').prev().addClass('seta');
	$(this).children(".cont_sub").show();
	var primeiro = $(this).parent();
	if ($(primeiro).is(".cont_sub")){
		var margem = $(this).parent().width();
		$(this).children().next().css({left: margem, top: 0});
	} else{
		return false;
	}
	}, function() {
		$(this).removeClass('active');
		$(this).children(".cont_sub").hide();
});

/*------------ Função para onmouseover da HOME ------------ */

function link_over(x){
	classe = x.className;
	x.className= classe + " over";
	x.onmouseout = function onmouseout(event){
		x.className=classe
		}; 
}

/* ------------ Função para limpar e denifir valar de um campo texto ------------ */
function limpaCampo(x,texto){
	if (x.value == texto)
		x.value = "";
	else if (x.value != "")
		x.select();
	x.onblur = function onblur(event){
		if (x.value == "")
			x.value = texto;
	};  
}

/* ------------ Função para link de div ------------ */
function link_menu(url) {  
	window.location.href = url;
}


/* ------------ PNG.FIX------------ */
(function(a){a.fn.pngie=function(c){settings=a.extend({blankgif:"http://upload.wikimedia.org/wikipedia/commons/c/ce/Transparent.gif",sizingMethod:"crop"},c);if(a.browser.msie&&parseInt(a.browser.version,10)<7){var b=function(){if(!/^progid\:DXImageTransform\.Microsoft\.AlphaImageLoader/.test(this.runtimeStyle.filter)&&a(this).width()>0){a(this).attr("width",a(this).width()).attr("height",a(this).height());this.runtimeStyle.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+a(this).attr("src")+'", sizingMethod="'+settings.sizingMethod+'");';a(this).attr("src",settings.blankgif)}};a(this).filter("[src$=.png]").add("[src$=.png]",this).each(b);a("[src$=.png]").live("mousemove",function(){a(this).each(b);a("[src$=.png]").each(b)});a("[src$=.png]").load(b);a(window).load(function(){a("[src$=.png]").each(b)});a("*",this).each(function(e){var d=a(this).css("background-image");if(typeof(d)=="string"&&d!="none"&!/^progid\:DXImageTransform\.Microsoft\.AlphaImageLoader/.test(this.runtimeStyle.filter)){d=/url\([\"\']?(.*\.png)[\"\']?\)/.exec(d);if(d&&d.length>1&&a(this).css("background-repeat").indexOf("no-")>-1){a(this).css("background-image","none").attr("contentEditable",true).attr("width",a(this).width()).attr("height",a(this).height());this.runtimeStyle.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+d[1]+'",sizingMethod="'+settings.sizingMethod+'")'}}})}return a}})(jQuery);
$(document).ready(function(){ $(document).pngie();});

/* ------------ Função para aumentar / diminuir a fonte ------------ */
( function($) {
	$.fn.fontResize = function(parms) {
		// set the options include any overrides
		var opts = $.extend( {}, $.fn.fontResize.defaults, parms);		
		this.each( function() {			
				// create the node with the links
				$(this).append(opts.defaultLabels);
				// if the cookie exists then use it
				if ($.cookie(opts.defaultCookieName)) {
					$.fn.fontResize.reSize(false, $.cookie(opts.defaultCookieName));
				}
				// bind increases
				$('.' + opts.defaultIncreaseClass).click( function() {
					$.fn.fontResize.reSize(true);
					return false;
				});
				// bind decreases
				$('.' + opts.defaultDecreaseClass).click( function() {
					$.fn.fontResize.reSize(false);
					return false;
				});
				// bind reset to default size
				$('.' + opts.defaultNormalizeClass).click( function() {
					$.fn.fontResize.reSize(false, opts.defaultSize);
					return false;
				});
			});
	};
	$.fn.fontResize.reSize = function(increase, absoluteValue) {
		// if setting absolute value use that rather than calculating new value
		if (absoluteValue) {
			$($.fn.fontResize.defaults.defaultTargetNode).css("font-size",
					absoluteValue);
			// delete the cookie if it is the default size anyway
			if (absoluteValue == $.fn.fontResize.defaults.defaultSize) {
				$.cookie($.fn.fontResize.defaults.defaultCookieName, null,$.fn.fontResize.defaults.defaultcookieParms);
			}
			return;
		}
		// calculate change factor
		var changeFactor = increase ? 1 + ($.fn.fontResize.defaults.defaultChangePercent / 100)
				: 1 - ($.fn.fontResize.defaults.defaultChangePercent / 100);
		// find existing target element to resize
		var nodeCurrentSize = $($.fn.fontResize.defaults.defaultTargetNode).css("font-size");
		// split out the numeric element
		var numericPart = parseInt(nodeCurrentSize);
		// if we got garbage leave now
		if (isNaN(numericPart)) {
			return;
		}
		// split out the units eg %,px,em
		var unitsPart = nodeCurrentSize.replace(numericPart, "");
		// calculate new font size
		var newFontSize = Math.round(parseInt(nodeCurrentSize) * changeFactor)
				+ unitsPart;
		// resize
		$($.fn.fontResize.defaults.defaultTargetNode)
				.css("font-size", newFontSize);
		return $.cookie($.fn.fontResize.defaults.defaultCookieName, newFontSize,
				$.fn.fontResize.defaults.defaultcookieParms);
	};
})(jQuery);
	$.fn.fontResize.defaults = {
		defaultTargetNode :".cont_esq",
		defaultChangePercent :5,
		defaultSize :"12px",
		defaultLabels :'',
		defaultDecreaseClass :"diminui",
		defaultIncreaseClass :"aumenta",
		defaultNormalizeClass :"normal",
		defaultInsertionNode :"fontResizer",
		defaultCookieName :"fontResizer",
		defaultcookieParms : {
			expires :3,
			path :'/'
			}
	};
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
