//<![CDATA[
	
	/*
	 * SCRIPT PRINCIPAL USADO NA MAIORIA DAS PÁGINAS WILMA
	 * -------------------------------------------------------
	 * 
	 * Autor: Gilmar Soares <professorgilmagro@gmail.com>
	 * Empresa: ENC Interativa
	 * 
	 * */
	
	

	
	$(function(){
         	
         	var lnk_enc = '<a class="produced-by vtip" title="Desenvolvido por: ENC Interativa" target="_blank" href="http://www.encinterativa.com.br" >&nbsp;</a>';
         	$("#footer").append(lnk_enc);
         	vtip();
         	
		 	/*
		 	 	PRE-LOAD DOS ICONES DE REDE SOCIAL 
		 	*/
			var dominio = "http://www.wkcozinha.com.br/new/";
                        //var dominio = "http://192.168.1.108/wilma/";
			var img_path = dominio + "public/img/icons/";
			
			jQuery.preloadImages = function(){
				
				for(var i = 0; i<arguments.length; i++){
					jQuery("<img>").attr("src", img_path + arguments[i]);
				}
			}
			
			$.preloadImages("twitter.jpg","facebook.jpg","myspace.jpg","feed.jpg","check1.gif","logoAlert.jpg","share_facebook.jpg","share_twitter.jpg");

			$("#redeSocial a img").animate({opacity: 0.8});
		 	
			/*
				PEGA O ANO E O MES ATUAL
			*/
			
			var now = new Date();
			var year = 0;
			var month = 0;
			year = now.getFullYear();
			month = now.getMonth() + 1;

			/*
		 	 	CALENDARIO
		 	*/
			$( "#calendar" ).datepicker({
				dayNamesMin: ['D', 'S', 'T', 'Q', 'Q', 'S', 'S'],
				dayNames : ['Domingo','Segunda','Terça','Quarta','Quinta','Sexta','Sábado'],
				monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
				prevText: '',
				nextText: '',
				onChangeMonthYear: function(y, m) {
				getDays(y,m);
			}
				
			});
						
			$(".ui-state-active").attr("class","ui-state-default");

			 /*
	 			PEGA OS DIAS VIA AJAX QUE TERÁ CURSO
			*/
			var cursos = [];
			
			function getDays(year,month){
				//ALTERAR A URL
				$.post(dominio + 'turmas/getTurmas',{year:year,month:month}, function(data) {
					 
					cursos = data.response;
					
					$("a.ui-state-default").each(function(){
						var day = $(this).html();
						
						for(i=0;i<cursos.length;i++){
							var curso = cursos[i];
							
							if(day == curso.day){
                                                                var complemento;
								complemento = (curso.horario != null) ? "" + curso.horario + "" + curso.tempo + "" : "";
								var description  = "<strong>" + curso.desc + "</strong><br />Professor(a): " + curso.instrutor + "<span>" + curso.aula + complemento + "</span>"
								$(this)
								.addClass("ui-state-active vtip")
								.attr("title",$(this).attr("title") + description + "<br />")
								.attr("href",curso.link);
								vtip();
								$(".ui-state-default").parent('td').attr('onclick','');
							}
						}
					});
				},'json');
			}
			
			getDays(year,month);
									
	        /*
 	 			SCROLL PERSONALIZADO
	        */
	        
			$(".scroll").jScrollPane({scrollbarWidth:5});
			
			 /*
	 			LIGHT BOX ESTILIZADO
			 */
            $("a[rel^='prettyPhoto']").prettyPhoto({theme: 'light_square' ,overlay_gallery: false,show_title: false});
        
			
			/*
 				EASY SLIDER
			*/
			$("#destaques,[id^=galeria]").easySlider({numeric:true});
			
					
			/*
			 	MENU PARA EXIBIR A LISTA DE CURSO
			 */
			
			$("#menu_curso> ul> li> img").click(function(){
				$(this).parent().find("ul").slideToggle("slow");
			});
			            
            
            $("#pesquisa").focus(function(){
            	$(this).removeClass("lupa");
            }).blur(function(){
            	$(this).addClass("lupa");
            });

            
			
            /* EFEITO HOVER DO MENU */
            
            $("#menu a img,.button").hover(
					
    				function(){
    					$(this).animate({opacity:0.5});
    				},
    				function(){
    					$(this).animate({opacity:1});
    			});
            
            var img = "";
            
            /* EFEITO HOVER DA BARRA REDE SOCIAL */
            
			$("#redeSocial a img").hover(
					
				function(){
					img =$(this).attr("src");
					$(this).attr("src",img.replace("_gray",""));
				},
				function(){
					$(this).attr("src",img);
			});
 			
			$(".slider").css("height","350px");
			
			$("#loading").dialog({minWidth:200,minHeight:100,modal:true,autoOpen: false});
			
				
	});	
	
	/*
		ALERT PERSONALIZADO
 */
	var msg = "";
	$("#msgBox").dialog({ autoOpen: false });
	
	function msgBox(message,titulo,block){

		block = (block == null) ? true : block;
		$("#msgBox").html(message).dialog({position: [350,'center'],title:titulo,minWidth:350,minHeight:160,modal:block,buttons: { "Fechar": function() { $(this).dialog("close"); }}});
		$("#msgBox").dialog('open');
	}
	
	/*
 	FUNÇÃO PARA VERIFICAR O E-MAIL
 */

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;
    }
}	

     
//]]>

