
(function($){  
	$.fn.placeholder = function(options) {  
		
		var defaults = {  
    		color: '#aaaaaa'
    	};
		
		var o = $.extend(defaults, options);
		
		return this.each(function() {
			var color = $(this).css('color');
			$(this).css('color', o.color);
			var texto = $(this).val();
			var textbox = $(this);
			
			$(this).focus(function(){
				if($(this).val() == texto){
					$(this).val('');
					$(this).css('color', color);
					$(this).blur(function(){
						if($(this).val() == ''){
							$(this).css('color', o.color);
							$(this).val(texto);
						}
					});
				}
			});
			
			$(textbox).closest('form').submit(function(){
				if($(textbox).val() == texto)
					$(textbox).val('');
			});			
		});  
	};  
})(jQuery);



$.widget("ui.slideshow", {
    options: {
    	timer: false,
    	transform: 'left',
        intervalo: 2000,
        velocidade: 500
    },
    _init: function(){    	
        this.start();
    },
    start: function(){
    	this.stop();
    	var slideshowdiv = this.element;    	
    	var largura = $(slideshowdiv).find('img:first').width();
    	var altura = $(slideshowdiv).find('img:first').height();
    	var totalimagens = $(slideshowdiv).find('img').length;
    	
    	var intervalo = this.options.intervalo;
    	var transform = this.options.transform;
    	var velocidade = this.options.velocidade;
    	
    	var wrapper = $('<div />').width(largura).height(altura).css({'overflow':'hidden','position':'relative'});
    	$(slideshowdiv).wrap(wrapper);
    	$(slideshowdiv).children('div').css('position','relative');
    	
    	
    	ReverseImages = function(direction){
			$(slideshowdiv).children('div').each(function(cont){
				if(cont > 0)
					$(this).prependTo($(slideshowdiv));
			});
			if (direction == 'horizontal')
				$(slideshowdiv).css('margin-left', '-' + largura * (totalimagens - 1) + 'px');
			else if (direction == 'vertical')
				$(slideshowdiv).css('margin-top', '-' + altura * (totalimagens - 1) + 'px');
		};
    	
    	switch(this.options.transform){
			case 'left':
				$(slideshowdiv).width(largura * totalimagens).height(altura);
				this.options.timer = window.setInterval("ChangeImageLeft(" + velocidade + ")", intervalo);
			break;
			case 'right':
				$(slideshowdiv).width(largura * totalimagens).height(altura);
				ReverseImages('horizontal');    				
				this.options.timer = window.setInterval("ChangeImageRight(" + velocidade + ")", intervalo);
			break;
			case 'up':
				$(slideshowdiv).height(altura * totalimagens).width(largura);            				
				this.options.timer = window.setInterval("ChangeImageUp(" + velocidade + ")", intervalo);
			break;
			case 'down':            				
				$(slideshowdiv).height(altura * totalimagens).width(largura);
				ReverseImages('vertical');
				this.options.timer = window.setInterval("ChangeImageDown(" + velocidade + ")", intervalo);
			break;
			case 'fade':
				$(slideshowdiv).height(altura).width(largura);            				
				this.options.timer = window.setInterval("ChangeImageFade(" + velocidade + ")", intervalo);
			break;
			case 'seethrough':
				$(slideshowdiv).children('div').css('position','absolute');
				$(slideshowdiv).height(altura).width(largura);            				
				this.options.timer = window.setInterval("ChangeImageSeethrough(" + velocidade + ")", intervalo);
			break;
		}
    	
    	ChangeImageLeft = function(velocidade){
			$(slideshowdiv).animate({'margin-left' : '-=' + largura } , velocidade, function(){
				$(slideshowdiv).children('div:first').appendTo($(slideshowdiv));
				$(slideshowdiv).css('margin-left','0');
    			}
    		);
		};
		ChangeImageRight = function(){            			
			$(slideshowdiv).animate({'margin-left' : '+=' + largura } , velocidade, function(){
				$(slideshowdiv).children('div:last').prependTo($(slideshowdiv));
				$(slideshowdiv).css('margin-left', '-' + largura * (totalimagens - 1) + 'px');
    			}
    		);
		};
		ChangeImageUp = function(){            			
			$(slideshowdiv).animate({'margin-top' : '-=' + altura } , velocidade, function(){
				$(slideshowdiv).children('div:first').appendTo($(slideshowdiv));
				$(slideshowdiv).css('margin-top', '0');
    			}
    		);
		};
		ChangeImageDown = function(){            			
			$(slideshowdiv).animate({'margin-top' : '+=' + altura } , velocidade, function(){
				$(slideshowdiv).children('div:last').prependTo($(slideshowdiv));
				$(slideshowdiv).css('margin-top', '-' + altura * (totalimagens - 1) + 'px');
    			}
    		);
		};
		ChangeImageFade = function(){
			$(slideshowdiv).children('div:first').fadeOut(velocidade/2, function(){
				$(slideshowdiv).children('div:first').appendTo($(slideshowdiv));
				$(slideshowdiv).children('div:first').fadeIn(velocidade/2);
			});
		};
		ChangeImageSeethrough = function(){			
			$(slideshowdiv).children('div:last').animate({'opacity': 0.0}, velocidade, function(){				
				$(slideshowdiv).children('div:last').css('opacity','1.0');
				$(slideshowdiv).children('div:last').prependTo($(slideshowdiv));
			});
		};
    },
    stop: function(){
    	this.element.css('margin-left','0').css('margin-top','0');
        if (this.options.timer) {
            clearInterval(this.options.timer);
            this.options.timer = false;
        }
    }    
});

(function(d){d.fn.numeric=function(a,c){a=a===false?"":a||".";c=typeof c=="function"?c:function(){};return this.data("numeric.decimal",a).data("numeric.callback",c).keypress(d.fn.numeric.keypress).blur(d.fn.numeric.blur)};d.fn.numeric.keypress=function(a){var c=d.data(this,"numeric.decimal"),b=a.charCode?a.charCode:a.keyCode?a.keyCode:0;if(b==13&&this.nodeName.toLowerCase()=="input")return true;else if(b==13)return false;var e=false;if(a.ctrlKey&&b==97||a.ctrlKey&&b==65)return true;if(a.ctrlKey&& b==120||a.ctrlKey&&b==88)return true;if(a.ctrlKey&&b==99||a.ctrlKey&&b==67)return true;if(a.ctrlKey&&b==122||a.ctrlKey&&b==90)return true;if(a.ctrlKey&&b==118||a.ctrlKey&&b==86||a.shiftKey&&b==45)return true;if(b<48||b>57){if(b==45&&this.value.length==0)return true;if(c&&b==c.charCodeAt(0)&&this.value.indexOf(c)!=-1)e=false;if(b!=8&&b!=9&&b!=13&&b!=35&&b!=36&&b!=37&&b!=39&&b!=46)e=false;else if(typeof a.charCode!="undefined")if(a.keyCode==a.which&&a.which!=0){e=true;if(a.which==46)e=false}else if(a.keyCode!= 0&&a.charCode==0&&a.which==0)e=true;if(c&&b==c.charCodeAt(0))e=this.value.indexOf(c)==-1?true:false}else e=true;return e};d.fn.numeric.blur=function(){var a=d.data(this,"numeric.decimal"),c=d.data(this,"numeric.callback"),b=d(this).val();if(b!="")RegExp("^\\d+$|\\d*"+a+"\\d+").exec(b)||c.apply(this)};d.fn.removeNumeric=function(){return this.data("numeric.decimal",null).data("numeric.callback",null).unbind("keypress",d.fn.numeric.keypress).unbind("blur",d.fn.numeric.blur)}})(jQuery);

function validaEmail(email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;   
   return reg.test(email);   
}

