var _log = function(msg){
    if(console && console.log){
        console.log(msg);
    }
}

var getParam = function (name, handle)
{
  var start=handle.indexOf("?"+name+"=");
  if (start<0) start=handle.indexOf("&"+name+"=");
  if (start<0) return '';
  start += name.length+2;
  var end=handle.indexOf("&",start)-1;
  if (end<0) end=handle.length;
  var result='';
  for(var i=start;i<=end;i++) {
    var c=handle.charAt(i);
    result=result+(c=='+'?' ':c);
  }
  return unescape(result);
}

$(function() {

    $('#slideshow').after('<div id="navSlideshow" class="nav">').cycle({
        fx:     'fade',
        speed:  'slow',
        timeout: 10000,
        pager:  '#navSlideshow',
        before: onBefore
    });

    $('#fraseBeinvenida ul').cycle({
        fx:     'fade',
        speed:  'slow',
        timeout: 10000    
	});


    function onBefore() {
		//$('#fraseBeinvenida ul').cycle('next');
        $('#title').html(this.alt);
    }


    $('.ad-gallery').adGallery({
        effect: 'fade',
        scroll_jump: 107
    });



    $('.thumbGallery').click(function(e){
        e.preventDefault();
        var href = this.href;
        var idPhoto = getParam('id', href);
        $.ajax({
            type:'POST',
            url: 'habitaciones',
            data:{ajax:1, id: idPhoto},
            success: function(response){
                $('#jsContentAjax').html(response)
            }
        })
    })

 $.datepicker.regional['sp'] = {
	monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
	firstDay : 1,
	dayNames: ['Lunes','Martes','Miercoles','Jueves','Viernes','S�bado','Domingo'],
	dayNamesShort: ['Lun','Mar','Mie','Jue','Vie','Sab','Dom'],
	dayNamesMin : ['Do','Lu','Ma','Mx','Ju','Vi','Sa'],
	dateFormat: 'dd/mm/yy'

 }
 
 
$.timepicker.regional['sp'] = {
	timeOnlyTitle: 'dasd',
	timeText: 'Hora',
	hourText: 'horas',
	minuteText: 'minutos',
	secondText: 'segundos',
	currentText: 'Ahora',
	closeText: 'Cerrar',
	ampm: false
};



 
 
    $.datepicker.setDefaults($.datepicker.regional['sp']);
    $.timepicker.setDefaults($.timepicker.regional['sp']);
    $('.date').datetimepicker({
            showSecond: true,
            timeFormat: 'hh:mm:ss'
    });




    $('.submitForm').click(function(e){
        e.preventDefault();
        $(this).parents('form').submit();
    })


    $('#astLanguages').toggle(function(e){
        if($(e.target).is('a')){
            window.location = $(e.target).attr('href')
            return false;
        }
        $(this).animate({left:'-65px'});
    }, function(e){
        if($(e.target).is('a')){
            window.location = $(e.target).attr('href')
            return false;
        }
        $(this).animate({left:'-22px'});
    })
	
});

