jQuery(document).ready(function() {
	
	Placeholder.init({
	    normal         : "#fff",
	    placeholder : "#7C7C7C"
	});
	
	$("#popLogin").fancybox({
		'scrolling'		: 'no',
		'titleShow'		: false,
		'showCloseButton': true
		
	});
	$(".popup559").fancybox({
		'width'				: 559,
		'height'			: 600,
		'scrolling'			: 'auto',
        'autoScale'     	: true,
        'autoDimensions'	: true,
		'type'				: 'iframe'
	});
	$(".popupObrigado").fancybox({
		'width'				: 559,
		'height'			: 186,
        'autoScale'     	: false,
		'type'				: 'iframe'
	});
	
	$('#slider').nivoSlider({
        effect:'slideInLeft',
        pauseTime:4000,
        controlNav:false,
        pauseOnHover:false,
        directionNav:false
        	
	});
	
	$("#loginMedicoForm").bind("submit", function() {

		if ($("#usuario").val().length < 1 || $("#senha").val().length < 1) {
		    $("#login_error").show();
		    $.fancybox.resize();
		    return false;
		}

		$.fancybox.showActivity();

		$.ajax({
			type		: "POST",
			cache	: false,
			url		: "/medicos/efeturarlogin",
			data		: $(this).serializeArray(),
			success: function(data) {
				$.fancybox.hideActivity();
				if(data == 1){
					window.location.replace("/medicos");
				}else if(data == 2){
					alert('login e/ou senha inválidos');
				}
				
			}
		});

		return false;
	});
});
