function fechar(div)
{
	$("#"+div).hide('slow');
	
}
$(document).ready(function(){
	
	// Pretty Photo
	$("a[rel^='prettyPhoto']").prettyPhoto({
		animationSpeed: 'slow', /* fast/slow/normal */
		padding: 10, /* padding for each side of the picture */
		opacity: 0.85, /* Value betwee 0 and 1 */
		showTitle: false, /* true/false */
		allowresize: true, /* true/false */
		counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
		theme: 'light_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
		callback: function(){
			alert('lala');
		}
	});
	
	
	

	// IE 6 pngfix	
	$('body').pngFix();

/*TRATA O FORMULARIO DE LOGIN */
	$("#login_login").click(function(){
			$("#div_login").toggle('slow');
		
	});
	
	$("#form_login").validate({
		rules: {
			email:{	required:true, email:true },
			senha:{ required:true }
		},			
		messages: {
				email : { required: "", email: ""},
				senha : { required: "" }
			
		},
		submitHandler: function(form) {
				$("#form_login #load").ajaxStart(function(){
					$(this).show();					
				});
				$.ajax({
					   type: "POST",
					   url: url+"application/models/AjaxFunctions.php",
					   data: $('#form_login').serialize()+"&function=login",
					   success: function(response){
							if(response != 'error')
							{
								$("#login").html(response);
								$('#div_login').fadeOut('slow');
							
							}
							else
							{
								$("#response").html('Dados incorretos.');
								
							}
							$("#load").hide();
					   	 	$("#response").fadeIn('slow');
						}
				});	
 			}

		});
		
/*TRATA O FORMULARIO DE CADASTRO */
	$("#login_cadastro").click(function(){
			$("#div_cadastro").show('slow');
		
	});
	
	
	
	$("#form_cadastro").validate({
		rules: {
			c_nome:   { required: true },
			c_email:  { required: true , email:true },
			c_senha:  { required: true },
			c_senha2: { required: true , equalTo: "#c_senha" }
    	},			
		messages: {
				c_nome:  { required: "" },
				c_email: { required: "" , email: ""},
				c_senha: { required: "" },
				c_senha2:{ required: "" , equalTo: ""}
				
		},
		submitHandler: function(form) {
				$("#form_cadastro #load").ajaxStart(function(){
					$(this).show();					
				});
				$.ajax({
					   type: "POST",
					   url: url+"application/models/AjaxFunctions.php",
					   data: $('#form_cadastro').serialize()+"&function=cadastro",
					   success: function(response){
							/*if(response != 'error')
							{
								$("#login").html(response);
								$('#div_cadastro').fadeOut('slow');
							
							}
							else
							{
								$("#c_response").html('Ocorreu um erro!');
								
							}
							$("#load").hide();
					   	 	$("#response").fadeIn('slow');
					   	 	*/
						}
				});	
 			}

		});		
});

