///* jQuery Carousel 0.9.5 - http://thomlx.free.fr/jquery/jquery_carousel.htm
(function(c){c.fn.carousel=function(j){var j=c.extend({direction:"horizontal",loop:false,dispItems:1,pagination:false,paginationPosition:"inside",nextBtn:'<a role="button">Next</a>',prevBtn:'<a role="button">Previous</a>',btnsPosition:"inside",nextBtnInsert:"appendTo",prevBtnInsert:"prependTo",nextBtnInsertFn:false,prevBtnInsertFn:false,autoSlide:false,autoSlideInterval:3000,delayAutoSlide:false,combinedClasses:false,effect:"slide",slideEasing:"swing",animSpeed:"normal",equalWidths:"true",verticalMargin:0,callback:function(){},useAddress:false,adressIdentifier:"carousel",tabLabel:function(k){return k},showEmptyItems:true},j);if(j.btnsPosition=="outside"){j.prevBtnInsert="insertBefore";j.nextBtnInsert="insertAfter"}j.delayAutoSlide=j.delayAutoSlide||j.autoSlideInterval;return this.each(function(){var k={$elts:{},params:j,launchOnLoad:[]};k.$elts.carousel=c(this).addClass("js");k.$elts.content=c(this).children().css({position:"absolute",top:0});k.$elts.wrap=k.$elts.content.wrap('<div class="carousel-wrap"></div>').parent().css({overflow:"hidden",position:"relative"});k.steps={first:0,count:k.$elts.content.children().length};k.steps.last=k.steps.count-1;if(c.isFunction(k.params.prevBtnInsertFn)){k.$elts.prevBtn=k.params.prevBtnInsertFn(k.$elts)}else{k.$elts.prevBtn=c(j.prevBtn)[j.prevBtnInsert](k.$elts.carousel)}if(c.isFunction(k.params.nextBtnInsertFn)){k.$elts.nextBtn=k.params.nextBtnInsertFn(k.$elts)}else{k.$elts.nextBtn=c(j.nextBtn)[j.nextBtnInsert](k.$elts.carousel)}k.$elts.nextBtn.addClass("carousel-control next carousel-next");k.$elts.prevBtn.addClass("carousel-control previous carousel-previous");a(k);if(k.params.pagination){i(k)}h(k);c(function(){var n=k.$elts.content.children();var m=0;n.each(function(){$item=c(this);$itemHeight=$item.outerHeight();if($itemHeight>m){m=$itemHeight}});if(k.params.verticalMargin>0){m=m+k.params.verticalMargin}n.height(m);var l=k.$elts.content.children(":first");k.itemWidth=l.outerWidth();if(j.direction=="vertical"){k.contentWidth=k.itemWidth}else{if(j.equalWidths){k.contentWidth=k.itemWidth*k.steps.count}else{k.contentWidth=(function(){var o=0;k.$elts.content.children().each(function(){o+=c(this).outerWidth()});return o})()}}k.$elts.content.width(k.contentWidth);k.itemHeight=m;if(j.direction=="vertical"){k.$elts.content.css({height:k.itemHeight*k.steps.count+"px"});k.$elts.content.parent().css({height:k.itemHeight*k.params.dispItems+"px"})}else{k.$elts.content.parent().css({height:k.itemHeight+"px"})}d(k);c.each(k.launchOnLoad,function(o,p){p()});if(k.params.autoSlide){window.setTimeout(function(){k.autoSlideInterval=window.setInterval(function(){b(k,e(k,"next"))},k.params.autoSlideInterval)},k.params.delayAutoSlide)}})})};function a(j){j.$elts.nextBtn.add(j.$elts.prevBtn).bind("enable",function(){var k=c(this).unbind("click").bind("click",function(){b(j,e(j,(k.is(".next")?"next":"prev")));g(j)}).removeClass("disabled");if(j.params.combinedClasses){k.removeClass("next-disabled previous-disabled")}}).bind("disable",function(){var k=c(this).unbind("click").addClass("disabled");if(j.params.combinedClasses){if(k.is(".next")){k.addClass("next-disabled")}else{if(k.is(".previous")){k.addClass("previous-disabled")}}}}).hover(function(){c(this).toggleClass("hover")})}function i(j){j.$elts.pagination=c('<div class="center-wrap"><div class="carousel-pagination"><p></p></div></div>')[((j.params.paginationPosition=="outside")?"insertAfter":"appendTo")](j.$elts.carousel).find("p");j.$elts.paginationBtns=c([]);j.$elts.content.find("li").each(function(k){if(k%j.params.dispItems==0){j.$elts.paginationBtns=j.$elts.paginationBtns.add(c('<a role="button"><span>'+j.params.tabLabel(j.$elts.paginationBtns.length+1)+"</span></a>").data("firstStep",k))}});j.$elts.paginationBtns.each(function(){c(this).appendTo(j.$elts.pagination)});j.$elts.paginationBtns.slice(0,1).addClass("active");j.launchOnLoad.push(function(){j.$elts.paginationBtns.click(function(k){b(j,c(this).data("firstStep"));g(j)})})}function h(j){if(j.params.useAddress&&c.isFunction(c.fn.address)){c.address.init(function(l){var k=c.address.pathNames();if(k[0]===j.params.adressIdentifier&&!!k[1]){b(j,k[1]-1)}else{c.address.value("/"+j.params.adressIdentifier+"/1")}}).change(function(l){var k=c.address.pathNames();if(k[0]===j.params.adressIdentifier&&!!k[1]){b(j,k[1]-1)}})}else{j.params.useAddress=false}}function b(j,k){j.params.callback(k);f(j,k);j.steps.first=k;d(j);if(j.params.useAddress){c.address.value("/"+j.params.adressIdentifier+"/"+(k+1))}}function e(k,j){if(j=="prev"){if(!k.params.showEmptyItems){if(k.steps.first==0){return((k.params.loop)?(k.steps.count-k.params.dispItems):false)}else{return Math.max(0,k.steps.first-k.params.dispItems)}}else{if((k.steps.first-k.params.dispItems)>=0){return k.steps.first-k.params.dispItems}else{return((k.params.loop)?(k.steps.count-k.params.dispItems):false)}}}else{if(j=="next"){if((k.steps.first+k.params.dispItems)<k.steps.count){if(!k.params.showEmptyItems){return Math.min(k.steps.first+k.params.dispItems,k.steps.count-k.params.dispItems)}else{return k.steps.first+k.params.dispItems}}else{return((k.params.loop)?0:false)}}}}function f(j,k){switch(j.params.effect){case"no":if(j.params.direction=="vertical"){j.$elts.content.css("top",-(j.itemHeight*k)+"px")}else{j.$elts.content.css("left",-(j.itemWidth*k)+"px")}break;case"fade":if(j.params.direction=="vertical"){j.$elts.content.hide().css("top",-(j.itemHeight*k)+"px").fadeIn(j.params.animSpeed)}else{j.$elts.content.hide().css("left",-(j.itemWidth*k)+"px").fadeIn(j.params.animSpeed)}break;default:if(j.params.direction=="vertical"){j.$elts.content.stop().animate({top:-(j.itemHeight*k)+"px"},j.params.animSpeed,j.params.slideEasing)}else{j.$elts.content.stop().animate({left:-(j.itemWidth*k)+"px"},j.params.animSpeed,j.params.slideEasing)}break}}function d(j){if(e(j,"prev")!==false){j.$elts.prevBtn.trigger("enable")}else{j.$elts.prevBtn.trigger("disable")}if(e(j,"next")!==false){j.$elts.nextBtn.trigger("enable")}else{j.$elts.nextBtn.trigger("disable")}if(j.params.pagination){j.$elts.paginationBtns.removeClass("active").filter(function(){return(c(this).data("firstStep")==j.steps.first)}).addClass("active")}}function g(j){if(!!j.autoSlideInterval){window.clearInterval(j.autoSlideInterval)}}})(jQuery);

//livequery v 1.0.3
(function($){$.extend($.fn,{livequery:function(type,fn,fn2){var self=this,q;if($.isFunction(type))fn2=fn,fn=type,type=undefined;$.each($.livequery.queries,function(i,query){if(self.selector==query.selector&&self.context==query.context&&type==query.type&&(!fn||fn.$lqguid==query.fn.$lqguid)&&(!fn2||fn2.$lqguid==query.fn2.$lqguid))return (q=query)&&false});q=q||new $.livequery(this.selector,this.context,type,fn,fn2);q.stopped=false;q.run();return this},expire:function(type,fn,fn2){var self=this;if($.isFunction(type))fn2=fn,fn=type,type=undefined;$.each($.livequery.queries,function(i,query){self.selector==query.selector&&self.context==query.context&&(!type||type==query.type)&&(!fn||fn.$lqguid==query.fn.$lqguid)&&(!fn2||fn2.$lqguid==query.fn2.$lqguid)&&!this.stopped&&$.livequery.stop(query.id)});return this}});$.livequery=function(selector,context,type,fn,fn2){this.selector=selector;this.context=context||document;this.type=type;this.fn=fn;this.fn2=fn2;this.elements=[];this.stopped=false;this.id=$.livequery.queries.push(this)-1;fn.$lqguid=fn.$lqguid||$.livequery.guid++;if(fn2)fn2.$lqguid=fn2.$lqguid||$.livequery.guid++;return this};$.livequery.prototype={stop:function(){var query=this;if(this.type)this.elements.unbind(this.type,this.fn);else this.fn2&&this.elements.each(function(i,el){query.fn2.apply(el)});this.elements=[];this.stopped=true},run:function(){if(this.stopped)return;var query=this,oEls=this.elements,els=$(this.selector,this.context),nEls=els.not(oEls);this.elements=els;if(this.type){nEls.bind(this.type,this.fn);oEls.length>0&&$.each(oEls,function(i,el){$.inArray(el,els)<0&&$.event.remove(el,query.type,query.fn)})}else{nEls.each(function(){query.fn.apply(this)});this.fn2&&oEls.length>0&&$.each(oEls,function(i,el){$.inArray(el,els)<0&&query.fn2.apply(el)})}}};$.extend($.livequery,{guid:0,queries:[],queue:[],running:false,timeout:null,checkQueue:function(){if($.livequery.running&&$.livequery.queue.length){var length=$.livequery.queue.length;while(length--)$.livequery.queries[$.livequery.queue.shift()].run()}},pause:function(){$.livequery.running=false},play:function(){$.livequery.running=true;$.livequery.run()},registerPlugin:function(){$.each(arguments,function(i,n){if(!$.fn[n])return;var old=$.fn[n];$.fn[n]=function(){var r=old.apply(this,arguments);$.livequery.run();return r}})},run:function(id){if(id!=undefined)$.inArray(id,$.livequery.queue)<0&&$.livequery.queue.push(id);else $.each($.livequery.queries,function(id){$.inArray(id,$.livequery.queue)<0&&$.livequery.queue.push(id)});$.livequery.timeout&&clearTimeout($.livequery.timeout);$.livequery.timeout=setTimeout($.livequery.checkQueue,20)},stop:function(id){if(id!=undefined)$.livequery.queries[id].stop();else $.each($.livequery.queries,function(id){$.livequery.queries[id].stop()})}});$.livequery.registerPlugin("append","prepend","after","before","wrap","attr","removeAttr","addClass","removeClass","toggleClass","empty","remove");$(function(){$.livequery.play()});var init=$.prototype.init;$.prototype.init=function(a,c){var r=init.apply(this,arguments);if(a&&a.selector)r.context=a.context,r.selector=a.selector;if(typeof a=="string")r.context=c||document,r.selector=a;return r};$.prototype.init.prototype=$.prototype})(jQuery);

//jquery browser
(function($){$.browserTest=function(a,z){var u='unknown',x='X',m=function(r,h){for(var i=0;i<h.length;i=i+1){r=r.replace(h[i][0],h[i][1]);}return r;},c=function(i,a,b,c){var r={name:m((a.exec(i)||[u,u])[1],b)};r[r.name]=true;r.version=(c.exec(i)||[x,x,x,x])[3];if(r.name.match(/safari/)&&r.version>400){r.version='2.0';}if(r.name==='presto'){r.version=($.browser.version>9.27)?'futhark':'linear_b';}r.versionNumber=parseFloat(r.version,10)||0;r.versionX=(r.version!==x)?(r.version+'').substr(0,1):x;r.className=r.name+r.versionX;return r;};a=(a.match(/Opera|Navigator|Minefield|KHTML|Chrome/)?m(a,[[/(Firefox|MSIE|KHTML,\slike\sGecko|Konqueror)/,''],['Chrome Safari','Chrome'],['KHTML','Konqueror'],['Minefield','Firefox'],['Navigator','Netscape']]):a).toLowerCase();$.browser=$.extend((!z)?$.browser:{},c(a,/(camino|chrome|firefox|netscape|konqueror|lynx|msie|opera|safari)/,[],/(camino|chrome|firefox|netscape|netscape6|opera|version|konqueror|lynx|msie|safari)(\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/));$.layout=c(a,/(gecko|konqueror|msie|opera|webkit)/,[['konqueror','khtml'],['msie','trident'],['opera','presto']],/(applewebkit|rv|konqueror|msie)(\:|\/|\s)([a-z0-9\.]*?)(\;|\)|\s)/);$.os={name:(/(win|mac|linux|sunos|solaris|iphone)/.exec(navigator.platform.toLowerCase())||[u])[0].replace('sunos','solaris')};if(!z){$('html').addClass([$.os.name,$.browser.name,$.browser.className,$.layout.name,$.layout.className].join(' '));}};$.browserTest(navigator.userAgent);})(jQuery);

//jquery corner
(function(a) { var d = "round", g = "transparent", b = "width", c = "div", h = document.createElement(c).style, f = h["MozBorderRadius"] !== undefined, i = h["WebkitBorderRadius"] !== undefined, e = h["borderRadius"] !== undefined || h["BorderRadius"] !== undefined, l = document.documentMode || 0, n = a.browser.msie && (a.browser.version < 8 && !l || l < 8), k = a.browser.msie && function() { var a = document.createElement(c); try { a.style.setExpression(b, "0+0"); a.style.removeExpression(b) } catch (d) { return false } return true } (); a.support = a.support || {}; a.support.borderRadius = f || i || e; function m(b, c) { return parseInt(a.css(b, c)) || 0 } function j(a) { var a = parseInt(a).toString(16); return a.length < 2 ? "0" + a : a } function p(c) { while (c) { var b = a.css(c, "backgroundColor"), d; if (b && b != g && b != "rgba(0, 0, 0, 0)") { if (b.indexOf("rgb") >= 0) { d = b.match(/\d+/g); return "#" + j(d[0]) + j(d[1]) + j(d[2]) } return b } if (c.nodeName.toLowerCase() == "html") break; c = c.parentNode } return "#ffffff" } function o(c, b, a) { switch (c) { case d: return Math.round(a * (1 - Math.cos(Math.asin(b / a)))); case "cool": return Math.round(a * (1 + Math.cos(Math.asin(b / a)))); case "sharp": return Math.round(a * (1 - Math.cos(Math.acos(b / a)))); case "bite": return Math.round(a * Math.cos(Math.asin((a - b - 1) / a))); case "slide": return Math.round(a * Math.atan2(b, a / b)); case "jut": return Math.round(a * Math.atan2(a, a - b - 1)); case "curl": return Math.round(a * Math.atan(b)); case "tear": return Math.round(a * Math.cos(b)); case "wicked": return Math.round(a * Math.tan(b)); case "long": return Math.round(a * Math.sqrt(b)); case "sculpt": return Math.round(a * Math.log(a - b - 1, a)); case "dogfold": case "dog": return b & 1 ? b + 1 : a; case "dog2": return b & 2 ? b + 1 : a; case "dog3": return b & 3 ? b + 1 : a; case "fray": return b % 2 * a; case "notch": return a; case "bevelfold": case "bevel": return b + 1 } } a.fn.corner = function(j) { var h = this; if (h.length == 0) { if (!a.isReady && h.selector) { var q = h.selector, l = h.context; a(function() { a(q, l).corner(j) }) } return h } return h.each(function() { var t = "px -", B = "absolute", A = "relative", E = "position", v = "none", z = "solid", s = "1px", h = "px", l = this, I = a(l), y = [I.attr(a.fn.corner.defaults.metaAttr) || "", j || ""].join(" ").toLowerCase(), V = /keep/.test(y), R = (y.match(/cc:(#[0-9a-f]+)/) || [])[1], T = (y.match(/sc:(#[0-9a-f]+)/) || [])[1], u = parseInt((y.match(/(\d+)px/) || [])[1]) || 10, W = /round|bevelfold|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dogfold|dog/, S = (y.match(W) || [d])[0], U = /dogfold|bevelfold/.test(y), P = { T: 0, B: 1 }, q = { TL: /top|tl|left/.test(y), TR: /top|tr|right/.test(y), BL: /bottom|bl|left/.test(y), BR: /bottom|br|right/.test(y) }, G, C, O, H, w, x, r, Q, L, N, K, D, M, F; if (!q.TL && !q.TR && !q.BL && !q.BR) q = { TL: 1, TR: 1, BL: 1, BR: 1 }; if (a.fn.corner.defaults.useNative && S == d && (e || f || i) && !R && !T) { q.TL && I.css(e ? "border-top-left-radius" : f ? "-moz-border-radius-topleft" : "-webkit-border-top-left-radius", u + h); q.TR && I.css(e ? "border-top-right-radius" : f ? "-moz-border-radius-topright" : "-webkit-border-top-right-radius", u + h); q.BL && I.css(e ? "border-bottom-left-radius" : f ? "-moz-border-radius-bottomleft" : "-webkit-border-bottom-left-radius", u + h); q.BR && I.css(e ? "border-bottom-right-radius" : f ? "-moz-border-radius-bottomright" : "-webkit-border-bottom-right-radius", u + h); return } G = document.createElement(c); a(G).css({ overflow: "hidden", height: s, minHeight: s, fontSize: s, backgroundColor: T || g, borderStyle: z }); C = { T: parseInt(a.css(l, "paddingTop")) || 0, R: parseInt(a.css(l, "paddingRight")) || 0, B: parseInt(a.css(l, "paddingBottom")) || 0, L: parseInt(a.css(l, "paddingLeft")) || 0 }; if (typeof l.style.zoom != undefined) l.style.zoom = 1; if (!V) l.style.border = v; G.style.borderColor = R || p(l.parentNode); O = a(l).outerHeight(); for (H in P) { w = P[H]; if (w && (q.BL || q.BR) || !w && (q.TL || q.TR)) { G.style.borderStyle = "none " + (q[H + "R"] ? z : v) + " none " + (q[H + "L"] ? z : v); x = document.createElement(c); a(x).addClass("jquery-corner"); r = x.style; w ? l.appendChild(x) : l.insertBefore(x, l.firstChild); if (w && O != "auto") { if (a.css(l, E) == "static") l.style.position = A; r.position = B; r.bottom = r.left = r.padding = r.margin = "0"; if (k) r.setExpression(b, "this.parentNode.offsetWidth"); else r.width = "100%" } else if (!w && a.browser.msie) { if (a.css(l, E) == "static") l.style.position = A; r.position = B; r.top = r.left = r.right = r.padding = r.margin = "0"; if (k) { Q = m(l, "borderLeftWidth") + m(l, "borderRightWidth"); r.setExpression(b, "this.parentNode.offsetWidth - " + Q + '+ "px"') } else r.width = "100%" } else { r.position = A; r.margin = !w ? "-" + C.T + t + C.R + "px " + (C.T - u) + t + C.L + h : C.B - u + t + C.R + t + C.B + t + C.L + h } for (L = 0; L < u; L++) { N = Math.max(0, o(S, L, u)); K = G.cloneNode(false); K.style.borderWidth = "0 " + (q[H + "R"] ? N : 0) + "px 0 " + (q[H + "L"] ? N : 0) + h; w ? x.appendChild(K) : x.insertBefore(K, x.firstChild) } if (U && a.support.boxModel) { if (w && n) continue; for (D in q) { if (!q[D]) continue; if (w && (D == "TL" || D == "TR")) continue; if (!w && (D == "BL" || D == "BR")) continue; M = { position: B, border: v, margin: 0, padding: 0, overflow: "hidden", backgroundColor: G.style.borderColor }; F = a("<div/>").css(M).css({ width: u + h, height: s }); switch (D) { case "TL": F.css({ bottom: 0, left: 0 }); break; case "TR": F.css({ bottom: 0, right: 0 }); break; case "BL": F.css({ top: 0, left: 0 }); break; case "BR": F.css({ top: 0, right: 0 }) } x.appendChild(F[0]); var J = a("<div/>").css(M).css({ top: 0, bottom: 0, width: s, height: u + h }); switch (D) { case "TL": J.css({ left: u }); break; case "TR": J.css({ right: u }); break; case "BL": J.css({ left: u }); break; case "BR": J.css({ right: u }) } x.appendChild(J[0]) } } } } }) }; a.fn.uncorner = function() { (e || f || i) && this.css(e ? "border-radius" : f ? "-moz-border-radius" : "-webkit-border-radius", 0); a("div.jquery-corner", this).remove(); return this }; a.fn.corner.defaults = { useNative: true, metaAttr: "data-corner"} })(jQuery);

/* jTwitter 1.1.1 - Twitter API abstraction plugin for jQuery - http://jquery-howto.blogspot.com */
(function(b){b.extend({jTwitter:function(d,a,c){if(!(d=="undefined"||a=="undefined")){if(b.isFunction(a)){c=a;a=5}b.getJSON("http://twitter.com/status/user_timeline/"+d+".json?count="+a+"&callback=?",function(e){b.isFunction(c)&&c.call(this,e)})}}})})(jQuery);

/** jQuery Meio Mask
 * @version: 1.1.3
 * Created by Fabio M. Costa on 2008-09-16. Please report any bug at http://www.meiocodigo.com
 * Copyright (c) 2008 Fabio M. Costa http://www.meiocodigo.com
 * The MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
(function(D){var C=(window.orientation!=undefined),A=((D.browser.opera||(D.browser.mozilla&&parseFloat(D.browser.version.substr(0,3))<1.9))?"input":"paste");D.event.special.paste={setup:function(){if(this.addEventListener){this.addEventListener(A,B,false)}else{if(this.attachEvent){this.attachEvent(A,B)}}},teardown:function(){if(this.removeEventListener){this.removeEventListener(A,B,false)}else{if(this.detachEvent){this.detachEvent(A,B)}}}};function B(F){var E=this;F=D.event.fix(F||window.e);F.type="paste";setTimeout(function(){D.event.handle.call(E,F)},1)}D.extend({mask:{rules:{"z":/[a-z]/,"Z":/[A-Z]/,"a":/[a-zA-Z]/,"*":/[0-9a-zA-Z]/,"@":/[0-9a-zA-ZçÇáàãâéèêíìóòôõúùü]/},keyRepresentation:{8:"backspace",9:"tab",13:"enter",16:"shift",17:"control",18:"alt",27:"esc",33:"page up",34:"page down",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"delete",116:"f5",123:"f12",224:"command"},iphoneKeyRepresentation:{10:"go",127:"delete"},signals:{"+":"","-":"-"},options:{attr:"alt",mask:null,type:"fixed",maxLength:-1,defaultValue:"",signal:false,textAlign:true,selectCharsOnFocus:true,autoTab:true,setSize:false,fixedChars:"[(),.:/ -]",onInvalid:function(){},onValid:function(){},onOverflow:function(){}},masks:{"phone":{mask:"(99) 9999-9999"},"phone-us":{mask:"(999) 999-9999"},"cpf":{mask:"999.999.999-99"},"cnpj":{mask:"99.999.999/9999-99"},"date":{mask:"39/19/9999"},"date-us":{mask:"19/39/9999"},"cep":{mask:"99999-999"},"time":{mask:"29:59"},"cc":{mask:"9999 9999 9999 9999"},"integer":{mask:"999.999.999.999",type:"reverse"},"decimal":{mask:"99,999.999.999.999",type:"reverse",defaultValue:"000"},"decimal-us":{mask:"99.999,999,999,999",type:"reverse",defaultValue:"000"},"signed-decimal":{mask:"99,999.999.999.999",type:"reverse",defaultValue:"+000"},"signed-decimal-us":{mask:"99,999.999.999.999",type:"reverse",defaultValue:"+000"}},init:function(){if(!this.hasInit){var E=this,F,G=(C)?this.iphoneKeyRepresentation:this.keyRepresentation;this.ignore=false;for(F=0;F<=9;F++){this.rules[F]=new RegExp("[0-"+F+"]")}this.keyRep=G;this.ignoreKeys=[];D.each(G,function(H){E.ignoreKeys.push(parseInt(H))});this.hasInit=true}},set:function(I,F){var E=this,G=D(I),H="maxLength";F=F||{};this.init();return G.each(function(){if(F.attr){E.options.attr=F.attr}var O=D(this),Q=D.extend({},E.options),N=O.attr(Q.attr),J="";J=(typeof F=="string")?F:(N!="")?N:null;if(J){Q.mask=J}if(E.masks[J]){Q=D.extend(Q,E.masks[J])}if(typeof F=="object"&&F.constructor!=Array){Q=D.extend(Q,F)}if(D.metadata){Q=D.extend(Q,O.metadata())}if(Q.mask!=null){if(O.data("mask")){E.unset(O)}var K=Q.defaultValue,L=(Q.type=="reverse"),M=new RegExp(Q.fixedChars,"g");if(Q.maxLength==-1){Q.maxLength=O.attr(H)}Q=D.extend({},Q,{fixedCharsReg:new RegExp(Q.fixedChars),fixedCharsRegG:M,maskArray:Q.mask.split(""),maskNonFixedCharsArray:Q.mask.replace(M,"").split("")});if((Q.type=="fixed"||L)&&Q.setSize&&!O.attr("size")){O.attr("size",Q.mask.length)}if(L&&Q.textAlign){O.css("text-align","right")}if(this.value!=""||K!=""){var P=E.string((this.value!="")?this.value:K,Q);this.defaultValue=P;O.val(P)}if(Q.type=="infinite"){Q.type="repeat"}O.data("mask",Q);O.removeAttr(H);O.bind("keydown.mask",{func:E._onKeyDown,thisObj:E},E._onMask).bind("keypress.mask",{func:E._onKeyPress,thisObj:E},E._onMask).bind("keyup.mask",{func:E._onKeyUp,thisObj:E},E._onMask).bind("paste.mask",{func:E._onPaste,thisObj:E},E._onMask).bind("focus.mask",E._onFocus).bind("blur.mask",E._onBlur).bind("change.mask",E._onChange)}})},unset:function(F){var E=D(F);return E.each(function(){var H=D(this);if(H.data("mask")){var G=H.data("mask").maxLength;if(G!=-1){H.attr("maxLength",G)}H.unbind(".mask").removeData("mask")}})},string:function(J,F){this.init();var I={};if(typeof J!="string"){J=String(J)}switch(typeof F){case"string":if(this.masks[F]){I=D.extend(I,this.masks[F])}else{I.mask=F}break;case"object":I=F}if(!I.fixedChars){I.fixedChars=this.options.fixedChars}var E=new RegExp(I.fixedChars),G=new RegExp(I.fixedChars,"g");if((I.type=="reverse")&&I.defaultValue){if(typeof this.signals[I.defaultValue.charAt(0)]!="undefined"){var H=J.charAt(0);I.signal=(typeof this.signals[H]!="undefined")?this.signals[H]:this.signals[I.defaultValue.charAt(0)];I.defaultValue=I.defaultValue.substring(1)}}return this.__maskArray(J.split(""),I.mask.replace(G,"").split(""),I.mask.split(""),I.type,I.maxLength,I.defaultValue,E,I.signal)},_onFocus:function(G){var F=D(this),E=F.data("mask");E.inputFocusValue=F.val();E.changed=false;if(E.selectCharsOnFocus){F.select()}},_onBlur:function(G){var F=D(this),E=F.data("mask");if(E.inputFocusValue!=F.val()&&!E.changed){F.trigger("change")}},_onChange:function(E){D(this).data("mask").changed=true},_onMask:function(E){var G=E.data.thisObj,F={};F._this=E.target;F.$this=D(F._this);if(F.$this.attr("readonly")){return true}F.data=F.$this.data("mask");F[F.data.type]=true;F.value=F.$this.val();F.nKey=G.__getKeyNumber(E);F.range=G.__getRange(F._this);F.valueArray=F.value.split("");return E.data.func.call(G,E,F)},_onKeyDown:function(F,G){this.ignore=D.inArray(G.nKey,this.ignoreKeys)>-1||F.ctrlKey||F.metaKey||F.altKey;if(this.ignore){var E=this.keyRep[G.nKey];G.data.onValid.call(G._this,E?E:"",G.nKey)}return C?this._keyPress(F,G):true},_onKeyUp:function(E,F){if(F.nKey==9||F.nKey==16){return true}if(F.data.type=="repeat"){this.__autoTab(F);return true}return this._onPaste(E,F)},_onPaste:function(F,G){if(G.reverse){this.__changeSignal(F.type,G)}var E=this.__maskArray(G.valueArray,G.data.maskNonFixedCharsArray,G.data.maskArray,G.data.type,G.data.maxLength,G.data.defaultValue,G.data.fixedCharsReg,G.data.signal);G.$this.val(E);if(!G.reverse&&G.data.defaultValue.length&&(G.range.start==G.range.end)){this.__setRange(G._this,G.range.start,G.range.end)}if((D.browser.msie||D.browser.safari)&&!G.reverse){this.__setRange(G._this,G.range.start,G.range.end)}if(this.ignore){return true}this.__autoTab(G);return true},_onKeyPress:function(L,E){if(this.ignore){return true}if(E.reverse){this.__changeSignal(L.type,E)}var M=String.fromCharCode(E.nKey),O=E.range.start,I=E.value,G=E.data.maskArray;if(E.reverse){var H=I.substr(0,O),K=I.substr(E.range.end,I.length);I=H+M+K;if(E.data.signal&&(O-E.data.signal.length>0)){O-=E.data.signal.length}}var N=I.replace(E.data.fixedCharsRegG,"").split(""),F=this.__extraPositionsTill(O,G,E.data.fixedCharsReg);E.rsEp=O+F;if(E.repeat){E.rsEp=0}if(!this.rules[G[E.rsEp]]||(E.data.maxLength!=-1&&N.length>=E.data.maxLength&&E.repeat)){E.data.onOverflow.call(E._this,M,E.nKey);return false}else{if(!this.rules[G[E.rsEp]].test(M)){E.data.onInvalid.call(E._this,M,E.nKey);return false}else{E.data.onValid.call(E._this,M,E.nKey)}}var J=this.__maskArray(N,E.data.maskNonFixedCharsArray,G,E.data.type,E.data.maxLength,E.data.defaultValue,E.data.fixedCharsReg,E.data.signal,F);E.$this.val(J);return(E.reverse)?this._keyPressReverse(L,E):(E.fixed)?this._keyPressFixed(L,E):true},_keyPressFixed:function(E,F){if(F.range.start==F.range.end){if((F.rsEp==0&&F.value.length==0)||F.rsEp<F.value.length){this.__setRange(F._this,F.rsEp,F.rsEp+1)}}else{this.__setRange(F._this,F.range.start,F.range.end)}return true},_keyPressReverse:function(E,F){if(D.browser.msie&&((F.range.start==0&&F.range.end==0)||F.range.start!=F.range.end)){this.__setRange(F._this,F.value.length)}return false},__autoTab:function(F){if(F.data.autoTab&&((F.$this.val().length>=F.data.maskArray.length&&!F.repeat)||(F.data.maxLength!=-1&&F.valueArray.length>=F.data.maxLength&&F.repeat))){var E=this.__getNextInput(F._this,F.data.autoTab);if(E){F.$this.trigger("blur");E.focus().select()}}},__changeSignal:function(F,G){if(G.data.signal!==false){var E=(F=="paste")?G.value.charAt(0):String.fromCharCode(G.nKey);if(this.signals&&(typeof this.signals[E]!="undefined")){G.data.signal=this.signals[E]}}},__getKeyNumber:function(E){return(E.charCode||E.keyCode||E.which)},__maskArray:function(M,H,G,J,E,K,N,L,F){if(J=="reverse"){M.reverse()}M=this.__removeInvalidChars(M,H,J=="repeat"||J=="infinite");if(K){M=this.__applyDefaultValue.call(M,K)}M=this.__applyMask(M,G,F,N);switch(J){case"reverse":M.reverse();return(L||"")+M.join("").substring(M.length-G.length);case"infinite":case"repeat":var I=M.join("");return(E!=-1&&M.length>=E)?I.substring(0,E):I;default:return M.join("").substring(0,G.length)}return""},__applyDefaultValue:function(G){var E=G.length,F=this.length,H;for(H=F-1;H>=0;H--){if(this[H]==G.charAt(0)){this.pop()}else{break}}for(H=0;H<E;H++){if(!this[H]){this[H]=G.charAt(H)}}return this},__removeInvalidChars:function(H,G,E){for(var F=0,I=0;F<H.length;F++){if(G[I]&&this.rules[G[I]]&&!this.rules[G[I]].test(H[F])){H.splice(F,1);if(!E){I--}F--}if(!E){I++}}return H},__applyMask:function(H,F,I,E){if(typeof I=="undefined"){I=0}for(var G=0;G<H.length+I;G++){if(F[G]&&E.test(F[G])){H.splice(G,0,F[G])}}return H},__extraPositionsTill:function(H,F,E){var G=0;while(E.test(F[H++])){G++}return G},__getNextInput:function(N,F){var I=N.form.elements,H=D.inArray(N,I)+1,M=null,J;for(J=H;J<I.length;J++){M=D(I[J]);if(this.__isNextInput(M,F)){return M}}var E=document.forms,G=D.inArray(N.form,E)+1,L,K=null;for(L=G;L<E.length;L++){K=E[L].elements;for(J=0;J<K.length;J++){M=D(K[J]);if(this.__isNextInput(M,F)){return M}}}return null},__isNextInput:function(G,E){var F=G.get(0);return F&&(F.offsetWidth>0||F.offsetHeight>0)&&F.nodeName!="FIELDSET"&&(E===true||(typeof E=="string"&&G.is(E)))},__setRange:function(G,H,E){if(typeof E=="undefined"){E=H}if(G.setSelectionRange){G.setSelectionRange(H,E)}else{var F=G.createTextRange();F.collapse();F.moveStart("character",H);F.moveEnd("character",E-H);F.select()}},__getRange:function(F){if(!D.browser.msie){return{start:F.selectionStart,end:F.selectionEnd}}var G={start:0,end:0},E=document.selection.createRange();G.start=0-E.duplicate().moveStart("character",-100000);G.end=G.start+E.text.length;return G},unmaskedVal:function(E){return D(E).val().replace(D.mask.fixedCharsRegG,"")}}});D.fn.extend({setMask:function(E){return D.mask.set(this,E)},unsetMask:function(){return D.mask.unset(this)},unmaskedVal:function(){return D.mask.unmaskedVal(this[0])}})})(jQuery);

// jQuery Alert Dialogs Plugin
// Version 1.1
// Cory S.N. LaViska
// Visit http://abeautifulsite.net/notebook/87 for more information//
//		jAlert( message, [title, callback] )
//		jConfirm( message, [title, callback] )
//		jPrompt( message, [value, title, callback] )
// License: This plugin is dual-licensed under the GNU General Public License and the MIT License and is copyright 2008 A Beautiful Site, LLC. 
//
//minimizado @ http://refresh-sf.com/yui/
(function(a){a.alerts={verticalOffset:-75,horizontalOffset:0,repositionOnResize:true,overlayOpacity:0.01,overlayColor:"#FFF",draggable:true,okButton:"&nbsp;OK&nbsp;",cancelButton:"&nbsp;Cancel&nbsp;",dialogClass:null,alert:function(b,c,d){if(c==null){c="Alert"}a.alerts._show(c,b,null,"alert",function(e){if(d){d(e)}})},confirm:function(b,c,d){if(c==null){c="Confirm"}a.alerts._show(c,b,null,"confirm",function(e){if(d){d(e)}})},prompt:function(b,c,d,e){if(d==null){d="Prompt"}a.alerts._show(d,b,c,"prompt",function(f){if(e){e(f)}})},_show:function(g,f,c,b,i){a.alerts._hide();a.alerts._overlay("show");a("BODY").append('<div id="popup_container"><h1 id="popup_title"></h1><div id="popup_content"><div id="popup_message"></div></div></div>');if(a.alerts.dialogClass){a("#popup_container").addClass(a.alerts.dialogClass)}var h=(a.browser.msie&&parseInt(a.browser.version)<=6)?"absolute":"fixed";a("#popup_container").css({position:h,zIndex:99999,padding:0,margin:0});a("#popup_title").text(g);a("#popup_content").addClass(b);a("#popup_message").text(f);a("#popup_message").html(a("#popup_message").text().replace(/\n/g,"<br />"));a("#popup_container").css({minWidth:a("#popup_container").outerWidth(),maxWidth:a("#popup_container").outerWidth()});a.alerts._reposition();a.alerts._maintainPosition(true);switch(b){case"alert":a("#popup_message").after('<div id="popup_panel"><input type="button" value="'+a.alerts.okButton+'" id="popup_ok" /></div>');a("#popup_ok").click(function(){a.alerts._hide();i(true)});a("#popup_ok").focus().keypress(function(j){if(j.keyCode==13||j.keyCode==27){a("#popup_ok").trigger("click")}});break;case"confirm":a("#popup_message").after('<div id="popup_panel"><input type="button" value="'+a.alerts.okButton+'" id="popup_ok" /> <input type="button" value="'+a.alerts.cancelButton+'" id="popup_cancel" /></div>');a("#popup_ok").click(function(){a.alerts._hide();if(i){i(true)}});a("#popup_cancel").click(function(){a.alerts._hide();if(i){i(false)}});a("#popup_ok").focus();a("#popup_ok, #popup_cancel").keypress(function(j){if(j.keyCode==13){a("#popup_ok").trigger("click")}if(j.keyCode==27){a("#popup_cancel").trigger("click")}});break;case"prompt":a("#popup_message").append('<br /><input type="text" size="30" id="popup_prompt" />').after('<div id="popup_panel"><input type="button" value="'+a.alerts.okButton+'" id="popup_ok" /> <input type="button" value="'+a.alerts.cancelButton+'" id="popup_cancel" /></div>');a("#popup_prompt").width(a("#popup_message").width());a("#popup_ok").click(function(){var e=a("#popup_prompt").val();a.alerts._hide();if(i){i(e)}});a("#popup_cancel").click(function(){a.alerts._hide();if(i){i(null)}});a("#popup_prompt, #popup_ok, #popup_cancel").keypress(function(j){if(j.keyCode==13){a("#popup_ok").trigger("click")}if(j.keyCode==27){a("#popup_cancel").trigger("click")}});if(c){a("#popup_prompt").val(c)}a("#popup_prompt").focus().select();break}if(a.alerts.draggable){try{a("#popup_container").draggable({handle:a("#popup_title")});a("#popup_title").css({cursor:"move"})}catch(d){}}},_hide:function(){a("#popup_container").remove();a.alerts._overlay("hide");a.alerts._maintainPosition(false)},_overlay:function(b){switch(b){case"show":a.alerts._overlay("hide");a("BODY").append('<div id="popup_overlay"></div>');a("#popup_overlay").css({position:"absolute",zIndex:99998,top:"0px",left:"0px",width:"100%",height:a(document).height(),background:a.alerts.overlayColor,opacity:a.alerts.overlayOpacity});break;case"hide":a("#popup_overlay").remove();break}},_reposition:function(){var c=((a(window).height()/2)-(a("#popup_container").outerHeight()/2))+a.alerts.verticalOffset;var b=((a(window).width()/2)-(a("#popup_container").outerWidth()/2))+a.alerts.horizontalOffset;if(c<0){c=0}if(b<0){b=0}if(a.browser.msie&&parseInt(a.browser.version)<=6){c=c+a(window).scrollTop()}a("#popup_container").css({top:c+"px",left:b+"px"});a("#popup_overlay").height(a(document).height())},_maintainPosition:function(b){if(a.alerts.repositionOnResize){switch(b){case true:a(window).bind("resize",a.alerts._reposition);break;case false:a(window).unbind("resize",a.alerts._reposition);break}}}};jAlert=function(b,c,d){a.alerts.alert(b,c,d)};jConfirm=function(b,c,d){a.alerts.confirm(b,c,d)};jPrompt=function(b,c,d,e){a.alerts.prompt(b,c,d,e)}})(jQuery);

(function($) {

    window.alert = function(mensagem, titulo, callback) {
        mensagem = mensagem || 'Mensagem';
        titulo   = titulo || 'Mensagem';
        callback = callback || function(){};
        
        $("object, embed").hide();
        
        jAlert(mensagem, titulo, function(e){
            $("object, embed").show();
            callback.call();                 
        });
        //return proxied.apply(this, arguments);
    }

    $.fn.navegador = function() {
        navegador = $.browser.name;

        if (navegador == 'undefined') {
            alert('plugin "jQuery Browser" nao encontrado');
            return;
        }
        versao = ($.browser.version).split(".")[0];

        $("body")
		.addClass(navegador)
		.addClass(navegador + versao);
    }

    identificarResolucao = function() {
        resolucao = "res" + screen.width;
        areaVisivel = $("body").width();
        //$("#componente").prepend("<br>"+ resolucao);
        classe = 'res';

        if (areaVisivel < 800)
            classe += '800';
        else if (areaVisivel < 960)
            classe += '960';
        else if (areaVisivel < 1024)
            classe += '1024';
        else if (areaVisivel < 1088)
            classe += '1088';
        else if (areaVisivel < 1152)
            classe += '1152';
        else if (areaVisivel < 1280)
            classe += '1280';
        else if (areaVisivel < 1360)
            classe += '1360';
        else if (areaVisivel < 1440)
            classe += '1440';
        else if (areaVisivel < 1600)
            classe += '1600';
        else if (areaVisivel < 1680)
            classe += '1680';

        classes = $("body").attr("class");
        _classes = classes.split(" ");
        for (var c in _classes) {
            removerClasse(c);
        }

        function removerClasse(c) {
            $("body").removeClass(c);
        }

        $("body").addClass(classe);

        /* -------------------------------------------
        RESOLUÇÃO -> ÁREA VISÍVEL (CHROME)
        1920 -> ?
        1680 -> ?
        1600 -> ?
        1440 -> 1423
        1360 -> 1343
        1280 -> 1263
        1152 -> 1135
        1088 -> 1071
        1024 -> 1007
        960 -> 946
        800 -> 783
        ----------------------------------------------*/
    }

    msg = function(txt) {
        window.console ? console.log(txt) : alert(txt);
    }

    $.fn.debug = function() {
        return this.each(function(i) {
            window.console ? console.log(this) : null;
        });
    }

    /* destacar um elemento
    default: firstEvent:focus | activeClass:onFocus | lastEvent:blur
    modo de usar:
    $("input:text, input:password, textarea").highlight();
    $("ul li").highlight({ firstEvent:'mouseover', activeClass:'hover', lastEvent:'mouseout' });
    */
    $.fn.highlight = function(options) {
        var settings = jQuery.extend({
            activeClass: 'onFocus',
            firstEvent: 'focus',
            lastEvent: 'blur'
        }, options);

        return $(this)
		.live(settings.firstEvent, function() {
		    $(this).addClass(settings.activeClass)
		})
		.live(settings.lastEvent, function() {
		    $(this).removeClass(settings.activeClass)
		});
    }

    /* kill default event
    usage: myfunction(e){ kill(e); doStuffs() }
    */
    kill = function(e) {
        if (!e) e = window.event;
        (e.stopPropagation) ? e.stopPropagation() : e.cancelBubble = true;
        (e.preventDefault) ? e.preventDefault() : e.returnValue = false;
        return false;
    }

    /* ir para uma pagina
    usage: goto('index.php') */
    goto = function(url) {
        window.location = url;
    }

    $.fn.inlineLabel = function() {
        return this.each(function() {
            var input = $(this);

            if ($.trim(input.val()) == "") input.val(input.attr("title"));

            input
			.focus(function() {
			    if (input.val() == input.attr("title")) input.val("");
			})
			.blur(function() {
			    if ($.trim(input.val()) == "") input.val(input.attr("title"));
			});
        });
    };

    $.fn.equalizarColunas = function() {
        var maxHeight = 0;
        this.each(function() {
            if (this.offsetHeight > maxHeight) { maxHeight = this.offsetHeight; }
        });
        this.each(function() {
            $(this).height(maxHeight + "px");
            if (this.offsetHeight > maxHeight) {
                $(this).height((maxHeight - (this.offsetHeight - maxHeight)) + "px");
            }
        });
    };

    in_array = function(needle, haystack, argStrict) {
        // Checks if the given value exists in the array

        var found = false, key, strict = !!argStrict;

        for (key in haystack) {
            if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
                found = true;
                break;
            }
        }

        return found;
    }

    /* http://phpjs.org/ */
    array_push = function(array) {
        // Pushes elements onto the end of the array
        var i, argv = arguments, argc = argv.length;

        for (i = 1; i < argc; i++) {
            array[array.length++] = argv[i];
        }

        return array.length;
    }

    /* http://phpjs.org/ */
    array_shift = function(array) {
        // Pops an element off the beginning of the array
        if (array.length > 0) {
            return array.shift();
        }

        return null;
    }

    array_pop = function(array) {
        // Pops an element off the end of the array
        var key = '', cnt = 0;

        if (array.hasOwnProperty('length')) {
            // Indexed
            if (!array.length) {
                // Done popping, are we?
                return null;
            }
            return array.pop();
        } else {
            // Associative
            for (key in array) {
                cnt++;
            }
            if (cnt) {
                delete (array[key]);
                return array[key];
            } else {
                return null;
            }
        }
    }

    array_unshift = function(array) {
        // Pushes elements onto the beginning of the array
        var argc = arguments.length, argv = arguments, i;

        for (i = 1; i < argc; i++) {
            array.unshift(argv[i]);
        }

        return (array.length);
    }

    $.fn.curvas = function() {
        
        $(this).wrap("<div class='wrapper' />");

        $(".wrapper")
                .append('<span class="curva tl" />')
                .append('<span class="curva tr" />')
                .append('<span class="curva bl" />')
                .append('<span class="curva br" />');
    }
    
    tamanhoLetra = 0;
    alterarTamanhoLetra = function(acao){
        tamanho = $("body").css("fontSize");
        tamanho = eval(tamanho.replace("px", ""));
        if( acao == '++' ){
            if( tamanhoLetra == 3 ) return;
            tamanho++;
            tamanhoLetra++;
        }else{
            if( tamanhoLetra == -3 ) return;
            tamanho--;
            tamanhoLetra--;
        }
        $("body").css("fontSize", tamanho);
    } 
                           
	getTweets = function(alvo, usuario, qtdMensagens){
    	var o = {}
    	
    	o.qtdMensagens = qtdMensagens;
    	o.caixaTwitter = $("#" + alvo);
    		
    	o.caixaTwitter.append("<li><a href='#'>carregando tweets...</a></li>");
    	
    	$.jTwitter(usuario, o.qtdMensagens, function(data){
    	
    		o.caixaTwitter.empty();    		
    		o.list = '';
    		
            $.each(data, function(i, post){
            	o.hora = H(post.created_at);
            	o.texto = formatTwitString(post.text);
            	
            	o.list += '<li>' + o.texto + "<span class='hora'>" + o.hora + '</span></li>';
            });	
            
            o.caixaTwitter.append(o.list);
            
        });
    }
    
    formatTwitString = function(str){
	    str=' '+str;
	    str = str.replace(/((ftp|https?):\/\/([-\w\.]+)+(:\d+)?(\/([\w/_\.]*(\?\S+)?)?)?)/gm,'<a href="$1" target="_blank">$1</a>');
	    str = str.replace(/([^\w])\@([\w\-]+)/gm,'$1@<a href="http://twitter.com/$2" target="_blank">$2</a>');
	    str = str.replace(/([^\w])\#([\w\-]+)/gm,'$1<a href="http://twitter.com/search?q=%23$2" target="_blank">#$2</a>');
	    return str;
    }
    
    // from http://widgets.twimg.com/j/1/widget.js
    var K = function () {
        var a = navigator.userAgent;
        return {
            ie: a.match(/MSIE\s([^;]*)/)
        }
    }();
     
    var H = function (a) {
        var b = new Date();
        var c = new Date(a);
        if (K.ie) {
            c = Date.parse(a.replace(/( \+)/, ' UTC$1'))
        }
        var d = b - c;
        var e = 1000,
            minute = e * 60,
            hour = minute * 60,
            day = hour * 24,
            week = day * 7;
        if (isNaN(d) || d < 0) {
            return ""
        }
        if (d < e * 7) {
            return "agora pouco"
        }
        if (d < minute) {
            return Math.floor(d / e) + " segundos atr&aacute;s"
        }
        if (d < minute * 2) {
            return "h&aacute; 1 minuto"
        }
        if (d < hour) {
            return "h&aacute; " + Math.floor(d / minute) + " minutos"
        }
        if (d < hour * 2) {
            return "h&aacute; 1 hora"
        }
        if (d < day) {
            return "h&aacute; " + Math.floor(d / hour) + " horas atr&aacute;s"
        }
        if (d > day && d < day * 2) {
            return "ontem"
        }
        if (d < day * 365) {
            return "h&aacute; " + Math.floor(d / day) + " dias"
        } else {
            return "h&aacute; mais de 1 ano"
        }
    };
    
    var Wefit = {}
    Wefit.easterEgg = function() {
        total = 0;
        $(document).bind('keypress', function(e) {
            //key = e.keyCode || e.charCode;

            //503!
        });
    }

    Wefit.easterEgg();
    
    toSlug = function(s){
        if(typeof s != 'string'){
            return '';
        }else{
            s = s.replace(' ','+');
            return s;
        }
    }
    
    popup = function(url, params){
        var newWindow = window.open(url, 'name', params);
            
        /*if(!newWindow || newWindow.closed || typeof newWindow.closed=='undefined' || newWindow.location=='about:blank'){
            alert('Favor desabilite o bloqueador de popups');
        }*/
    }
    
    compartilhar = function(servico) {

        var url;

        titulo = encodeURIComponent($.trim($("title").html()).replace('#', ''));
        link = encodeURIComponent(location.href);
          
        var winWidht = $(window).width();
        var winHeight = $(window).height();        
          
        switch (servico) {   
            case 'orkut':{
                var params = {};
                params[google.orkut.share.Field.TITLE] = titulo;
                params[google.orkut.share.Field.DESTINATION_URL] = link;
                
                var connection = new google.orkut.share.Connection(params);
                //connection.send('orkut.com', {}); 
                popup('http://www.orkut.com', 'height=' + winHeight + ',width=' + winWidht + ',scrollbars=yes');
                //window.open('http://www.orkut.com', 'height=' + winHeight + ',width=' + winWidht + ',scrollbars=yes');
            }break;      
            
            case 'twitter':{
                try{
                    api_service_url = '/Handlers/ShortenUrl.ashx';
                    $.get(
                        api_service_url, 
                        {
                            link: link
                        },
                        function(ret){
                            url = 'http://twitter.com/home?status=' + titulo + ' ' + ret + ' %23marabraz';
                            //window.open(url);
                            popup(url, 'height=' +winHeight+ ',width=' + winWidht + ',scrollbars=yes');
                        }
                    );
                }catch(error){
                    url = 'http://twitter.com/home?status=' + titulo + ' ' + link + ' %23marabraz';
                    //window.open(url);
                    popup(url, 'height=' + winHeight + ',width=' + winWidht + ',scrollbars=yes');
                }
            }break;
            
            case 'facebook':{
                url = 'http://www.facebook.com/sharer.php?t=' + escape(titulo) + '&u=' + link;
                //window.open(url);
                popup(url, 'height=' + winHeight + ',width=' + winWidht + ',scrollbars=yes');
            }break;
        }
    }
        
    getFlash = function( swfID ){
		 if(navigator.appName.indexOf("Microsoft") != -1){
			  me = window[swfID];
		 }else{
			  me = document[swfID];
		 }
		 return me;
	}
	
	validarCPF = function(val){
	    var cpfValido = true;
        var cpf = val;
       
        var filtro = /^\d{3}.\d{3}.\d{3}-\d{2}$/i;
        if(!filtro.test(cpf)){
    	    cpfValido = false;
        }	   
        cpf = remove(cpf, ".");
        cpf = remove(cpf, "-");
        if(cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111" ||
		    cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" ||
		    cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" ||
		    cpf == "88888888888" || cpf == "99999999999"){
	        cpfValido = false;
       }

       soma = 0;
       for(i = 0; i < 9; i++)
   	     soma += parseInt(cpf.charAt(i)) * (10 - i);
       resto = 11 - (soma % 11);
       if(resto == 10 || resto == 11)
	     resto = 0;
       if(resto != parseInt(cpf.charAt(9))){
		    cpfValido = false;
       }
       soma = 0;
       for(i = 0; i < 10; i ++)
	     soma += parseInt(cpf.charAt(i)) * (11 - i);
       resto = 11 - (soma % 11);
       if(resto == 10 || resto == 11)
	     resto = 0;
       if(resto != parseInt(cpf.charAt(10))){
         cpfValido = false;
       }
       
       return cpfValido;
     }
     
     remove = function(str, sub) {
       i = str.indexOf(sub);
       r = "";
       if (i == -1) return str;
       r += str.substring(0,i) + remove(str.substring(i + sub.length), sub);
       return r;
     }

})(jQuery);


