if(typeof(console)=="undefined"){
	console=new Object();
	console.log=function(){
		return null;
	}
}



$(document).ready(function () {
	$('html').addClass('js');
	$('.js-hide').hide();
	
$('.parent ul').hide();

$('.parent').hover(function(){
  var ul = $(this).children('ul');
  ul.stop().fadeIn('fast',function(){ul.css('opacity',1)})
}, function(){
  var ul = $(this).children('ul');
  ul.stop().fadeOut('slow')
});
	
  $('#video_corporativo').fancybox({
    'type'			: 'swf',
    'swf'			: {
      'wmode'		: 'transparent',
      'allowfullscreen'	: 'true'
    },
    'width':560,
    'height':349,
    'padding': 0
  });
	
	
$("#banner").scrollable({
    circular: true,
    mousewheel: true
}).autoscroll({
    autoplay: true,
    interval:5000
});
$("#plazas").scrollable({
    circular: true,
    mousewheel: true,
    next :	"#next",
    prev :	"#prev"
}).autoscroll({
    autoplay: true,
    interval:5000
});



/*Para el Fade In*/
var actual = 1;
var temp =0;
                $('#atras').click(function(){
                    if(actual==1){
                        $('#capa' + actual ).fadeOut("slow", function(){$('#capa1').fadeIn()});
                        $('#' + actual ).css({"fontWeight":"bold","color":"#000000"});
                    }
                    else{
                        temp=actual-1
                        $('#' + actual ).css({"fontWeight":"normal","color":"#025f84","text-decoration":"underline"});
                        $('#capa' + actual ).fadeOut("slow", function(){$('#capa'+temp).fadeIn()});
                        actual=temp;
                        $('#' + actual ).css({"fontWeight":"bold","color":"#000000"});
                        $("#pagina").text(""+actual);
                    }
                });
                $('#adelante').click(function(){
                     if(actual==2){
                        $('#capa' + actual ).fadeOut("slow", function(){$('#capa2').fadeIn()});
                        $('#' + actual ).css({"fontWeight":"bold","color":"#000000","text-decoration":"none"});
                    }
                    else{
                        temp=actual+1
                        $('#' + actual ).css({"fontWeight":"normal","color":"#025f84","text-decoration":"underline"});
                        $('#capa' + actual ).fadeOut("slow", function(){$('#capa'+temp).fadeIn()});
                        actual=temp;
                        $('#' + actual ).css({"fontWeight":"bold","color":"#000000","text-decoration":"none"});
                        $("#pagina").text(""+actual);
                    }
                });
                $('#2').click( function(){
                       $('#' + actual ).css({"fontWeight":"normal","color":"#025f84","text-decoration":"underline"});
			$('#capa' + actual ).fadeOut("slow", function(){$('#capa2').fadeIn()});
                        actual = 2;
                        $('#' + actual ).css({"fontWeight":"bold","color":"#000000","text-decoration":"none"});
			$("#pagina").text(""+actual);
		});

		$('#1').click( function(){
                        $('#' + actual ).css({"fontWeight":"normal","color":"#025f84","text-decoration":"underline"});
			$('#capa' + actual ).fadeOut("slow", function(){$('#capa1').fadeIn()});
                        actual = 1;
                        $('#' + actual ).css({"fontWeight":"bold","color":"#000000","text-decoration":"none"});
                        $("#pagina").text(""+actual);

			
		});

		$('#3').click( function(){
                       $('#' + actual ).css({"fontWeight":"normal","color":"#025f84","text-decoration":"underline"});
			$('#capa' + actual ).fadeOut("slow", function(){$('#capa3').fadeIn()});
                        actual = 3;
                       $('#' + actual ).css({"fontWeight":"bold","color":"#000000","text-decoration":"none"});
                        $("#pagina").text(" "+actual);
			
		});
/*Fin Fade in*/
/*Fancy Box*/

$(".fancy").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600,
		'speedOut'		:	200
		
	});
$("#ofrecenostuterreno-link").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600,
		'speedOut'		:	200,
                'titleShow' : false,
                'scrolling' :	'no',
                'height': 	610,
                'autoDimensions':false,
                'autoScale':false

	});
$("a[rel=grup-conchitas]").fancybox({
    'transitionIn' : 'none',
 'transitionOut' : 'none',
 'titlePosition' : 'over',
 'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
 return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';
 }
});
$("a[rel=grup-santiago]").fancybox({
    'transitionIn' : 'none',
 'transitionOut' : 'none',
 'titlePosition' : 'over',
 'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
 return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';
 }
});
$("a[rel=grup-valle]").fancybox({
    'transitionIn' : 'none',
 'transitionOut' : 'none',
 'titlePosition' : 'over',
 'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
 return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';
 }
});
$("a[rel=grup-mapa-conchitas]").fancybox({
    'transitionIn' : 'none',
 'transitionOut' : 'none',
 'titlePosition' : 'over',
 'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
 return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';
 }
});
$("a[rel=grup-mapa-santiago]").fancybox({
    'transitionIn' : 'none',
 'transitionOut' : 'none',
 'titlePosition' : 'over',
 'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
 return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';
 }
});
$("a[grup-mapa-valle]").fancybox({
    'transitionIn' : 'none',
 'transitionOut' : 'none',
 'titlePosition' : 'over',
 'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
 return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';
 }
});

/*Fin Fancy Box*/
if($("#msg").length > 0){
  $("#msg").css('opacity',0)
}
$("#frm").validate({
        errorPlacement:function(error, element){
            return false;
        },
        invalidHandler:function(form, validator){
            $('#msg').text('Por favor verifique los campos obligatorios (*)')
        },
        submitHandler: function(form){
          $('#formulario').css('position','relative').append('<div id="overlay"></div><img src="common/images/loader.gif" alt="enviando" id="enviando"/>');
          $('#overlay').css('opacity','0.8')
            $.ajax({
                type: 'POST',
                url: $(form).attr('action'),
                data: $(form).serialize(),
                success: function(data) {
                  $('#overlay').remove();
                  $('#enviando').remove();
                    $("#msg").animate({
                        opacity:0
                    },0, function(){
                        $("#msg").animate({
                            opacity:1
                        },"slow");
                    });
                    if (data=="ok"){
                        $('#msg').css("color","red");
                        $('#msg').html("Gracias por sus comentarios un ejecutivo se pondrá en contacto con usted. <span>Su mensaje se ha enviado con éxito</span>");			
                        form.reset();
                    }else{
                        $('#msg').text(data);
                    }
                }
            })
        }
    });
});

