function sizeCards(){

  $(".ccardssliderwrap,.ceventosgrid").each(function(){
    $(".citemnewhorz",this).removeAttr("style");
    var height=0;
    $(".citemnewhorz",this).each(function(){
      var elheight=$(this).height();

      if  (height<elheight){
        height=elheight;
      }
    });
    $(".citemnewhorz",this).height(height);

  });


}
function divideMenu(){
  // Select the original cmenuwrap div and its ul
            var $originalCmenuWrap = $('.cmenuwrap');
            var $ul = $originalCmenuWrap.find('ul').first();

            // Find all the direct li children
            var $li = $ul.children('li');

            // Calculate the middle index
            var middleIndex = Math.ceil($li.length / 2);

            // Split the li elements into two parts
            var $firstHalf = $li.slice(0, middleIndex);
            var $secondHalf = $li.slice(middleIndex);

            // Create a new cmenuwrap div and a new ul
            var $newCmenuWrap = $('<div class="cmenuwrap"></div>');
            var $newUl = $('<ul></ul>');

            // Append the second half of the li elements to the new ul
            $secondHalf.appendTo($newUl);

            // Append the new ul to the new cmenuwrap
            $newCmenuWrap.append($newUl);

            // Insert the new cmenuwrap after the original cmenuwrap
            $originalCmenuWrap.after($newCmenuWrap);

            // Add cmenuwrap1 class to the original cmenuwrap and cmenuwrap2 to the new one
            $originalCmenuWrap.addClass('cmenuwrap1');
            $newCmenuWrap.addClass('cmenuwrap2');

}

jQuery.extend(jQuery.expr[':'], {
    attrStartsWith: function (el, _, b) {
        for (var i = 0, atts = el.attributes, n = atts.length; i < n; i++) {
            if(atts[i].nodeName.toLowerCase().indexOf(b[3].toLowerCase()) === 0) {
                return true;
            }
        }

        return false;
    }
});
function prependClass(sel, strClass) {
    var $el = jQuery(sel);

    /* prepend class */
    var classes = $el.attr('class');
    classes = strClass +' ' +classes;
    $el.attr('class', classes);
}

function responsive(){
  var wwidth=$(window).width();
  $('*:attrStartsWith("data-resp-")').each(function(){
    var thethis=$(this);
    var highest=0;
    $.each(this.attributes, function() {
      if(this.specified) {
        var resp=this.name.replace('data-resp-', '');
        var value=this.value;

        if (highest<resp){
          if (!isNaN(resp)){
            highest=parseInt(resp,10);
          }

          console.log("hg"+highest);
        }



        if (wwidth<resp){
          var classList =thethis.attr('class').split(' ');
          for (var i = 0; i < classList.length; i++) {
            // Check if the class name starts with "col" and is followed by a number
            if (classList[i].match(/^col\d+$/)) {
              // Store the class name
              var className = classList[i];
              if (typeof thethis.attr("data-noresp") === 'undefined' || thethis.attr("data-noresp") === false) {
                thethis.attr("data-noresp",className);
              }
              // Remove the class from the element
              thethis.removeClass(className);
            }
          }

          prependClass(thethis,value);
        }

        if (wwidth>highest){
          thethis.addClass(thethis.attr("data-noresp"));
        }

      }
    });




  });


}
function loadingSpinner(thethis=0){
  if (thethis==0){
		var thethis=$("body");
	}
  if (thethis.hasClass("domloaded")){
	   thethis.addClass("loadingajax");
  }
	thethis.addClass("loadingajax");
	thethis.append("<div class='loader'><div class='loaderinner'><div class='lds-ripple'><div></div><div></div></div></div></div>");
}
function loadingSpinnerDone(thethis=0){
  if (thethis==0){
		var thethis=$("body");
	}
	thethis.removeClass("loadingajax");
	thethis.removeClass("loadingajaxfixed");
	thethis.find(".loader").remove();
}
function isEmail(email){
	return String(email)
    .toLowerCase()
    .match(
      /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
    );
}
function sectionfull100(){
	$('.jqsectionfull100').each(function(){
		$(".cmeasure",this).removeAttr("style");
		$(this).removeAttr("style");
		$(this).append("<div class='cmeasure'></div>");
		$(".cmeasure",this).css({
			position:"absolute",
			top:"0px",
			left:"0px",
			height:"100%",
			width:"100%"
		});
		var thisheightnopad=$(this).height();
		var thisheight=$(".cmeasure", this).height();
		var pads=thisheight-thisheightnopad;
		$(".cmeasure", this).remove();
		var wheight=$(window).height();

		var heightnopad=wheight-pads;

		if (wheight>thisheight){
			$(this).height(heightnopad);
		}

		console.log(thisheight);
	});
}
function checkCheck(){
	$('.icheckbox').each(function(){
		var status=$("input", this).is(":checked");
		if (status){
			$(this).addClass("selected");
		}else{
			$(this).removeClass("selected");
		}
	});
}

function dropDownRes(){
  $(".cselectdropdown").each(function(){
    var topval=$(".jqopendropdown").height();
    $(".cselectdropdownvalues").css({
      top:topval+"px"
    });
  });
}
function dropDownInit(){

		setTimeout(function(){
			$('.cselectdropdown').each(function(){
				var select=$("input", this).val();
				console.log(select);
				if (select!=""){
					$(".jqdropdownvalue[data-value='"+select+"']", this).click();
				}

			});



		}, 1);

}
function choiceInit(){

		setTimeout(function(){
			$('.cinputchoice').each(function(){
				var select=$("input", this).val();

				var selecttoarray = select.split(",");
			for (i = 0; i < selecttoarray.length; i++) {
				if (selecttoarray[i]!=""){
				console.log(selecttoarray[i]);
					$(".schoice[data-value='"+selecttoarray[i]+"']", this).click();
				}
			}


			});



		}, 1);

}

function commaDuped(list, value, separator){
	var currentvalue=list;
	var newvalue=list+","+value;
	var removedupes=Array.from(new Set(newvalue.split(separator))).toString();
	return removedupes.replace(/^,/, '');
}
function removeValue(list, value, separator) {
  separator = separator || ",";
  var values = list.split(separator);
  for(var i = 0 ; i < values.length ; i++) {
    if(values[i] == value) {
      values.splice(i, 1);
      return values.join(separator);
    }
  }
  return list;
}


function pageScrolled(){
	if ($(document).scrollTop() > 140) {
		$('body').addClass("scrolled");
	} else {
		$('body').removeClass("scrolled");
	}


  var element = $('.csection-avisos,.csection-noticies,footer');
  var elementTop = element.offset().top;
  var elementBottom = elementTop + element.outerHeight();
  var viewportTop = $(window).scrollTop();
  var viewportBottom = viewportTop + $(window).height();

  // Verifica si el elemento está en el viewport
  if (elementBottom+100 < viewportBottom) {
      $("body").addClass("scrolledtoend");
  }else{
    $("body").removeClass("scrolledtoend");
  }

}
function eqHeight(){

$(".ceqheight").each(function(i){
	$(this).addClass("ceqheight" + (i + 1));
});

var mapped = {};
var height=[];

$('.ceqheight').each(function(i){
	var height=$('.ceqheightinner').height();
	$('.ceqheight').height(height);
	var offset=Math.floor($(this).offset().top);
	$(this).attr("data-offset",offset);

});

$('.ceqheight[data-offset]').each(function(i, el){

	$(this).height($(".ceqheightinner", this).height());
	$(".ceqheightinner", this).removeAttr("style");
	category = $(el).attr('data-offset');

	if ($(".ceqheight"+(i)).attr('data-offset')!=category){
		height=[$(".ceqheightinner", this).height()];
	}else{
		height.push($(".ceqheightinner", this).height());
	}
	mapped[category]=height;

});


for(var key in mapped){
		var maxheight=Math.max(...mapped[key]);
		$('.ceqheight[data-offset='+key+'] .ceqheightinner').height(maxheight);
}

}
function grideq(){


	$(".rowmargined").each(function (i) {
		$(this).removeAttr("style");
		var rowmarginedw = $(this).width();
		var gridmargin = Math.abs(parseInt($(this).css("margin-left"),10));
		var calculo = rowmarginedw +gridmargin;
		$(this).width(calculo);
	});

}
function alertModal(msg){
		$(".cpopupalert .cpopuptext").text(msg);
		$(".cpopupalert").fadeIn(300, function(){
			$(".cpopupalert").addClass("showpopup");

		});
}
function jqswa(){
	var delay=0;

$(".jqswa").each(function (i) {
	$(this).addClass("scrollingway");
	$(this).attr("data-jqswan",i);
	$(this).addClass("jqswan"+i);

	var datadelay=parseFloat($(this).attr("data-jqswa-delay"));

	if (!datadelay) {
	}else{
		$(".jqswaitem", this).attr("data-jqswa-delay",datadelay);
	}

});
var eachindex=0;

var closest=[];
$(".jqswa .jqswaitem").each(function (i) {
	closest.push($(this).closest( ".jqswa" ).attr("data-jqswan"));

	if (closest.length>0){
		if(closest[i-1]!=closest[i]){
			eachindex=0;
		}
	}
	eachindex++;
	if (eachindex>0){
			var delay=(eachindex-1)/10;
	}
	var datadelay=parseFloat($(this).attr("data-jqswa-delay"));

	if (!datadelay) {
		datadelay=0.2;
	}

	$(this).css("transition-delay",(delay+datadelay)+"s");
});
}
function scrollingWay() {

        var wHeight = $(window).height();
        var topDist = $(document).scrollTop();
        var topDist2 = Math.round(topDist);
        var nscrollingways = $('.scrollingway').length;

        $(".scrollingway").each(function (i) {
            $(this).addClass("scrollingway" + (i + 1));
			$(".cdiapo",this).each(function (a) {
				$(this).addClass("cdiapo" + (a + 1));
			});
        });


        for (i = 1; i < nscrollingways + 1; i++) {
            var elementTop = $(".scrollingway" + i).offset().top;
            var elementTopHeight = $(".scrollingway" + i).height();
            if (topDist2 > elementTop - (wHeight / 1.28) && topDist2 < elementTop + (elementTopHeight / 1.2)) {
                $(".scrollingway" + i).addClass("scrollingwayready");
                $(".scrollingway" + i).addClass("scrollingwayfinish");


                setTimeout(function () {

                    setTimeout(function () {
                        $(".scrollingway1").addClass("scrollingwaydone");

                    }, 50);
                }, 600);

            } else {
                $(".scrollingway" + i).removeClass("scrollingwayready");

            }

        }



    }

    var flag = true;
$(document).ready(function() {
	grideq();
	jqswa();
  responsive();
	eqHeight();
	pageScrolled();
	sectionfull100();
  dropDownRes();

  sizeCards();
  divideMenu();

  $(".sub-menu a").addClass("cta");
  $(".sub-menu a").addClass("ctagray");

  if ($(".cmenuwrap .current-menu-item").length==0){
    $("body").addClass("lmenunotselected");
	}

  $(".cmenuresponsive ul li a").each(function() {
    if ($(this).closest("li").find("ul").length>0){
      $(this).addClass("lmenushow");
    }
  });

  $(".cburger").click(function(e) {
    e.preventDefault();

    $(".lmenushow").not(this).removeClass("lmenushowactive");
    $(".cmenuresponsive ul ul").not(this).slideUp(300);

    if ($(this).hasClass("lmenushowactive")){
      $(".cmenuresponsive ul ul").slideUp(300);
      $(".lmenushow").removeClass("lmenushowactive");

		}else{
      $(this).addClass("lmenushowactive");
      $(this).closest("li").find("ul").slideDown(300);
    }

  });

  $(".cmenuresponsive ul li.current-menu-ancestor ul").slideDown(0);
  $(".cmenuresponsive ul li.current-menu-ancestor > a").addClass("lmenushowactive");




  $('.cta').each(function() {
         var href = $(this).attr('href');
         if (href) {
             var isExternal = !href.includes(window.location.hostname);
             var isDocument = href.match(/\.(pdf|doc|docx|jpg|jpeg|png)$/i);

             if (isExternal) {
                 $(this).addClass('ctaexternal');
                 $(this).attr('target',"_blank");
             }

             if (isDocument) {
                 $(this).addClass('ctadocument');
                 $(this).attr('target',"_blank");
             }
         }
     });

  $("a").click(function(){
    var href = $(this).attr("href");
    if ($(this).attr("target")!="_blank"){
   // Get the current URL
   var currentUrl = window.location.href;
   // Check if the href contains the current domain
   if(href.indexOf(window.location.origin) === 0) {
       // Add loading class to the body
       if (!$(this).hasClass("lmenushow")){
       $("body").addClass("loadingpageout");
       }
   }
   }
  });

  var OSName="Unknown OS";
  if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";



  /*
  $('.ccovervideo').each(function(){
    $("video",this).coverVid(625, 900);
  });
*/
$(".jqmenuopennav").click(function() {
  if ($("body").hasClass("showmenuresponsive")){
    $("body").removeClass("showmenuresponsive");
    $(".cmenuresponsive").slideUp(300);
  }else{
    $("body").addClass("showmenuresponsive");
    $(".cmenuresponsive").slideDown(300);
  }


});

if ($(".sub-menu").is(":visible")) {
  $(".csectionbannerdefault").addClass("cbannersubmenued");
}



$(".jqplayvideocover").click(function() {
  $(this).closest(".cvideocover").fadeOut();
  $(this).closest(".csectionbgvideo").find("video")[0].play();
});

	$(".cacordion ul > li").click(function() {
		$("li",this).slideToggle(300);
		$(this).toggleClass("liacordionshow");
	});

  var OSName="Unknown OS";
  if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";

  if (OSName=="Windows"){
    $("body").niceScroll({
      scrollspeed:80,mousescrollstep: 30,styler:"fb", cursorcolor:"#000",cursoropacitymin:"0",cursorborder:"0px",horizrailenabled:false});
  }

  setInterval(function(){
    if ($(window).width()<1000){
      $("body").getNiceScroll().remove();
      eqHeight();
    }else{
      if (OSName=="Windows"){
        $("body").niceScroll({
          scrollspeed:80,mousescrollstep: 30,styler:"fb", cursorcolor:"#000",cursoropacitymin:"0",cursorborder:"0px",horizrailenabled:false});
      }
    }
  }, 500);
	$("body").addClass("domloaded");

  $(".citemnewhorz").hover(function() {
    console.log("test");
    $(".lalllink", this).stop(true,true).delay(1200).fadeIn( 0, function() {
  });

  }, function() {
    $(".lalllink", this).fadeOut(0);
  });

  $



  $( ".ch-cursor" ).hover(function() {
    var states=$(this).attr("data-cursor");
    $("body").addClass(states);
    if (states=="ch-info"){
      var text=$(this).attr("data-cursor-info");
      $(".e-cursortext").text(text);
    }
  }, function() {
    var states=$(this).attr("data-cursor");
    $("body").removeClass(states);
    $(".e-cursortext").text("");
  });

  $(".jqaccordion").click(function() {
    if (!$(this).closest(".rowaccordion").hasClass("rowaccordionactive") && !$(this).closest(".rowaccordion").hasClass("rowaccordionactivefirst")){
      $(this).closest(".rowaccordion").addClass("rowaccordionactive");
      $(this).closest(".rowaccordion").find(".e-accordion").slideDown(300);
      var thethis=$(this);
      setTimeout(function(){
      $("body").getNiceScroll().resize();
      thethis.closest(".rowaccordion").removeClass("rowaccordionactivefirst");

      }, 310);
		}else{
      $(this).closest(".rowaccordion").removeClass("rowaccordionactive");
      $(this).closest(".rowaccordion").find(".e-accordion").slideUp(300);
      var thethis=$(this);
      setTimeout(function(){
      $("body").getNiceScroll().resize();
      thethis.closest(".rowaccordion").removeClass("rowaccordionactivefirst");
      }, 310);
    }


  });


  $( "a,.slink,.cta,.caccordiontitle" ).hover(function() {
    if (!$(this).hasClass("ctanaked")){
    var states="ch-defaulthover";
    $("body").addClass(states);
    }
  }, function() {
    if (!$(this).hasClass("ctanaked")){
    var states="ch-defaulthover";
    $("body").removeClass(states);
    }
  });

  $('.jqnumbers').each(function(){
    var number=parseInt($(this).text(),10);
    $(this).text("");
    $(this).attr("data-number",number);
  });


	$(".icheckbox").click(function() {
		checkCheck();
	});
	checkCheck();
	dropDownInit();
	choiceInit();




	/*DATEPICKER
	var picker = new Lightpick({
		field: document.getElementById('datepicker1'),
		onClose:function() {
			console.log("datepicker1");


			var val=$("#datepicker1").val();
			console.log(val);
		  $("#datepicker1").closest(".jqdatepicker").find(".uploadname").text(val);
			if ($(this).closest(".jqdatepicker").find(".uploadname").text()==""){
				$(this).closest(".jqdatepicker").find(".uploadname").text($(this).closest(".jqdatepicker").find(".uploadname").attr("data-placeholder"))
			}


		}
	});

	*/

  $('.jqslick').slick({
		 infinite: true,
		 speed: 900,
     pauseOnHover:false,
 		swipeToSlide:true,
 		prevArrow: false,
 		nextArrow: false,
		 slidesToShow: 1,
		 fade: true,
			cssEase: 'ease-in-out',
			autoplay: true,
	autoplaySpeed: 1800
	});

/*FIXER
  $('.your-selector').slick({
    // configuration
}).on('beforeChange', (event, slick, currentSlide, nextSlide) => {
    if (currentSlide !== nextSlide) {
        document.querySelectorAll('.slick-center + .slick-cloned').forEach((next) => {
            // timeout required or Slick will overwrite the classes
            setTimeout(() => next.classList.add('slick-current', 'slick-center'));
        });
    }
});*/

$(".jqpopupshowimage").click(function() {
  var show=$(this).attr("data-imagepopup");
  var video=$(this).attr("data-imagepopuptype");
  if (video=="video"){
    $(".cpopupimage .cpopupinner").html('<video controls autoplay ><source src="' + show + '"type="video/mp4"></video>');
  }else{
  $(".cpopupimage .cpopupinner").html("<img src='"+show+"' />");
  }
});

  $(".jqslicknext").click(function() {
  $(this).parent().find(".slick-slider").slick('slickNext');
  });



  $(".jqslickprev").click(function() {
    $(this).parent().find(".slick-slider").slick('slickPrev');
  });


	/*SLICK
	$('.jqslickmenu').slick({
		 infinite: true,
		 speed: 900,
		 slidesToShow: 1,
		 fade: true,
			cssEase: 'ease-in-out',
			autoplay: true,
	autoplaySpeed: 3000,
	responsive: [

		{
			breakpoint: 800,
			settings: {
				slidesToShow: 1
			},



		},

	]
	});
	*/

	$(".cselectdropdownvalues").wrapInner("<div class='cdropsc'></div>");

	$(".jqdropdownvalue").click(function() {
		if (!$(this).hasClass("disabledrop")){
		var value=$(this).attr("data-value");
		var name=$(this).text();
		var theinput=$(this).closest(".cselectdropdown").find("input");

		if ($(this).closest(".cselectdropdown").attr("data-target")!== undefined){
			theinput=$("."+$(this).closest(".cselectdropdown").attr("data-target"));
		}
		console.log(theinput);
		var thesinput=$(this).closest(".cselectdropdown").find(".sinput");
		var placeholder=thesinput.attr("data-placeholder");


			if ($(this).closest(".cselectdropdown").attr("data-multiselect")==1){
				if ($(this).hasClass("selectedvalue")){
					$(this).removeClass("selectedvalue");
						theinput.val(removeValue(theinput.val(),value,","));
						thesinput.text(removeValue(thesinput.text(),name,","));
					if (theinput.val()==""){
						console.log("none");
						thesinput.text(placeholder);
					}
				}else{

				$(this).addClass("selectedvalue");
				var tipovalues= commaDuped(theinput.val(),value,",");
				theinput.val(tipovalues.replace(/^,/, ''));
				var tiponames= commaDuped(thesinput.text(),name,",").replace(placeholder,'');
				thesinput.text(tiponames.replace(/^,/, ''));
				}
			}else{
				$(this).closest(".cselectdropdown").find(".jqdropdownvalue").removeClass("selectedvalue");
				$(this).addClass("selectedvalue");
				theinput.val(value);
				thesinput.text(name);
				$(this).closest(".cselectdropdown").find(".cselectdropdownvalues").delay(100).slideUp(100);
				$(this).closest(".cselectdropdown").removeClass("selectactive");
			}
		}
    theinput.trigger('change');
	});


	$(".jqalert").click(function() {
		var msg=$(this).attr("data-alert");
		alertModal(msg);
	});

  $( ".jqsuscribenews" ).click(function() {
    var form=$(this).closest("form");
    var gracias =$(this).closest("form").attr("data-formok");
    var validateall =$(this).closest("form").attr("data-validate-all");
    var validateemail =$(this).closest("form").attr("data-validate-email");
    var thethis=$(this);

    var title=$(this).closest(".cpopup").find(".shpre").text();

    if (title==""){
      title="Contacto Web";
    }
    var cta=$(this).closest("form").find(".icta").val();
    if(cta==""){
      cta="default";
    }

    var text = {
      email:$(this).closest("form").find(".iemail").val(),
    }
    console.log(text);
    if (text.email!=""){
      var formData = new FormData($(this).closest("form")[0]);

      if(isEmail(text.email)){
        $("body").addClass("jqloadingajax");
        $.ajax({
        type: "POST",
        url: urlajax+"/ajax/cc-suscribe.php",
        data: formData,
         dataType: 'text',
         contentType: false,
         processData: false,
        success: function(data){
           console.log(data);
          if (data==1){
            form.after("<div class='cformgraciasnewsletter'>"+gracias+"</div>");
            form.slideUp(200);
            $("body").removeClass("jqloadingajax");

          }
        }

        });
      }else{
        alertModal(validateemail);
      }
      }else{
        alertModal(validateall);
      }


  });

  $( ".jqsendformcontact" ).click(function() {
		var form=$(this).closest("form");
		var acepto="";
		var aceptonews="";
		var gracias =$(this).closest("form").attr("data-formok");
		var validateall =$(this).closest("form").attr("data-validate-all");
		var validateemail =$(this).closest("form").attr("data-validate-email");
    var thethis=$(this);

		if ($(this).closest("form").find(".iprivacidad").is(":checked")){acepto=1;}
		if ($(this).closest("form").find(".icomercial").is(":checked")){aceptonews=1;}

    var title=$(this).closest(".cpopup").find(".shpre").text();

    if (title==""){
      title="Contacto Web";
    }
    var cta=$(this).closest("form").find(".icta").val();
    if(cta==""){
      cta="default";
    }

    var dni=$(this).closest("form").find(".idni").val();
    var nacionalitat=$(this).closest("form").find(".inacionalitat").val();
    var carrer=$(this).closest("form").find(".icarrer").val();
    var localitat=$(this).closest("form").find(".ilocalitat").val();
    var datanaixement=$(this).closest("form").find(".idatanaixement").val();
    var cursos_anteriors = [];
    $(this).closest("form").find("input[name='cursos_anteriors[]']:checked").each(function() {
        cursos_anteriors.push($(this).val());
    }); coneixements_previs=$(this).closest("form").find(".iconeixements_previs").val();

		var text = {
			nombre:$(this).closest("form").find(".inombre").val(),
      dni:dni,
      nacionalitat:nacionalitat,
      carrer:carrer,
      localitat:localitat,
      coneixements_previs:coneixements_previs,
      cursos_anteriors:cursos_anteriors,
			empresa:$(this).closest("form").find(".iempresa").val(),
			telefono:$(this).closest("form").find(".itelefono").val(),
      datanaixement:datanaixement,
			email:$(this).closest("form").find(".iemail").val(),
			mensaje:$(this).closest("form").find(".imensaje").val(),
      urlfrom:window.location.href,
      cta:cta,
      title:title,
			acepto:acepto,
			aceptonews:aceptonews
		}

    var errors=0;

    if ($(this).closest("form").find(".idni").length != 0) {
    if (text.dni == "" || text.nacionalitat == "" && text.carrer == "" || text.localitat == "" || text.coneixements_previs == "" || text.cursos_anteriors == "" || text.datanaixement == "") {
        errors = 1;
    }
}



		console.log(text);
		if (text.nombre!="" && text.email!="" && text.telefono!="" && text.acepto==1 && errors==0){

      var formData = new FormData($(this).closest("form")[0]);
      if ($(this).closest("form").find("#idcv").length>0){
        formData.append('cv', $(this).closest("form").find("#idcv")[0].files[0]);
      }


			if(isEmail(text.email)){
        $("body").addClass("jqloadingajax");
        $.ajax({
 				type: "POST",
 				url: urlajax+"/ajax/cc-lead.php",
 				data: formData,
         dataType: 'text',
    	 	 contentType: false,
    	 	 processData: false,
 				success: function(data){
           console.log(data);
 					if (data==1){
 						form.after("<div class='cformgracias'>"+gracias+"</div>");
 						form.slideUp(200);
            $("body").removeClass("jqloadingajax");

 					}
 				}

 				});
			}else{
				alertModal(validateemail);
			}
			}else{
				alertModal(validateall);
			}


	});

});
$( window ).resize(function() {
	grideq();
	eqHeight();
	sectionfull100();
  responsive();
  dropDownRes();
  sizeCards();
});
window.onload = function(){
	$(function() {
		$(scrollingWay);
		grideq();
		eqHeight();
		sectionfull100();
		$("body").addClass("windowloaded");
    dropDownRes();
	});
}
$(window).scroll(function () {
$(scrollingWay);
pageScrolled();
$('.scrollingwayfinish .jqnumbers').not(".jqnumbersdone").each(function(){
	$(this).addClass("jqnumbersdone");
	var number=parseInt($(this).attr("data-number"),10);
	$(this).numberAnimate();
	$(this).numberAnimate('set', number);
});

});

$(document).on('click', '.jqcerrarpopup,.cbotonalert,.cpopupwrap', function(){
	var thethis=$(this);
	thethis.closest(".cpopupwrap").removeClass("showpopup");
	thethis.closest(".cpopupwrap").fadeOut(300, function(){
  thethis.closest(".cpopupwrap").find(".icta").val("");
  thethis.closest(".cpopupwrap").find(".e-popuptitle").text(thethis.closest(".cpopupwrap").find(".e-popuptitle").attr("data-currval"));
  thethis.closest(".cpopupwrap").find(".e-popuptitle").removeAttr("data-currval");
	});
});
$(document).on('click', '.cpopup', function(event){
	event.stopPropagation();
});

$(document).on('click', '.jqgoto', function(){
	console.log("test");
	var goto=$(this).attr("data-goto");
	var correccion=0;
	if ($(".cheader .jqsubmenusticky").length>0){
	correccion=$(".cheader").height()+$(".cheader .jqsubmenusticky").height()+parseInt($(".cheader .jqsubmenusticky").css("padding-top"),10)+parseInt($(".cheader .jqsubmenusticky").css("padding-bottom"),10);
	}


	$("html").animate({
			scrollTop: $("#"+goto).offset().top-correccion
	}, 1000);
});


$(document).on('click', '.jqopendropdown', function(){

		if ($(this).parent().hasClass("selectactive")){
			$(this).parent().removeClass("selectactive");
			$(this).parent().find(".cselectdropdownvalues").delay(100).slideUp(100);

			$(".svgclosedrop").remove();
			setTimeout(function(){
			$(".cselectdropdownvalues .cdropsc").mCustomScrollbar('destroy');

			}, 210);


		}else{
		$(this).parent().addClass("selectactive");
		$(this).parent().find(".cselectdropdownvalues").slideDown(100);
		$(".cselectdropdownvalues .cdropsc").mCustomScrollbar();


		}

});
$(document).on('click', '.jqacepto', function(){
	if ($(this).hasClass("selectedvalue")){
		$(this).removeClass("selectedvalue");
		$("input",this).prop('checked', false);
	}else{
		$(this).addClass("selectedvalue");
		$("input",this).prop('checked', true);
	}
});

$(document).on('click', '.jqacepto', function(){
	if ($(this).hasClass("selectedvalue")){
		$(this).removeClass("selectedvalue");
		$("input",this).prop('checked', false);
	}else{
		$(this).addClass("selectedvalue");
		$("input",this).prop('checked', true);
	}
});
$(document).on('click', '.jqpopupshow', function(){
  var show=$(this).attr("data-popup");

  var popuptitle=$(this).attr("data-popuptitle");
  if (popuptitle!=""){
    var currentvalue=$(show).find(".e-popuptitle").text();
    $(show).find(".e-popuptitle").attr("data-currval",currentvalue);
    $(show).find(".e-popuptitle").text(popuptitle);
  }

  var thetitle=$(this).attr("data-leadtitle");
  if (thetitle!=""){
    $(show).find(".icta").val(thetitle);
  }
  $(show).addClass("showpopup").fadeIn(300);
  grideq();
});

$(document).on('click', '.jqpopupshowmonografics', function(){
  $("html").animate({
			scrollTop: 0
	}, 1000);
});


document.addEventListener('DOMContentLoaded', (event) => {
    const cursorDiv = document.querySelector('.ccursorretro');

    document.addEventListener('mousemove', (e) => {
        cursorDiv.style.left = `${e.clientX}px`;
        cursorDiv.style.top = `${e.clientY}px`;
    });
});

$(window).on('scroll', function() {

});
