main.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. window.onload = function() {
  2. var availableWidth = [ 500, 1024, 1400, 1920];
  3. var size=0;
  4. var banner=document.getElementById("banner");
  5. while ($(window).width() > availableWidth[size] && size < availableWidth.length-1 )
  6. size++;
  7. banner.src="Images/slider/slide1-"+availableWidth[size]+".jpg";
  8. var contact= document.getElementsByClassName("contact");
  9. var tit_curso = document.getElementsByClassName("titulo_curso");
  10. var desc_curso = document.getElementsByClassName("descripcion_curso");
  11. function curso_click(){
  12. for(var j =0; j < desc_curso.length; j++){
  13. if (desc_curso[j].getAttribute("tatosa") == this.getAttribute("tatosa"))
  14. desc_curso[j].style.display="block";
  15. }
  16. }
  17. for(var i =0; i < tit_curso.length; i++)
  18. tit_curso[i].onclick=curso_click;
  19. for(var i =0; i < contact.length; i++)
  20. contact[i].onclick=showContact;
  21. function showContact() {
  22. $('.basic-grey, #overlay-contact').toggle();
  23. if($('.basic-grey').is(':visible')){
  24. $('#overlay-contact').click(function(){
  25. $('.basic-grey, #overlay-contact').hide();
  26. });
  27. $('#exit').click(function(){
  28. $('.basic-grey, #overlay-contact').hide();
  29. });
  30. }
  31. }
  32. $('li a').click(function () {
  33. $('html, body').animate({ scrollTop: $($(this).attr('href')).position().top }, 'slow');
  34. if ($(this).attr('href')=='#footer-outer') { showContact(); }
  35. return false;
  36. });
  37. // $('.menu').hide(); //TATII!!!
  38. $('#responsive-menu').click(function(){
  39. $('.menu').slideToggle(300);
  40. });
  41. var startY= $('#top_wrapper').position().top + $('#top_wrapper').outerHeight();
  42. $('#logo').css('opacity','0');
  43. $('#navlist').css('height','55px');
  44. $(window).scroll(function () {
  45. if($(this).scrollTop() > startY ){
  46. $('#logo').css({'opacity':'1', 'transition': 'opacity 0.5s ease-in-out'});
  47. }else{
  48. $('#logo').css({'opacity':'0', 'transition': 'opacity 0.5s ease-in-out'});
  49. }
  50. });
  51. $("#btnconsulta").click(function() {
  52. $.post('contacto.php',{nombre: $("#name").val(), mail:$("#email").val(),consulta:$("#message").val()}).done(function(data) {
  53. $("#respuestacontacto").html(data);
  54. });
  55. });
  56. $("#ok").click(function() {
  57. $.post('newsletter.php',{mail:$("#suscribe").val()}).done(function(data) {
  58. $("#respuestanewsletter").html(data);
  59. });
  60. });
  61. var curImg=1;
  62. setInterval(slide, 8000);
  63. function slide() {
  64. banner.className='transp';
  65. setTimeout(transp, 500);
  66. curImg++;
  67. if(curImg>5) curImg=1;
  68. }
  69. function transp() {
  70. banner.src="Images/slider/slide"+curImg+"-"+availableWidth[size]+".jpg";
  71. banner.removeAttribute('class');
  72. }
  73. }