var varOcultar=true;
$(document).ready(function(){
    //Solicitud de servicios
	/*$("#forma_observaciones input[name='area']").click(function(){
		var area = "." + $(this).val();
		$("#forma_observaciones .box_areas").show();
		$("#forma_observaciones .hide").hide();
		$("#forma_observaciones .planta").hide();
		$(area).fadeIn();
	});*/



	$('#iaRut').click(function(){
		if ($(this).val()=='Ingrese su Rut'){
			$(this).val('');
		}
	});
	$('#iaRut').blur(function(){
		if ($(this).val()==''){
			$(this).val('Ingrese su Rut');
		}
	});
	
	$('#iaRut').keyup(function() {
		if (this.value.match(/[^0-9kK-]/g)) {
			this.value = this.value.replace(/[^0-9kK-]/g, '');
		}
	});
	
	$("#tPass").click(function(){
		$("#tPass").hide();
		$('#iaPassword').focus();
	})
	
	$('#iaPassword').focus(function(){
		$("#tPass").hide();
	});

	$('#iaPassword').blur(function(){
		if ($(this).val()==''){
			$("#tPass").show();
		}
	});


	$("#iaLogin").click(function(){
		var rut = $('#iaRut').val();
		var clave = $('#iaPassword').val();
		rut = rut.replace(/[^0-9kK]/g, '')  ;
		$.ajax({
			type: "POST",
			url: "/validaloginLightbox.php",
			data: "txtRutLogin="+rut+"&txtPassLogin="+clave+"",
			success: function(msg){
				
				if (msg=='ok'){

				// -----------------------------------
				// Obtener Informacion Adicional para Metriplica
				// -----------------------------------
						$.ajax({
							async : false ,
							dataType:"json",
							type: "POST",
							url: "/op_ajax.php",
							data: "tipo=userinfo" , 
							
							success: function( datos ){

								if( datos.CODE == 'OK' ) {
				// -----------------------------------
				if(qa==true)
				{
				   var buff = "_gaq.push(function(){mxTracker.markingup();});" ;
				   buff = buff  + "_gaq.push(function(){mxTracker._setSeg1('1');});";
				   buff = buff  + "_gaq.push(function(){mxTracker._setSeg2('0');});";
				   buff = buff  + "_gaq.push(function(){mxTracker._setSeg3('0');});";
				   buff = buff  + "_gaq.push(function(){mxTracker._setSeg4('" + datos.DATA.FLD4 + "');});";
				   buff = buff  + "_gaq.push(function(){mxTracker._setSeg5('" + datos.DATA.FLD5 + "');});";
			 	   buff = buff  + "_gaq.push(function(){mxTracker._setSeg6('" + datos.DATA.FLD6 + "');});";
				   buff = buff  + "_gaq.push(function(){mxTracker._setSeg7('" + datos.DATA.FLD7 + "');});";
				   buff = buff  + "_gaq.push(function(){mxTracker._setSeg8('" + datos.DATA.FLD8 + "');});";
				   buff = buff  + "_gaq.push(function(){mxTracker._setSeg9('" + datos.DATA.FLD9 + "');});";
				   var buff = buff  +"_gaq.push(function(){mxTracker._trackContent('LoginUsuarioWeb');});" ;
				   eval( buff ) ;
				}
				// -----------------------------------
								
								}
							}
						});
				// -----------------------------------
				// Obtener Informacion Adicional para Metriplica
				// -----------------------------------
					
					window.location.href= window.location.href;
					
				}else{
					$('#msgLogin').html('Rut o contrase&ntilde;a incorrectos.');
					$('#msgLogin').fadeIn('slow');
					setTimeout("$('#msgLogin').fadeOut('slow');",5000);
				}
			}       
		});
	});
	
	$("#iaRegistrate").click(function(){
		window.location = "/registro/"
	});
	
	$("#iaSalir").click(function(){
		window.location = "/log_out.php"
	});



 

  
  	// Posventa
  
	$("#forma_observaciones input[name='area']").click(function(){
        $("#forma_observaciones .box_observaciones").hide();
		$("#forma_observaciones .box_observaciones").fadeIn();
	});	
	
	$(function() {
		$("#draggable").draggable({
		   containment: ".map_marker",
           stop: function(event, ui) {
				var pos_x = $("#draggable").css("left");
				var pos_y = $("#draggable").css("top");
				var x = pos_x.replace("px", "");
				var y = pos_y.replace("px", ""); 
				$("#hdnX").val(x);
				$("#hdnY").val(y);
		   }								
		});
	});
	
		
	$(".myitem a").click(function(){
		$("#item div a img").removeClass('imgDest');
		$(this).addClass('imgDest');
		imagen = $(this).attr('href');
		lugar = $(this).attr('title');
		
		$("#draggable").fadeOut('fast');
		$("#imgProblema").fadeOut('fast',function(){
			$("#hdnImg").val(imagen);
			$("#hdnLugar").val(lugar);
			$(this).attr("src",imagen);
			$(this).fadeIn('slow');
			
			$("#draggable").css({'left' : 0, 'top' : 0});
			$("#draggable").fadeIn('slow');
			$("#hdnX").val(0);
			$("#hdnY").val(0);
			
			
		});
		return false;
	});
		
	/******* editar mi perfil ***********************************/
	$(".dato.edit").hide();
	$(".btn-guardar-perfil").hide();
	$(".editar").click(function(){
		$(this).hide();
		$(this).parent().find('.dato.ingresado').hide();
		$(this).parent().find('.dato.edit').show();
		$(this).parent().find('.btn-guardar-perfil').show();
		return false;
	});
	$(".btn-cancelar ").click(function(){
		$(this).parent().parent().find('.dato.edit').hide();
		$(this).parent().parent().find('.btn-guardar-perfil').hide();
		$(this).parent().parent().find('.dato.ingresado').show();
		$(".editar").show();
		return false;
	});
	/******* editar mi perfil ***********************************/
	
	
	/******* favoritos ***********************************/
	$(".favorito").css({'cursor':'pointer'});
	
	$(".favorito").click(function(){
		if ( $(this).attr('class') == 'favorito si' ){
			$(this).removeClass('si');
		}
		else{
			$(this).addClass('si');
		}
	});
	/******* favoritos ***********************************/
	
	$(".pop[rel]").overlay({
		speed: '0',
		mask: 'black',
		fixed: false,
		left :"center",
		top: "5%",
		onBeforeLoad: function() {
			var wrap = this.getOverlay().find(".contentWrap");
			wrap.load(this.getTrigger().attr("href"));
		}
	});
	
	
	//$("#mapa_chile a[title]").tooltip({tipClass:'ayudita'});
	// tool tip mapa chile
	
	$("#mapa_chile div").hide();
	$('#mapa_chile .punto a').click(function(){
		$("#mapa_chile div").hide();
		$(this).parent().find("div").slideDown();
		return false;
	});
	$('#mapa_chile div').mouseleave(function(){
		$(this).parent().find("div").slideUp();
	});
	
	
	$(".option-plane a").click(function(){
		$(this).parent().find('a').removeClass('actual');
		$(this).addClass('actual');
		var tab = $(this).attr('href');
		$(".box_vista").hide();
		$(tab).fadeIn();
		return false;
	});
	
	$(".vistalista thead.item").click(function(){
		$(this).parent().find("tbody").toggle();
		$(this).toggleClass("open");
	});	
		$(".vistalista .all").click(function(){
		$(this).parent().parent().parent().parent().find("input").attr("checked",true);
		return false;
	});
	$(".vistalista .none").click(function(){
		$(this).parent().parent().parent().parent().find("input").attr("checked",false);
		return false;
	});	
	
	// tus favoritos home
	$(".box-favoritos").hide();
	$(".box-favoritos").parent().mouseleave(function(){
		$(this).find(".box-favoritos").slideUp(300, function(){
				$('#user .favo').removeClass("act");
			});
	});
	
	
	//encuesta paso dos
	$(".encuesta").hide();
	$('.btn-ver-mas').toggle(function(){
		$(this).parent().find(".encuesta").slideDown();
		return false;
	},function(){
		$(this).parent().find(".encuesta").slideUp();
		return false;
	});
	$(".botones a ").click(function(){
		$(".encuesta").hide();
		return false;
	});
	
	
	$('#user .favo').click(function(){
		if( $(this).attr("class") == "favo act" ){
			$(this).parent().find(".box-favoritos").slideUp(300, function(){
				$('#user .favo').removeClass("act");
			});
		}else{
			$(this).parent().find(".box-favoritos").slideDown();
			$('#user .favo').addClass("act");
		}
	});
	
	
	//input sugerencias
	$("#suggest").hide();
	
	$('#buscador .combtn').click(function(){
		if( $(this).attr("class") == "combtn opened" ){
			$(this).removeClass("opened");
			$("#suggest").slideUp();
		}else{
			$(this).addClass("opened");
			$("#suggest").slideDown();
			$("#input-buscador").val('');
			$("#input-buscador").focus();
			
		}
	});
	
	$('#salaVentasForm .accion').click(function(){
		if( $(this).attr("class") == "accion opened" ){
			$(this).removeClass("opened");
			$("#suggest_sl").slideUp();
		}else{
			$(this).addClass("opened");
			$("#suggest_sl").slideDown();
			$("#terminoSalaVentasForm").val('');
			$("#terminoSalaVentasForm").focus();
		}
	});
	
	//$("#suggest li ul li ul li ").click(function(){
	$("#suggest li ul li ul li a").click(function(){
		var str = $(this).text();
		$("#input-buscador").val(str);
		$("#suggest").slideUp();
		$('#buscador .combtn').removeClass("opened");		
		return true;
	});
	$("#suggest li ul li ul li a").hover(
		function(){
			$(".cont_hover").removeClass("hoverMenu");
			var nombre_id = $(this).attr("id");
			var arr = nombre_id.split("_");
			numBusqueda = arr[1];
		},
		function(){
			
		}
	)
	
	$('#buscador').mouseleave(function(){
		$("#suggest").slideUp();
		$('#buscador .combtn').removeClass("opened");
	});
	
	

	// Transversal, Llamados de tipografia (Cufon)
	Cufon.replace('.type');
	
	//-> Portada, Sliders para precios (Jquery UI)
	//-> Portada, Sliders para precios (Jquery UI)
	$("#total_range").slider({
		range: true,
		min: 800,
		max: 25000,
		step: 100,
		values: [800, 25000],
		slide: function(event, ui) {
			$("#total_value").val('UF ' + agregaPuntosFijo(ui.values[0]) + ' - UF ' + agregaPuntosFijo(ui.values[1]) );
		}
	});
	
	$("#total_value").val('UF ' + agregaPuntosFijo($("#total_range").slider("values", 0)) + ' - UF ' + agregaPuntosFijo($("#total_range").slider("values", 1)) );


	/* comentado por error en explorer 6
	//-> Financiamiento, Slider para tasa de interés
	$('#tasa.slider').slider({
		slide: function(event, ui) {
			$(this).next().text(ui.value + '%');
		}
	});
	*/
	$('#annos.slider').slider({
		slide: function(event, ui) {
			$(this).next().children().text(ui.value);
		}
	});
	
	
	$('#tasados.slider').slider({
		slide: function(event, ui) {
			$(this).next().children().text(ui.value);
		}
	});
	
	$('#monto1.slider').slider({
		min: 0,
		max: 30000,
		step: 100,
		slide: function(event, ui) {
			$(".monto1").val(agregaPuntosFijo(ui.value));
		}
	});
	
	$('#monto2.slider').slider({
		min: 0,
		max: 5000000,
		step: 10000,
		slide: function(event, ui) {
			$(".monto2").val(agregaPuntosFijo(ui.value));			
		}
	});
	
	$('#pie1.slider').slider({
		min: 0,
		max: 3000,
		step:50,
		slide: function(event, ui) {
			$(".pie1").val(agregaPuntosFijo(ui.value));
		}
	});
	$('#pie2.slider').slider({
		min: 0,
		max: 60000000,
		step:100000,
		slide: function(event, ui) {
			$(".pie2").val(agregaPuntosFijo(ui.value));
		}
	});
	
	$('#plazo0.slider').slider({
		min: 0,
		max: 30,
		slide: function(event, ui) {
			$(".plazo0").val(ui.value);
		}
	});
	
	$('#plazo1.slider').slider({
		min: 0,
		max: 30,
		slide: function(event, ui) {
			$(".plazo1").val(ui.value);
		}
	});
	$('#plazo2.slider').slider({
		min: 0,
		max: 30,
		slide: function(event, ui) {
			$(".plazo2").val(ui.value);
		}
	});
	
	$('#interes0.slider').slider({
	    min: 0.0,
		max: 8.0,
		step: 0.1,
		slide: function(event, ui) {
			$(".interes0").val(ui.value);
		}
	});
	
	$('#interes1.slider').slider({
	    min: 0.0,
		max: 8.0,
		step: 0.1,
		slide: function(event, ui) {
			$(".interes1").val(ui.value);
		}
	});
	
	$('#interes2.slider').slider({
	    min: 0.0,
		max: 8.0,
		step: 0.1,
		slide: function(event, ui) {
			$(".interes2").val(ui.value);
		}
	});
	

	$("#dividendo_range").slider({
		range: true,
		min: 50000,
		max: 5000000,
		step: 50000,
		values: [50000, 5000000],
		slide: function(event, ui) {
			$("#dividendo_value").val('$' + agregaPuntosFijo(ui.values[0]) + ' - $' + agregaPuntosFijo(ui.values[1]) );
		}
	});
	
	$("#dividendo_value").val('$' + agregaPuntosFijo($("#dividendo_range").slider("values", 0)) + ' - $' + agregaPuntosFijo($("#dividendo_range").slider("values", 1)) );
	//<- Sliders para precios 	

	// Portada, Opciones Extras 
	$("#extras").hide();
	$(".extras").click( function(){
		$(this).removeClass( "selected" )
		if( $("#extras").is (':hidden') ) {
			$(this).addClass( "selected" )
		}
		$("#extras").toggle();
		return false;
	});

	// Transversal, Muestra oculta Cajas de Buscador Lateral
	
	
	

	$(".full p").hide();
	$(".full p").addClass("cerrado");
	$(".full label").click(function(){
		
			$(".full label").removeClass("minus");	
		
		session = $(this).html().substring(0,2);

		$(".full p").hide();

		var acc = 0
		
		$(this).parent().find("div").hide();
		
		if($(this).parent().find("p").attr('class') == 'favfive abierto' || $(this).parent().find("p").attr('class') == 'abierto'){
		
			acc = 1;
			$(this).parent().find("p").slideUp();					
			$(this).parent().find("p").removeClass("abierto");
			$(this).parent().find("p").addClass("cerrado");
			
			$(this).parent().find("label").removeClass("minus");	
			
		} else {

			acc = 2;
			$(".full p").removeClass("abierto");
			$(this).parent().find("p").slideDown();						
			$(this).parent().find("p").removeClass("cerrado");
			$(this).parent().find("p").addClass("abierto");	
			
			
			
			$(this).parent().find("label").addClass("minus");	

		}
		
		sDetallesAv();
		sDetalles(".cbxComuna:checked","#sel-comuna div");
		sDetalles(".chkRegion:checked","#sel-region div");
		if (acc == 2){
			$(this).parent().find("div").fadeOut();
		}
	});
	$("label.title").append("<span>&nbsp;</span>");
	

	// -> LLamados de Carruseles (Jquery Tools)
	
	$(".banners").scrollable({
		size: '1',
		items: ".items_top",
		clickable: false,
		circular: true
	}).navigator({navi:'.tab_top'}).autoscroll(8000);
	
	$(".proyectos").scrollable({
		size: '2',
		items: ".items_proyectos",
		prev: ".prev_proyectos" ,
		next: ".next_proyectos",
		clickable: false
	});
	
	$(".proyectos").scrollable({
		size: '2',
		items: ".items_proyectos",
		prev: ".prev_proyectos" ,
		next: ".next_proyectos",
		clickable: false
	});
	
	$(".carrousel-dormitorios").scrollable({
		size: '4',
		items: ".franja",
		prev: ".btn-anterior" ,
		next: ".btn-siguiente",
		clickable: false,
		circular: true
	}).autoscroll(3500);
	
	
	
	
	$(".scroll_proye").scrollable({
		items: "ul",
		prev: ".arrow_proye.left" ,
		next: ".arrow_proye.right",
		clickable: false
		
	});
	
	$(".sugerencias_scroll").scrollable({
		items: "ul",
		prev: ".arrow_suge.left" ,
		next: ".arrow_suge.right",
		clickable: false
	});
	
	$("#ultimas").scrollable({
		size: '5',
		items: ".items_ultimas",
		prev: ".prev_ultimas",
		next: ".next_ultimas",
		clickable: false
	});
	
	$("#interesarte").scrollable({
		size: '5',
		items: ".items_interesarte",
		prev: ".prev_interesarte",
		next: ".next_interesarte",
		clickable: false
	});
	
	$("#opor").scrollable({
		size: '3',
		items: ".items_opor",
		prev: ".prevPage_opor" ,
		next: ".nextPage_opor",
		clickable: false
	});
	
	$(".alternatives").scrollable({
		size: '3',
		items: ".items",
		prev: ".prevPage_alternatives" ,
		next: ".nextPage_alternatives",
		clickable: false
	});
	
	$("#fav").scrollable({
			size: '4',
			items: ".items_fav",
			prev: ".prev_fav" ,
			next: ".next_fav",
			clickable: false
	});
	

	$(".carru .box").scrollable();

	
	// <- LLamados de Carruseles
	
		
	// Transversal, Creador de Botones. (Jquery UI)
	$(".btn").button();
	
	// -> Transversal, Tabs (Jquery Tools)
	$("ul.tabs").tabs("div.panes > div");
		
		//mis actividades
		$(".mis-acti-tabs").tabs(".panes_acti > .pane_acti");
		
		// Rangos
		$("#rangos").tabs("div.items_rangos > div.item_rangos");
		
		$("#rangos ul li a").click(function(){
			valor = $(this).attr("rel");
			$("#opcionRango").val(valor);
			
			if(  ! $( this ).parent() .parent() .parent() .hasClass( 'index' )  ) {
				busqueda_viva();
			}
		});
		
		
		// Recomendaciones
		$("ul.tabs_recomendaciones").tabs(".boxs_recomendaciones > .box_recomendaciones");
		// Resultados
		//$('.swap').tabs('.resu-panes > .resu-pane', {effect: 'fade', fadeOutSpeed: 400});
		
		$('.proceso-tabs').tabs('.proceso-panes > .proceso-pane');


	// <- Tabs	
	
	
	// Transversal, Input Super Cleaner.
	$(".clean").each(function(){
		var value = $(this).val();
		$(this).focusin(function(){if($(this).val() == value){$(this).val("");};});
		$(this).focusout(function(){if($(this).val() == ''){$(this).val(value);};});
	});
	
	// Transversal, Combobox Super Caller.
	$("ol.combo").cocombobox();
	
	// acordeon
	$(".accordion").tabs(".accordion div.aco-pane", {tabs: 'h4', initialIndex: null});
	
	$('.accor').tabs(".accor li div", {tabs: 'li a.accor_link', initialIndex: null})
	

	// cerrar oferta
	$('div#banner_publicidad .oferta .cerrar').click(function(){$(this).parent().parent().fadeOut();});


	// cerrar oferta
	$('.oferta .cerrar').click(function(){$(this).parent().fadeOut();});
	
	// tabla modelo
	$('.modelos').hide();
	$('.modelo').click(function(){$(this).toggleClass('up').siblings('div.modelos').toggle(200);return false;});
	
	//-> Transversal, llamados para Galeria 	
	$("#gallery").append('<span class="foot"></span>');
	$(".bobtoronja").append('<span class="foot"></span>');
	
	$(".trans").append('<span class="back"></span>');
	$(".back").css({'opacity':'0.7'});

	$("#gallery .navi a.galeria").click(function(){
		$(this).parent().parent().animate({'bottom':'0','opacity':'hide'}, 300);
		var enlace = $(this).attr("href");
		
		/* Metriplica */	
		if(qa==true)
		{
			_gaq.push(function(){mxTracker.markingup();}); 
			_gaq.push(function(){mxTracker._setActionVar('VieronFotografias');}); 
			_gaq.push(function(){mxTracker._trackContent('/Proyectos/VerFotografias/' +  enlace );}); 
		}
		/* Metriplica */		
		
		$(this).parent().parent().parent().find(".box").hide();
		$(enlace).fadeIn();
		$(enlace).find(".close").show();
		return false;
	});
	
	
	$("#gallery .box").append('<a href="#" title="enlace" class="close">Cerrar</a>');
	$("#gallery .box .close").click(function(){
		$(this).parent().fadeOut(function(){
			$("#gallery .navi").animate({'bottom':'20px','opacity':'show'}, 300);
			
		});
		return false;	
	});
	
	
	//<- Fin llamados para Galeria
	
	// facilidades
	$(".facilidades").hide();
	$('.btn-facilidades').toggle(function(){
		$(this).addClass("sel");
		$(".facilidades").slideDown();
		return false;	
		  },
		  function () {
		   $(this).removeClass("sel");
		   $(".facilidades").hide();
		   });
		$(".facilidades").mouseleave(function(){
		$(this).hide();
		$('.btn-facilidades').removeClass("sel");
	});
	// compartir

		
	// tool tip detalles
		$(".detail .cont").hide();
		$(".btn-open").click(function(){
			$(this).parent().find(".cont").show();
			return false;	
		});
		$(".btn-close").click(function(){
			$(this).parent().parent().parent().find(".cont").hide();
			return false;	
		});
	
	// Llamados para sugerencias	
	$(".sugerencias_scroll a").click(function(){
		var id_perfil = $(this).attr("href");
		$(".sugerencias_scroll a").parent().removeClass("active");
		$(this).parent().addClass("active");
		$(".principal").hide();
		$(id_perfil).fadeOut(0,function(){
				$(this).fadeIn(1900);
		});
		return false;
	});
	
	
	$(".scroll_proye a").click(function(){
		var id_proye = $(this).attr("href");
		$(this).parent().parent().find("li").removeClass("active");
		$(this).parent().addClass("active");
		$(this).parent().parent().parent().parent().parent().find(".proyecto").hide();
		$(id_proye).fadeOut(0,function(){
				$(this).fadeIn(1900);
		});
		return false;
	});
	
	
	//contratulations
	var keys=[];var konami='38,38,40,40,37,39,37,39,66,65';
	$(document).keydown(function(e){keys.push(e.keyCode);
	if(keys.toString().indexOf(konami)>=0){alert("You really need a life!");
	keys=[];}});
	
	$(".tool-tip-calcula").hide();
	$(".calcula .btn-calcula img").mouseenter(function(){
		$(".tool-tip-calcula").fadeIn();
	});
	
	$(".calcula").mouseleave(
	function() {
		$(".tool-tip-calcula").fadeOut();
	});
	// PARAEL TOOL TIP DE PREGUNTA
	$(".tool-tip-dividendo").hide();
	$(".precioDividendo .btn-dividendo img").mouseover(function(){
		varOcultar=false;
		//$(this).parents(".tool-tip-dividendo").fadeIn();
		$('.tool-tip-dividendo').fadeIn();
		$('.tool-tip-dividendo').css({left:$(this).offset().left + 18, top:$(this).offset().top - 9 });
	});
	$(".btn-dividendo").mouseleave(function() {
		varOcultar=true;
		setTimeout("fadeOutToolTip()",500);
	});
	$(".tool-tip-dividendo").mouseover(function(){
		varOcultar=false;
		$('.tool-tip-dividendo').show();
	});
	$(".tool-tip-dividendo").mouseout(function(){
		
		if(!varOcultar){
			varOcultar=true;
			setTimeout("fadeOutToolTip()",500);
		}
	});
	

	// PARAEL TOOL TIP DE PREGUNTA
	
	// tabla agendar
		$(function () {
				if ($.browser.msie) {
				   $('input:radio').click(function () {
				       this.blur();
				       this.focus();
		        });
		    }
		});
		$('#tarde, #noche').hide();	
		$('.agenda-op input').click(function(){
				var val = $(this).val();
				switch(val){
						case 'tarde':
								$('#manana, #noche').hide();
								$('#tarde').fadeIn();
						break;
						case 'noche':
								$('#manana, #tarde').hide();
								$('#noche').fadeIn();
						break;
						default:
								$('#tarde, #noche').hide();
								$('#manana').fadeIn();
						break;
				}
		});
		
		
	/**** muestra y esconde novedades ****/
	$(".vermas_novedades").click(function(){

		if( $(".novGrupo_1").hasClass("activo") ){

			$(".novGrupo_1").fadeOut("slow",function(){
				if( $(".novedades li").hasClass("novGrupo_2") ){					
					$(".novGrupo_2").fadeIn("slow");
					$(".novGrupo_1").removeClass("activo");
					$(".novGrupo_2").addClass("activo");
				}
				else{
					$(".novGrupo_1").fadeIn("slow");	
				}
			});
		}
		else if( $(".novGrupo_2").hasClass("activo") ){
						
			$(".novGrupo_2").fadeOut("slow",function(){
				$(".novGrupo_2").removeClass("activo");
				
				if( $(".novedades li").hasClass("novGrupo_3") ){								
					$(".novGrupo_3").fadeIn("slow");					
					$(".novGrupo_3").addClass("activo");
				}
				else{
					$(".novGrupo_1").fadeIn("slow");
					$(".novGrupo_1").addClass("activo");
				}
			});
		}
		else if( $(".novGrupo_3").hasClass("activo") ){
			$(".novGrupo_3").removeClass("activo");
			
			$(".novGrupo_3").fadeOut("slow",function(){
				if( $(".novedades li").hasClass("novGrupo_4") ){
					$(".novGrupo_4").fadeIn("slow");
					$(".novGrupo_4").addClass("activo");		
				}
				else{
					$(".novGrupo_1").fadeIn("slow");
					$(".novGrupo_1").addClass("activo");	
				}
			});					
		}
		else if( $(".novGrupo_4").hasClass("activo") ){
			$(".novGrupo_4").removeClass("activo");
			
			$(".novGrupo_4").fadeOut("slow",function(){
				if( $(".novedades li").hasClass("novGrupo_5") ){
					$(".novGrupo_5").fadeIn("slow");
					$(".novGrupo_5").addClass("activo");			
				}
				else{
					$(".novGrupo_1").fadeIn("slow");
					$(".novGrupo_1").addClass("activo");	
				}
				
			});						
		}
		else if( $(".novGrupo_5").hasClass("activo") ){
			$(".novGrupo_5").removeClass("activo");
			
			$(".novGrupo_5").fadeOut("slow",function(){
				if( $(".novedades li").hasClass("novGrupo_6") ){
					$(".novGrupo_6").fadeIn("slow");
					$(".novGrupo_6").addClass("activo");
				}
				else{
					$(".novGrupo_1").fadeIn("slow");
					$(".novGrupo_1").addClass("activo");	
				}
			});
		}
		else if( $(".novGrupo_6").hasClass("activo") ){
			$(".novGrupo_6").removeClass("activo");
			$(".novGrupo_1").addClass("activo");						
			
			$(".novGrupo_6").fadeOut("slow",function(){
				$(".novGrupo_1").fadeIn("slow");
			});
		}		
	});
	/**** muestra y esconde novedades ****/
	
	
	// eliminar favoritos
	$('#fav .eliminar').click(function(){
		$(this).parent().fadeOut();
	});
	
	
	
	/******** seguimiento de compra *******************/
	$(".ventanas_seguimiento").addClass("pasivo");
	//$(".sub_ventanas_seguimiento").addClass("pasivo");
	
	$(".btn_cotizacion").click(function(){
		$(".ventanas_seguimiento").removeClass("activo");
		$(".ventanas_seguimiento").addClass("pasivo");
		
		$("#area_cotizacion").removeClass("pasivo");
		$("#area_cotizacion").addClass("activo");
		$(".sub-pasos").removeClass("activo"); // sacamos submenu
		$(".sub-pasos").addClass("pasivo"); // sacamos submenu
		$(this).parent().removeClass("pas");
		$(this).parent().addClass("act2");
		if($(".btn_entrega").length > 0){
			$(".dos").removeClass("act3"); 
			$(".dos").removeClass("pas2"); // sacamos pasivo
			$(".dos").addClass("pas"); // agregamos activo
			$(".tres").removeClass("act");
			$(".tres").addClass("pas2");
		}else{
			$(".dos").removeClass("act"); // sacamos pasivo
			$(".dos").addClass("pas2"); // agregamos activo
		}

	});
	
	$(".btn_compra").click(function(){
		
		$(".ventanas_seguimiento").removeClass("activo");
		$(".ventanas_seguimiento").addClass("pasivo");
		
		$("#area_compra").removeClass("pasivo");
		$("#area_compra").addClass("activo");
		$(".sub-pasos").removeClass("pasivo"); // agregamos submenu
		$(".sub-pasos").addClass("activo"); // agregamos submenu
		
		
		$(".uno").removeClass("act2"); // sacamos activo
		$(".uno").addClass("pas"); // agregamos pasivo
		
		$(".dos").removeClass("pas2"); // sacamos pasivo
		$(".dos").addClass("act"); // agregamos activo
		
		if($(".btn_entrega").length > 0){
			$(".tres").removeClass("act");
			$(".tres").addClass("pas2");
			$(".dos").removeClass("pas");
			$(".dos").removeClass("act"); 
			$(".dos").addClass("act3"); 
			
		}
		
		
	});
	
	
	$("#sub_reserva").click(function(){
		if($(this).attr("class") == "past"){
			$(".sub_ventanas_seguimiento").addClass("pasivo");
			$(".sub_ventanas_seguimiento").removeClass("activo");
			$("#area_reserva").removeClass("pasivo");
			$("#area_reserva").addClass("activo");
			
			$(this).removeClass("past");
			$(this).addClass("actual");
			$(this).html('1. Reserva');
			
			if($("#sub_promesa").attr("class") == "actual"){
				$("#sub_promesa").removeClass("actual");
				$("#sub_promesa").addClass("past");
				$("#sub_promesa").html('<a href="javascript:;" title="">2. Promesa</a>');
			}
			if($("#sub_escritura").attr("class") == "actual"){
				$("#sub_escritura").removeClass("actual");
				$("#sub_escritura").addClass("past");
				$("#sub_escritura").html('<a href="javascript:;" title="">3. Escritura</a>');
			}
		}
	});
	$("#sub_promesa").click(function(){
		if($(this).attr("class") == "past"){
			$(".sub_ventanas_seguimiento").addClass("pasivo");
			$(".sub_ventanas_seguimiento").removeClass("activo");
			$("#area_promesa").removeClass("pasivo");
			$("#area_promesa").addClass("activo");
			
			$(this).removeClass("past");
			$(this).addClass("actual");
			$(this).html('2. Promesa');
			
			if($("#sub_reserva").attr("class") == "actual"){
				$("#sub_reserva").removeClass("actual");
				$("#sub_reserva").addClass("past");
				$("#sub_reserva").html('<a href="javascript:;" title="">1. Reserva</a>');
			}
			if($("#sub_escritura").attr("class") == "actual"){
				$("#sub_escritura").removeClass("actual");
				$("#sub_escritura").addClass("past");
				$("#sub_escritura").html('<a href="javascript:;" title="">3. Escritura</a>');
			}
		}
	});
	$("#sub_escritura").click(function(){
		if($(this).attr("class") == "past"){
			$(".sub_ventanas_seguimiento").addClass("pasivo");
			$(".sub_ventanas_seguimiento").removeClass("activo");
			$("#area_escritura").removeClass("pasivo");
			$("#area_escritura").addClass("activo");
			
			$(this).removeClass("past");
			$(this).addClass("actual");
			$(this).html('3. Escritura');
			
			if($("#sub_promesa").attr("class") == "actual"){
				$("#sub_promesa").removeClass("actual");
				$("#sub_promesa").addClass("past");
				$("#sub_promesa").html('<a href="javascript:;" title="">2. Promesa</a>');
			}
			if($("#sub_reserva").attr("class") == "actual"){
				$("#sub_reserva").removeClass("actual");
				$("#sub_reserva").addClass("past");
				$("#sub_reserva").html('<a href="javascript:;" title="">1. Reserva</a>');
			}
		}
	});
	
	
	$(".btn_entrega").click(function(){
		$(".ventanas_seguimiento").removeClass("activo");
		$(".ventanas_seguimiento").addClass("pasivo");
		
		$("#area_entrega").removeClass("pasivo");
		$("#area_entrega").addClass("activo");
		
		$(".sub-pasos").removeClass("activo"); // agregamos submenu
		$(".sub-pasos").addClass("pasivo"); // agregamos submenu
		$(".uno").removeClass("act2"); // sacamos activo
		$(".uno").addClass("pas"); // agregamos pasivo
		$(".dos").removeClass("pas2"); // sacamos pasivo
		$(".dos").removeClass("act3"); 
		$(".dos").addClass("pas"); // agregamos activo
		$(".tres").removeClass("pas2");
		$(".tres").addClass("act");
	});
	/******** seguimiento de compra *******************/
		
});

$(function() {    
	var conveyor = $(".items_sugerimos", $("#sugerimos")),
	item = $(".item_sugerimos", $("#sugerimos"));
	conveyor.css("width", item.length * parseInt(item.css("width")));
	var sliderOpts = {
	  max: (item.length * parseInt(item.css("width"))) - parseInt($(".viewer_sugerimos", $("#sugerimos")).css("width")),
	  slide: function(e, ui) { 
		conveyor.css("left", "-" + ui.value + "px");
	  }
	};
	
$("#slider_sugerimos").slider(sliderOpts);


});
function fadeOutToolTip(){
	if(varOcultar){
		$('.tool-tip-dividendo').fadeOut();
		varOcultar=true;
	}
	
}
function mostrarToolTip(obj){
		//$(this).parents(".tool-tip-dividendo").fadeIn();
		
	$('.tool-tip-dividendo').fadeIn();
	$('.tool-tip-dividendo').css({left:$('#pregunta').offset().left + 18, top:$('#pregunta').offset().top - 15 });
};
function ocultarToolTip(obj){
		//$(this).parents(".tool-tip-dividendo").fadeIn();
	$('.tool-tip-dividendo').fadeOut();
};

function Mostrar_Telefonos(){
	var region= $('.sel').attr('rel');
	if(region==0){
		alert('Debe seleccionar una Zona');
	}else{
		urlPop('/lightbox-centro-asistencia.php?reg='+region,680,440);
	}
}
