/*Slider principal*/

$(document).ready(function(){
    
//fade in out de la red social
    $('.fade').hover(function() {$(this).children('span').fadeOut('250');},function() {$(this).children('span').fadeIn('250');})
    



        //combo de urbanizaciones y zonas
   $("#bv_zona").change(function () {
   		$("#bv_zona option:selected").each(function () {
			//alert($(this).val());
				elegido=$(this).val();
				$.post("/ajax/zonas.php", { elegido: elegido }, function(data){
                
				$("#bv_urbanizacion").show();
                $("#bv_urbanizacion").html(data);
			});			
        });
   })
	
    
    // BUSCADOR INICIO
    $('#buscador-opts a').click(function(e){
        e.preventDefault();
        var id = $(this).attr('href'); // obtener el div a mostrar
        $('#buscador-opts a').removeClass('active'); // desactivar todos los botones
        $(this).addClass('active'); // activar el boton
        $('.buscador-box').hide();
        $('#'+id.substr(1)).show();
    });


    //slider destacado
    $('#slider1').anythingSlider({
        delay: 5000,
        buildArrows: false,
        autoPlay: true,
        startText           : '<span class="ui-button-icon-primary ui-icon ui-icon-play"></span>',
        stopText           : '<span class="ui-button-icon-primary ui-icon ui-icon-pause">Pausa</span>',
    });

    //slider
    $('#slider2').anythingSlider({
        delay: 5000,
        buildArrows: false,
        autoPlay: false,
        startText           : '<span class="ui-button-icon-primary ui-icon ui-icon-play"></span>',
        stopText           : '<span class="ui-button-icon-primary ui-icon ui-icon-pause"></span>',
    });

    $('.thumbNav a').button();
    $('.start-stop').button();
    
    
    
    

stepcarousel.setup({
	galleryid: 'a_carousel', //id of carousel DIV
	beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
	panelclass: 'panel', //class of panel DIVs each holding content
	autostep: {enable:true, moveby:1, pause:4000},
	panelbehavior: {speed:500, wraparound:true, persist:true},
	statusvars: ['statusA', 'statusB', 'statusC'], //register 3 variables that contain current panel (start), current panel (last), and total panels
	contenttype: ['external'] //content setting ['inline'] or ['external', 'path_to_external_file']
})


 //PESTAÑA ALQUILERES

stepcarousel.setup({
	galleryid: 'v_carousel', //id of carousel DIV
	beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
	panelclass: 'panel', //class of panel DIVs each holding content
	autostep: {enable:true, moveby:1, pause:4000},
	panelbehavior: {speed:500, wraparound:true, persist:true},
	statusvars: ['statusA', 'statusB', 'statusC'], //register 3 variables that contain current panel (start), current panel (last), and total panels
	contenttype: ['external'] //content setting ['inline'] or ['external', 'path_to_external_file']
})






    
    //mostrar previsión del tiempo
    	//detectar que linka se activa
	$('#link-tiempo').click(function(){
		$('#forecast').addClass('form-color');
		//$('#test1').show('slow'); // para mostrar
		$('#forecast').toggle('fast'); // mostrar/ocultar
		//$("#forecast").click(function () { $("#forecast").slideToggle(); });
		
	});
    
    
    
    
    //combo de urbanizaciones y zonas
   $("#alq_zona").change(function () {
   		$("#alq_zona option:selected").each(function () {
			//alert($(this).val());
				elegido=$(this).val();
				$.post("/ajax/zonas.php", { elegido: elegido }, function(data){
				$("#alq_urbanizacion").show();
                $("#alq_urbanizacion").html(data);
			});			
        });
   })
    


   
   
   //newsletter
	  $('#iform').submit(function(e){
	        e.preventDefault();
	        $('#forminfo').validationEngine('hideAll');

    /**$('.news_send').click(function(e) {
    	e.preventDefault();**/
       // we want to store the values from the form input box, then send via ajax below   
	   if ($("#iform").validationEngine('validate')){
       var f_email			= $('#f_email').attr('value');  
       var f_category		= $('#f_category').attr('value');
           $.ajax({  
               url: "/ajax/newsletter.php",  
               async:true,
               beforeSend: function(objeto){
                   $('#news_box').html('<img src="/img/loader_90.gif" align="center" alt="Cargando..." id="loading-gif" />')
               },
  
  
               data: "f_email="+ f_email+"& f_category="+ f_category,  
               dataType: "json",
               success: function(data)
               {
                   if (data.exito == true) {
            		   
                	   $('form#news_iform').hide(function(){$('div.success').fadeIn();});  
                       //$('#news_ok').show();
                       $('#news_box').html(data.result);
                   }else
                   {
                	   $('form#news_iform').hide(function(){$('div.success').fadeIn();});  
                       //$('#news_error').show();
                       $('#news_box').html(data.result);
                   }  
               },
               timeout: 60000,
               type: "POST"
           });
	   };
       });
     //hasta aquí el ajax
	
   $('#iform').validationEngine('');
   
   $('.news_legal').click(function(e) {
       e.preventDefault()
       	$.fx.speeds._default = 1000;
   	$(function() {
   		$( "#news_legal" ).dialog({
   			autoOpen: true,
               width: 500,
               hight:350,
   			show: "blind",
   			hide: "silde"
   		});
   	});
   });   


   


})

/*Jqueryui*/
$(function() {
		$( "#tabs" ).tabs();
        $( "#accordion" ).accordion();

	});


// WEBCMA POPUP
	$.fx.speeds._default = 1000;
	$(function() {
		$( "#dialog" ).dialog({
			autoOpen: false,
			show: "blind",
			hide: "explode",
            height: 570,
            width: 660

		});

		$( "#opener" ).click(function() {
			$( "#dialog" ).dialog( "open" );
			return false;
		});
	});


