/* CRIADO POR GUSTAVO COSTA @GUSTAVOCOSTAW - GUSTAVO-COSTA.COM - GUSTAVO.COSTA.W@GMAIL.COM */

$(document).ready(function(){


    var map; // Map Google Maps

	/* SLIDER */

	$('#slider').nivoSlider({
		directionNav:false,
		captionOpacity:1,
		controlNavThumbs:true,
		controlNavThumbsFromAlt:true,
		effect:'random',
		animSpeed:500,
		pauseTime:3000,
		pauseOnHover:true
	});

	//PLACEHOLDER ALL

	$('input, textarea').placeholder();
	
	// EVENTS

    $('.fancyEvent').fancybox({
        
    });
	
	$('#marqueSuaConsulta').fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		onStart		:	function() {
			$('#marqueConsultaHidden').show();
		},
		onClosed	:	function() {
            $('#trabalhenaIofal').hide();
		}
	});
    $('.tratamento').fancybox({
        'titlePosition'     : 'inside',
        'transitionIn'      : 'none',
        'transitionOut'     : 'none',    
    });
	
    $('#trabalheConoscoLink').fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		onStart		:	function() {
			$('#trabalhenaIofal').show();
		},
		onClosed	:	function() {
            $('#trabalhenaIofal').hide();
		}
	});
	//EFFECT FOOTER LOCAIS DA IOFAL
	$('#footerHide').hide();

	$('#btnShow').click(function() {
		if($('#footerHide').css('display') == "none") {
			$('#footerHide').animate({
		    left: '+=50',
		    height: 'toggle'
		  }, 500, function() {
		    // Animation complete.
		  	});
		}
		else {
			$('#footerHide').animate({
		    left: '-=50',
		    height: 'toggle'
		  }, 500, function() {
		    // Animation complete.
		  	});
		}
	})
    $('#btnShow').click();
	//FANCY BOX ESTRUTURA

	$(".estructure a").fancybox({
		'overlayShow'	: true,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});
	//$('#noticeContent p').before('<br/>');

	// VALIDATE FORMS

	$('#form1').validate({
            rules:{
                paciente:{
                    required: true,
                    minlength: 3
                },
                fone: {
                    required: true
                },
                cel: {
                    required: true
                },
                email: {
                    required: true,
                    email: true
                }
            },
            messages:{
                paciente:{
                    required: "<br/><span class='very'>Campo obrigatorio.</span>",
                    minlength: "<br/><span class='very'>Este campo deve conter no minimo 3 caracteres.</span>"
                },
                fone: {
                    required: "<br/><span class='very'>Campo obrigatorio.</span>",
                },
                cel: {
                    required: "<br/><span class='very'>Campo obrigatorio.</span>",
                },
                email: {
                    required: "<br/><span class='very'>Campo obrigatorio.</span>",
                    email: "<br/><span class='very'>Preencha com um e-mail correto.</span>"
                }
            }
     });

	$('#trabalheNaIofal').validate({
            rules:{
                nome:{
                    required: true,
                    minlength: 3
                },
                idade: {
                    required: true,
                    minlength: 2
                },
                endereco:{
                    required: true,
                    minlength: 3
                },
                cidade: {
                    required: true,
                    minlength: 3
                },
                cep:{
                    required: true,
                    minlength: 3
                },
                fone: {
                    required: true,
                    minlength: 3
                },
                email: {
                    required: true,
                    email: true
                }
            },
            messages:{
                nome:{
                    required: "<br/><span class='very'>Campo obrigatorio.</span>",
                    minlength: "<br/><span class='very'>Este campo deve conter no mínimo 3 caracteres.</span>"
                },
                idade: {
                    required: "<br/><span class='very'>Campo obrigatorio.</span>",
                },
                endereco:{
                    required: "<br/><span class='very'>Campo obrigatorio.</span>",
                    minlength: "<br/><span class='very'>Este campo deve conter no mínimo 3 caracteres.</span>"
                },
                cidade: {
                    required: "<br/><span class='very'>Campo obrigatorio.</span>",
                },
                cep: {
                    required: "<br/><span class='very'>Campo obrigatorio.</span>",
                    minlength: "<br/><span class='very'>Este campo deve conter no minimo 3 caracteres.</span>"
                },
                idade: {
                    required: "<br/><span class='very'>Campo obrigatorio.</span>",
                    minlength: "<br/><span class='very'>Este campo deve conter no minimo 3 caracteres.</span>"
                },
                fone: {
                    required: "<br/><span class='very'>Campo obrigatorio.</span>",
                    minlength: "<br/><span class='very'>Este campo deve conter no minimo 3 caracteres.</span>"
                },
                email: {
                    required: "<br/><span class='very'>Campo obrigatorio.</span>",
                    email: "<br/><span class='very'>Preencha com um e-mail correto.</span>"
                }
            }
     });

     $('#contactForm').validate({
            rules:{
                nome:{
                    required: true,
                    minlength: 3
                },
                tel: {
                    required: true
                },
                msg: {
                    required: true
                },
                email: {
                    required: true,
                    email: true
                }
            },
            messages:{
                nome:{
                    required: "<br/><span class='very'>Campo obrigatorio.</span>",
                    minlength: "<br/><span class='very'>Este campo deve conter no minimo 3 caracteres.</span>"
                },
                tel: {
                    required: "<br/><span class='very'>Campo obrigatorio.</span>",
                },
                msg: {
                    required: "<br/><span class='very'>Campo obrigatorio..</span>",
                },
                email: {
                    required: "<br/><span class='very'>Campo obrigatorio.</span>",
                    email: "<br/><span class='very'>Preencha com um e-mail valido.</span>"
                }
            }
     });

     
     /*PAGINATION*/
     $("ul#contentText").quickPagination({pageSize:"3"});
     $("ul#contentText2").quickPagination({pageSize:"9"});
     $("ul#contentText3").quickPagination({pageSize:"12"});
     $("ul#listAlbums").quickPagination({pageSize:"16"});

     $('.fancyVideo').fancybox({
         'type' : 'iframe'
     });
     $('.testeVisaoShow').fancybox({
        'titlePosition'     : 'inside',
        'transitionIn'      : 'none',
        'transitionOut'     : 'none',
        'width' :  520,
        'height' : 500,
        onStart     :   function() {
            $('#testeVisao').show();
            
            var ar = "includes/teste/teste1.html";
            $.get(ar,function(data) {
               $('#testeContent').html(data);
            });
        },
        onClosed    :   function() {
            $('#testeVisao').hide();
        }
    });

    /* open teste */

    $('.testeReload').click(function() {
        var ar = "includes/teste/"+ $(this).attr('id')+".html";
        $.get(ar,function(data) {
            $('#testeContent').html(data);
        });
    })

        /*EFFECT ESTRUTURA */

    $('.menu').click(function(){ 
        $('.menu').next('ul').not($(this).next('ul')).slideUp('fast');
        $(this).next('ul').slideDown('slow');     
    });


    /*OPEN SWF*/

     $(".swf").fancybox({
        'padding'           : 0,
        'autoScale'         : false,
        'transitionIn'      : 'none',
        'transitionOut'     : 'none',
        'width' : 450,
        'height' : 250
     });

    /* GOOGLE MAPS */     
  function googleMaps() {
      var myLatlng = new google.maps.LatLng(-9.589176485343256, -35.733710700443226);

      var myOptions = {
        zoom: 11,
        center: myLatlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      }
      map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  }

function criarPonto(lat,lng,dados) {
    var marker = new google.maps.Marker({
          position: new google.maps.LatLng(lat,lng),
          title:dados,
          map:map
      });

      var infowindow = new google.maps.InfoWindow();
      infowindow.setContent(dados);
      infowindow.setPosition(new google.maps.LatLng(lat,lng));
      google.maps.event.addListener(marker,'click',function(event) {
        
        infowindow.open(map);

      });
  }
$('#menu ul li a').eq(page).css('background','#2841a6');
googleMaps();
criarPonto(-9.661835335431322, -35.70042985098644,"<div style='font:14px Arial;height:70px'>IOFAL - Ponta Verde<br/> Rua Dr. Pompeu de Miranda Sarmento, 205.<br/>Telefone: 82 3327.6563</div>");
criarPonto(-9.549810014087862, -35.725618475845295,"<div style='font:14px Arial;height:50px'>IOFAL - Benedito Bentes<br/>Av. Norma Pimentel da Costa, 918,<br/>Telefone: 3374.9110</div>");
criarPonto(-9.747780783424222, -36.662817174365955,"<div style='font:14px Arial;height:50px'>IOFAL - Arapiraca<br/>Rua Pedro Correia, 269, Centro<br/>Telefone: 3522.1274</div>");
criarPonto(-10.287389195077047, -36.582318717411,"<div style='font:14px Arial;height:70px'>IOFAL - Penedo<br/>Rua Santa Catarina, 09, Vila Matias Dom Constantino<br/>Telefone: 3551.3522</div>");


})
