function number_format( number, decimals, dec_point, thousands_sep ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     bugfix by: Michael White (http://getsprink.com)
    // +     bugfix by: Benjamin Lupton
    // +     bugfix by: Allan Jensen (http://www.winternet.no)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +     bugfix by: Howard Yeend
    // +    revised by: Luke Smith (http://lucassmith.name)
    // +     bugfix by: Diogo Resende
    // +     bugfix by: Rival
    // %        note 1: For 1000.55 result with precision 1 in FF/Opera is 1,000.5, but in IE is 1,000.6
    // *     example 1: number_format(1234.56);
    // *     returns 1: '1,235'
    // *     example 2: number_format(1234.56, 2, ',', ' ');
    // *     returns 2: '1 234,56'
    // *     example 3: number_format(1234.5678, 2, '.', '');
    // *     returns 3: '1234.57'
    // *     example 4: number_format(67, 2, ',', '.');
    // *     returns 4: '67,00'
    // *     example 5: number_format(1000);
    // *     returns 5: '1,000'
    // *     example 6: number_format(67.311, 2);
    // *     returns 6: '67.31'

    var n = number, prec = decimals;
    n = !isFinite(+n) ? 0 : +n;
    prec = !isFinite(+prec) ? 0 : Math.abs(prec);
    var sep = (typeof thousands_sep == "undefined") ? ',' : thousands_sep;
    var dec = (typeof dec_point == "undefined") ? '.' : dec_point;

    var s = (prec > 0) ? n.toFixed(prec) : Math.round(n).toFixed(prec); //fix for IE parseFloat(0.55).toFixed(0) = 0;

    var abs = Math.abs(n).toFixed(prec);
    var _, i;

    if (abs >= 1000) {
        _ = abs.split(/\D/);
        i = _[0].length % 3 || 3;

        _[0] = s.slice(0,i + (n < 0)) +
              _[0].slice(i).replace(/(\d{3})/g, sep+'$1');

        s = _.join(dec);
    } else {
        s = s.replace('.', dec);
    }

    return s;
}
(function($) {

$.extend($.fn, {
	livequery: function(type, fn, fn2) {
		var self = this, q;

		// Handle different call patterns
		if ($.isFunction(type))
			fn2 = fn, fn = type, type = undefined;

		// See if Live Query already exists
		$.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) )
					// Found the query, exit the each loop
					return (q = query) && false;
		});

		// Create new Live Query if it wasn't found
		q = q || new $.livequery(this.selector, this.context, type, fn, fn2);

		// Make sure it is running
		q.stopped = false;

		// Run it
		$.livequery.run( q.id );

		// Contnue the chain
		return this;
	},

	expire: function(type, fn, fn2) {
		var self = this;

		// Handle different call patterns
		if ($.isFunction(type))
			fn2 = fn, fn = type, type = undefined;

		// Find the Live Query based on arguments and stop it
		$.each( $.livequery.queries, function(i, query) {
			if ( 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);
		});

		// Continue the chain
		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;

	// The id is the index of the Live Query in $.livequery.queries
	this.id = $.livequery.queries.push(this)-1;

	// Mark the functions for matching later on
	fn.$lqguid = fn.$lqguid || $.livequery.guid++;
	if (fn2) fn2.$lqguid = fn2.$lqguid || $.livequery.guid++;

	// Return the Live Query
	return this;
};

$.livequery.prototype = {
	stop: function() {
		var query = this;

		if ( this.type )
			// Unbind all bound events
			this.elements.unbind(this.type, this.fn);
		else if (this.fn2)
			// Call the second function for all matched elements
			this.elements.each(function(i, el) {
				query.fn2.apply(el);
			});

		// Clear out matched elements
		this.elements = [];

		// Stop the Live Query from running until restarted
		this.stopped = true;
	},

	run: function() {
		// Short-circuit if stopped
		if ( this.stopped ) return;
		var query = this;

		var oEls = this.elements,
			els  = $(this.selector, this.context),
			nEls = els.not(oEls);

		// Set elements to the latest set of matched elements
		this.elements = els;

		if (this.type) {
			// Bind events to newly matched elements
			nEls.bind(this.type, this.fn);

			// Unbind events to elements no longer matched
			if (oEls.length > 0)
				$.each(oEls, function(i, el) {
					if ( $.inArray(el, els) < 0 )
						$.event.remove(el, query.type, query.fn);
				});
		}
		else {
			// Call the first function for newly matched elements
			nEls.each(function() {
				query.fn.apply(this);
			});

			// Call the second function for elements no longer matched
			if ( this.fn2 && oEls.length > 0 )
				$.each(oEls, function(i, el) {
					if ( $.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;
			// Run each Live Query currently in the queue
			while ( length-- )
				$.livequery.queries[ $.livequery.queue.shift() ].run();
		}
	},

	pause: function() {
		// Don't run anymore Live Queries until restarted
		$.livequery.running = false;
	},

	play: function() {
		// Restart Live Queries
		$.livequery.running = true;
		// Request a run of the Live Queries
		$.livequery.run();
	},

	registerPlugin: function() {
		$.each( arguments, function(i,n) {
			// Short-circuit if the method doesn't exist
			if (!$.fn[n]) return;

			// Save a reference to the original method
			var old = $.fn[n];

			// Create a new method
			$.fn[n] = function() {
				// Call the original method
				var r = old.apply(this, arguments);

				// Request a run of the Live Queries
				$.livequery.run();

				// Return the original methods result
				return r;
			}
		});
	},

	run: function(id) {
		if (id != undefined) {
			// Put the particular Live Query in the queue if it doesn't already exist
			if ( $.inArray(id, $.livequery.queue) < 0 )
				$.livequery.queue.push( id );
		}
		else
			// Put each Live Query in the queue if it doesn't already exist
			$.each( $.livequery.queries, function(id) {
				if ( $.inArray(id, $.livequery.queue) < 0 )
					$.livequery.queue.push( id );
			});

		// Clear timeout if it already exists
		if ($.livequery.timeout) clearTimeout($.livequery.timeout);
		// Create a timeout to check the queue and actually run the Live Queries
		$.livequery.timeout = setTimeout($.livequery.checkQueue, 20);
	},

	stop: function(id) {
		if (id != undefined)
			// Stop are particular Live Query
			$.livequery.queries[ id ].stop();
		else
			// Stop all Live Queries
			$.each( $.livequery.queries, function(id) {
				$.livequery.queries[ id ].stop();
			});
	}
});

// Register core DOM manipulation methods
$.livequery.registerPlugin('append', 'prepend', 'after', 'before', 'wrap', 'attr', 'removeAttr', 'addClass', 'removeClass', 'toggleClass', 'empty', 'remove');

// Run Live Queries when the Document is ready
$(function() { $.livequery.play(); });


// Save a reference to the original init method
var init = $.prototype.init;

// Create a new init method that exposes two new properties: selector and context
$.prototype.init = function(a,c) {
	// Call the original init and save the result
	var r = init.apply(this, arguments);

	// Copy over properties if they exist already
	if (a && a.selector)
		r.context = a.context, r.selector = a.selector;

	// Set properties
	if ( typeof a == 'string' )
		r.context = c || document, r.selector = a;

	// Return the result
	return r;
};

// Give the init function the jQuery prototype for later instantiation (needed after Rev 4091)
$.prototype.init.prototype = $.prototype;

})(jQuery);

// JavaScript Document
// Funcoes e plugins jQuery
/*
* @Copyright (c) 2008 Aurélio Saraiva (aureliosaraiva@gmail.com)
* @Page http://inovaideia.com.br/maskInputMoney

* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

/*
* @Version: 0.2
* @Release: 2008-07-25
*/
(function($) {
	$.fn.maskMoney = function(settings) {
		settings = $.extend({
			symbol: "US$",
			decimal: ".",
			precision: 2,
			thousands: ",",
			showSymbol:true
		}, settings);

		settings.symbol=settings.symbol+" ";

		return this.each(function() {
			var input=$(this);
			function money(e) {
				e=e||window.event;
				var k=e.charCode||e.keyCode||e.which;
				if (k == 8) { // tecla backspace
					preventDefault(e);
					var x = input.val().substring(0,input.val().length-1);
					input.val(maskValue(x));
					return false;
				} else if (k == 9) { // tecla tab
					return true;
				}
				if (k < 48 || k > 57) {
					preventDefault(e);
					return true;
				}
				var key = String.fromCharCode(k);  // Valor para o código da Chave
				preventDefault(e);
				input.val(maskValue(input.val()+key));
			}

			function preventDefault(e) {
				if (e.preventDefault) { //standart browsers
					e.preventDefault()
				} else { // internet explorer
					e.returnValue = false
				}
			}

			function maskValue(v) {
				v = v.replace(settings.symbol,"");
				var a = '';
				var strCheck = '0123456789';
				var len = v.length;
				var t = "";
				if (len== 0) {
					t = "0.00";
				}
				for (var i = 0; i < len; i++)
					if ((v.charAt(i) != '0') && (v.charAt(i) != settings.decimal))
						break;

				for (; i < len; i++) {
					if (strCheck.indexOf(v.charAt(i))!=-1) a+= v.charAt(i);
				}

				var n = parseFloat(a);
				n = isNaN(n) ? 0 : n/Math.pow(10, settings.precision);
				t = n.toFixed(settings.precision);

				var p, d = (t=t.split("."))[1].substr(0, settings.precision);
				for (p = (t=t[0]).length; (p-=3) >= 1;) {
					t = t.substr(0,p) + settings.thousands + t.substr(p);
				}
				return setSymbol(t+settings.decimal+d+Array(
					(settings.precision+1)-d.length).join(0));
			}

			function focusEvent() {
				if (input.val()=="") {
					input.val(setSymbol(getDefaultMask()));
				} else {
					input.val(setSymbol(input.val()));
				}
			}

			function blurEvent() {
				if (input.val()==setSymbol(getDefaultMask())) {
					input.val("");
				} else {
					input.val(input.val().replace(settings.symbol,""))
				}
			}

			function getDefaultMask() {
				var n = parseFloat("0")/Math.pow(10, settings.precision);
				return (n.toFixed(settings.precision)).replace(
					new RegExp("\\.", "g"), settings.decimal);
			}

			function setSymbol(v) {
				if (settings.showSymbol) {
					return settings.symbol+v;
				}
				return v;
			}

			input.bind("keypress",money);
			input.bind("blur",blurEvent);
			input.bind("focus",focusEvent);

			input.one("unmaskMoney",function() {
				input.unbind("focus",focusEvent);
				input.unbind("blur",blurEvent);
				input.unbind("keypress",money);
				if ($.browser.msie)
				this.onpaste= null;
				else if ($.browser.mozilla)
				this.removeEventListener('input',blurEvent,false);
			});
		});
	}

	$.fn.unmaskMoney=function() {
		return this.trigger("unmaskMoney");
	};
})(jQuery);


/*
 * iconDock jQuery plugin 
 * http://icon.cat/software/iconDock
 *
 * Version: 0.8 beta
 * Date: 2/05/2007
 *
 * Copyright (c) 2007 Isaac Roca & icon.cat (iroca@icon.cat)
 * Dual licensed under the MIT-LICENSE.txt and GPL-LICENSE.txt
 *
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 * 
 */
 
 eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('b.1s=0;b.1W=0;b(1z).1E(9(e){8 F=0;8 H=0;f(b.2w.2g){F=1P.2h+1z.1M.2i;H=1P.2j+1z.1M.2l}u{F=e.2m;H=e.2n}f(F<0){F=0}f(H<0){H=0}b.1s=F;b.1W=H;18 W});b.2o=9(d){8 13=0;f(d.w){1Z(d.w){13+=d.2p;d=d.w}}u f(d.y)13+=d.y;18 13};b.1T=9(d){8 11=0;f(d.w){1Z(d.w){11+=d.2q;d=d.w}}u f(d.x)11+=d.x;18 11};8 23={j:2r,o:2s,1S:1q,1w:2,19:2t,1j:\'1k\'};8 4=n 15();8 14=n 15();8 1L=9(7){5.e=n 15();5.p=1B;5.2u=1B;5.1a=V;f(7==2v){5.7=23}u{5.7=7}};8 1R=9(){5.1h=1B;5.Z=\'\';5.z=\'\';5.1c=\'\';5.17=\'\';5.K=\'#\';5.g=0;5.v=0};8 1H=9(3){8 E,h,l,m,T,2b;4[3].J.G("2a","25");E="";T=0;b(4[3].e).q(9(i){h=4[3].7.o-5.g;1I(4[3].7.1j){A\'1J\':l=h;m=0;B;A\'1k\':l=h/2;m=h/2;B;A\'1K\':l=0;m=h;B}E+=\'<a 1b="1d: 0; 1e:0;" K="\'+5.K+\'" 1O="\'+5.17+\'"><t 22="\'+5.1c+\'" 1b="1l: \'+l+\'C 0 \'+m+\'C 0; 1d:0; 1e:0;" L="\'+5.g+\'" 1n="\'+5.g+\'" I="\'+((5.g>4[3].7.j)?5.z:5.Z)+\'" /></a>\';T+=5.g});E="<1C 26=\\"1D\\" 1b=\\"1d:0; 1l:0; 1e:0; L: "+T+"C; 1n:"+4[3].7.o+"C; \\">"+E+"</1C>";4[3].J.27(E);R=n 15();R.Q(n 1G());R[R.10-1].I=5.z;4[3].p=b("1C.1D",4[3].J);b("t",4[3].p).q(9(i){4[3].e[i].1h=5});4[3].p.1E(9(){X(3);f(4[3].1a)1y(3,s)});4[3].p.28(9(){a=n 20();s=a.21();X(3);1g(3,s)},9(){b(4[3].e).q(9(i){5.v=4[3].7.j});1p(3);4[3].1a=V})};8 1r=9(3){b(4[3].e).q(9(i){5.g=4[3].7.j;5.v=4[3].7.j});1H(3)};8 1g=9(3,s){8 D=V;b("a",4[3].p).q(9(i){f(4[3].e[i].g<4[3].e[i].v)D=W});f(D){X(3);1y(3,s);1Q("1g("+3+","+s+");",1F)}u{4[3].1a=W}};8 1t=9(3,i,c){8 t=4[3].e[i].1h;8 h,l,m,1m;c=U.29(c);h=4[3].7.o-c;1I(4[3].7.1j){A\'1J\':l=h;m=0;B;A\'1k\':l=h/2;m=h/2;B;A\'1K\':l=0;m=h;B}t.I=(c>4[3].7.j)?4[3].e[i].z:4[3].e[i].Z;1m=1i(4[3].p.1f("L"))+c-4[3].e[i].g;b(t).1f("1l",l+"C 1N "+m+"C 1N");4[3].p.1f("L",1m);t.L=c;t.1n=c;4[3].e[i].g=c};8 1p=9(3){8 1o=1i((4[3].7.o-4[3].7.j)*1q/4[3].7.19);8 D=V;b(4[3].e).q(9(i){8 c;f((5.g-1o)>4[3].7.j){D=W;c=5.g-1o}u{c=4[3].7.j}1t(3,i,c)});f(D){1Q("1p("+3+")",1q)}u{1r(3)}};8 X=9(3){8 N,k;N=4[3].7.o-4[3].7.j;k=U.1V(4[3].7.1S,4[3].7.1w);b("a",4[3].p).q(9(i){8 1X=U.2f(b.1s-b.1T(5)-1i(4[3].e[i].g/2));8 1x=-(N*U.1V(1X,4[3].7.1w))/k;8 c=(1x<-N)?4[3].7.o-N:4[3].7.o+1x;4[3].e[i].v=c})};8 1y=9(3,s){8 O,P,a;a=n 20();O=a.21()-s;P=(O/4[3].7.19<1)?O/4[3].7.19:1;b(4[3].e).q(9(i){8 24,c;f(P<1){c=4[3].7.j+(5.v-4[3].7.j)*P}u{c=5.v}f(O>1F)1t(3,i,c)})};b.2c.2d({2e:9(7){8 3=4.10;4.Q(n 1L(7));4[3].J=5;b("a",4[3].J).q(9(i){8 S,M,r,1A,1u,12,Y,l,m;4[3].e.Q(n 1R());S=b("t",5);M=b(5);r=S.G("I");1A=r.1U(".");1u=r.1U("1Y");4[3].e[i].Z=r;4[3].e[i].z=r.1v(0,1u)+\'1Y\'+4[3].7.o+r.1v(1A,r.10-1);14.Q(n 1G());14[14.10-1].I=4[3].e[i].z;4[3].e[i].17=M.G("1O");4[3].e[i].K=M.G("K");12=M.G("2k");Y=S.G("22");4[3].e[i].1c=(12)?12:(Y)?Y:4[3].e[i].17.1v(6,16)+"..."});1r(3);18 5}});',62,157,'|||id|docks|this||conf|var|function||jQuery|costat|obj||if|costatActual|resta||iconMinSide||ptop|pbottom|new|iconMaxSide|divDock|each|imgsrc|lastOver|img|else|costatFinal|offsetParent|||srcBig|case|break|px|recrida|strHTML|tempX|attr|tempY|src|dockPare|href|width|aInt|diferencia|difOver|factorOv|push|bigimg|imgInt|divWidth|Math|false|true|inDock|imgalt|srcSmall|length|curleft|aname|curtop|preloadImgs|Array||descripcio|return|veloOutDock|isMoving|style|titol|margin|border|css|overDock|imgDock|parseInt|valign|middle|padding|ampladaFinal|height|tamanyPas|outDock|100|startDock|mouseX|actDock|liobarra|substr|coefAttDock|calc|moveDock|document|liopunt|null|div|docking|mousemove|60|Image|resetDock|switch|bottom|top|dock|body|0px|title|event|setTimeout|dockElement|distAttDock|getPosX|lastIndexOf|pow|mouseY|distancia|_|while|Date|getTime|alt|defaultConf|factor|center|class|html|hover|round|align|lastover|fn|extend|addDockEffect|abs|msie|clientX|scrollLeft|clientY|name|scrollTop|pageX|pageY|getPosY|offsetTop|offsetLeft|35|70|1000|pareDock|undefined|browser'.split('|'),0,{}))



/******* Mascara para data,hora,fone,cep ***********/
jQuery(function($){
	// formata os campos
	hora = "99:99";
	data = "99/99/9999";
	data_mes_ano = "99/9999";
	fone = "(99)9999-9999";
	cep  = "99999-999";
	cnpj = "99.999.999/9999-99";
	cpf = "999.999.999-99";
	$(".formata_data_mes_ano").livequery(function(){
		if($(this).attr('readonly') !== true){
			$(this).mask(data_mes_ano);
		}
	});
	$(".formata_data").livequery(function(){
		if($(this).attr('readonly') !== true){
			$(this).mask(data);
		}
	});
	$(".formata_hora").livequery(function(){
		if($(this).attr('readonly') !== true){
			$(this).mask(hora);
		}
	});
	$(".formata_fone").livequery(function(){
		if($(this).attr('readonly') !== true){
			$(this).mask(fone);
		}
	});
	$(".formata_cep").livequery(function(){
		if($(this).attr('readonly') !== true){
			$(this).mask(cep);
		}
	});
	$(".formata_cnpj").livequery(function(){
		if($(this).attr('readonly') !== true){
			$(this).mask(cnpj);
		}
	});
	$(".formata_cpf").livequery(function(){
		if($(this).attr('readonly') !== true){
			$(this).mask(cpf);
		}
	});
	$(".formata_moeda").livequery(function(){
		if($(this).attr('readonly') !== true){
			$(this).maskMoney({showSymbol:false, decimal:",",thousands:".",precision:2});;
		}
	});

	
	var confDock3 = {
		iconMinSide : 150,
		iconMaxSide : 300,
		distAttDock : 50,
		coefAttDock : 1,	
		veloOutDock : 200,
		valign: 'bottom'
	}
	jQuery(".imagens_crescendo.imagens").addDockEffect(confDock3);
	
	$("a[rel='lightbox']").lightBox({imageLoading:'imagens/loading.gif',imageBtnClose:'imagens/closelabel.gif',imageBtnPrev:'imagens/prev.gif',imageBtnNetx:'imagens/next.gif',imageBlank:'imagens/blank.gif'});
});
/**** Fim da Mascara para data e hora *******/	

/******* Mostra e esconde o mapa ***********/
function mostra_mapa(){				
        
        
	if($('#map').css('display')=='none'){
                $('.padded').css('height','auto');
                
		$('#map').show('slow',function(){
			load();                        
			$('#mostra_esconde').html('Esconder Mapa');                                                
		});
	}else{
		$('#map').hide('slow' , function(){                    
                    $('#mostra_esconde').html('Mostrar Mapa');
                    AjustaTamanhoPadded();
                });

	}
	return false;
}
/******* Fim do Mostra e esconde o mapa ***********/

function ucwords (str) {
    // http://kevin.vanzonneveld.net
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Waldo Malqui Silva
    // +   bugfixed by: Onno Marsman
    // *     example 1: ucwords('kevin van zonneveld');
    // *     returns 1: 'Kevin Van Zonneveld'
    // *     example 2: ucwords('HELLO WORLD');
    // *     returns 2: 'HELLO WORLD'
 
    return (str+'').replace(/^(.)|\s(.)/g, function ( $1 ) { return $1.toUpperCase( ); } );
}

function PreencheEndereco( input , uf_id , cidade_id , bairro_id , logradouro_tipo_id , logradouro_id ){				
	if( /\d{5}-\d{3}$/.test(input) === false || typeof($.cep) != 'undefined' && $.cep == input ) return false;
	
				  $.cep = input;					
					 uf = $('#' + uf_id				);
				 cidade = $('#' + cidade_id			);
				 bairro = $('#' + bairro_id			);
		logradouro_tipo = $('#' + logradouro_tipo_id );
			 logradouro = $('#' + logradouro_id		);
		
	uf.ajaxStart(function(){
		uf.attr('disabled','disabled');
		uf.addClass('loading');
	});
	
	cidade.ajaxStart(function(){
		cidade.attr('disabled','disabled');
		cidade.addClass('loading');
	});
	
	bairro.ajaxStart(function(){
		bairro.attr('readonly','readonly');
		bairro.addClass('loading');
	});
	
	logradouro_tipo.ajaxStart(function(){
		logradouro_tipo.attr('disabled','disabled');
		logradouro_tipo.addClass('loading');
	});
	
	logradouro.ajaxStart(function(){
		logradouro.attr('readonly','readonly');
		logradouro.addClass('loading');
	});
	
	$.getScript( input , function(data){		
		if( typeof resultadoCEP == 'undefined' || typeof resultadoCEP != 'undefined' && resultadoCEP === false ){
			alert('Ocorreu um erro durante a solicitação.');			
			cidade.removeClass('loading');
			cidade.attr('disabled','');
		}else if(resultadoCEP.resultado_txt == 'serviço indisponível/cep inválido'){
			alert('Serviço de CEP indisponível ou o CEP informado está inválido.');			
			cidade.removeClass('loading');
			cidade.attr('disabled','');
		}else{
			uf.find('option:contains("' + resultadoCEP.uf.toUpperCase() + '")').attr('selected','selected');				
					
			if( cidade.find('option:contains("' + resultadoCEP.cidade + '")').length > 0 ){
				cidade.find('option:contains("' + resultadoCEP.cidade + '")').attr('selected','selected');
				cidade.removeClass('loading');
				cidade.attr('disabled','');
			}else{								
				Dados( uf.find('option:selected').val() ,'traz_cidades' , resultadoCEP.cidade );								
				$.interval = setInterval( function(){					
					if(cidade.find('option:contains("' + ucwords(resultadoCEP.cidade) + '")').length > 0){
						cidade.find('option:contains("' + ucwords(resultadoCEP.cidade) + '")').attr('selected','selected');
						cidade.removeClass('loading');
						cidade.attr('disabled','');
						clearInterval($.interval);
					}else if(cidade.find('option').length > 0){
						cidade.removeClass('loading');
						cidade.attr('disabled','');
						clearInterval($.interval);
					}
				} , 1000 );
			}
			bairro.val(resultadoCEP.bairro);			
			logradouro_tipo.find('option[value="'+ resultadoCEP.tipo_logradouro +'"]').attr('selected','selected');
			logradouro.val(resultadoCEP.logradouro);
		}
		uf.removeClass('loading');		
		uf.attr('disabled','');
		bairro.removeClass('loading');
		bairro.attr('readonly','');
		logradouro_tipo.removeClass('loading');
		logradouro_tipo.attr('disabled','');
		logradouro.removeClass('loading');
		logradouro.attr('readonly','');
	});
	
	uf.unbind('ajaxStart');
	cidade.unbind('ajaxStart');
	bairro.unbind('ajaxStart');
	logradouro_tipo.unbind('ajaxStart');
	logradouro.unbind('ajaxStart');
};

