function checkMail(mail){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(mail) == "string"){
        if(er.test(mail)){ return true; }
    }else if(typeof(mail) == "object"){
        if(er.test(mail.value)){
                    return true;
         }
    }else{
        return false;
    }
}


/* efeito para retirar os valores default dos campos input e textarea ao dar foto*/
$(document).ready(function(){
	$('input,textarea').each(function(){
		var input = this;
		$(this).focus(function(){
			if(this.value === this.defaultValue){
				this.value = '';
			}
		});
		$(this).blur(function(){
			if(this.value == ''){
				this.value = this.defaultValue;
			}
		});
	});
	
	window.popMe = function(tmp_url){
		var body = $('body');
		var child = $('<div id="child" style="background:transparent; width:250px; height:250px; position:absolute; z-index:150;">').html('<div style="margin:0 auto;" id="result"></div>');
		var bg = $('<div id="popbg">').html('');
		$(bg).css({display:'none',opacity:0.0,background:'#000000',width:$(document).width()+'px',height:$(document).height()+'px',position:'absolute','z-index':'50'});
		$(bg).click(function(){
			$('#child').hide();
			$(this).hide('fast');
		});
		body.prepend(bg);
		$(bg).css({display:'block'});
		$(bg).animate({opacity:0.75},250);
		body.prepend(child);
		
		$('#child #result').load(tmp_url, function(){
			var child = $('#child');
			var result = $('#result');
			child.css({width:'auto',height:'auto'});
			var l = ((($(window).width() / 2) - (result.width() / 2)) + $(document).scrollLeft());
			var t = ((($(window).height() / 2) - (result.height() / 2)) + $(document).scrollTop());
			// child.animate({width:result.width()+'px',height:result.height()+'px',marginLeft:l+'px',marginTop:t+'px'}, 200);
			child.css({width:result.width()+'px',height:result.height()+'px',marginLeft:l+'px',marginTop:t+'px'});
//				$('#child').css({width:$('#result').width()+'px',height:$('#result').height()+'px',marginLeft:l+'px',marginTop:t+'px'});
			child.find('.popMeX').click(function(event){
				event.preventDefault();
				popMeX();
			});
		});
	};
	window.popMeX = function(){
		$('#popbg').click();
	};
});
