$(document).ready(function(){
    //fecha
	$('#datepicker').datepicker({
        changeMonth: true,
    	changeYear: true,
        yearRange: '1950:2020',
        dateFormat: 'dd/mm/yy'
     });
    ///limpia text box
    $('input.borra-vacio').blur(function(){ if(this.value=='')this.value=this.title; })
                        .focus(function(){ this.value=''});

    //newsletter
    $('#btn-newsletter').css('cursor','pointer').click(function(){
            if($('#email-newsletter').val().match(/[\w-\.]{1,}@([\w-]{2,}\.)*([\w-]{2,}\.)[\w-]{2,4}/) && $('#email-newsletter').val()!='')
	     {
                  $.ajax({
                    type: "POST",
                    url: getBaseUrl+'/mod_newsletters/public/register/',
                    data: "email="+$('#email-newsletter').val() ,
                    async: false,
                    success: function(respuesta){
                        $('#email-newsletter').value='';
                        msg_windows(respuesta);
                         
                  }
                 });
            }else{
               msg_windows('L\'email n\'est pas correct');
            }
         return false;
    });
    ///dialog
    
    ///SLIDE
    // Expand Panel
	$("#open").click(function(){
		$("div#panel").slideDown("slow");
	});

	// Collapse Panel
	$("#close").click(function(){
		$("div#panel").slideUp("slow");
	});

	// Switch buttons from "Log In | Register" to "Close Panel" on click
	$("#toggle a").click(function () {
		$("#toggle a").toggle();
	});
      ///FIN SLIDE
});

$(window).ready(function(){
    //corrige PNG
	$.ifixpng('scripts/jquery.ifixpng/blank.gif');
  	$("img").ifixpng();
	$(".img_png").ifixpng();
	$("input[type='image']").ifixpng().css('cursor','pointer');
});

function messagealert(texto) {
           $("#messages").remove();
                var img='<div id="messages" title="Information" >'+
                       texto +
                        '</div>';
                $(img).dialog({
                height: 100,
                width: 200,
                resizable: false,
                modal: true,
                dialogClass: 'alert'

              });
              setTimeout(function() {
             $("#messages").remove();
             }, 2000);
             
}

