var link_to_php_folder = '//www.animalslebanon.org/php/'; var state = 1; var months = Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); var days = Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); function fillDays(obj) { buf = ''; for (i = 1; i < 32; i++) { buf += '' } $("[name='" + obj + "']").html(buf); } function fillMonths(obj) { buf = ''; for (i = 1; i < 13; i++) { buf += '' } $("[name='" + obj + "']").html(buf); } function fillYears(obj) { buf = ''; for (i = 2025; i > 1900; i--) { buf += '' } $("[name='" + obj + "']").html(buf); } function fillYearsDOB(obj) { buf = ''; for (i = 2006; i > 1900; i--) { buf += '' } $("[name='" + obj + "']").html(buf); } function fillYearsCC(obj) { buf = ''; for (i = 2015; i < 2036; i++) { buf += '' } $("[name='" + obj + "']").html(buf); } function fillCountry(obj) { $.getJSON({ type: "GET", url: link_to_php_folder + 'datasets.json.php?k=countries', success: function(data) { countries = data; buf = ''; lim = countries.length; console.log(lim); for (i = 0; i < lim; i++) { buf += '' } $("[name='" + obj + "']").html(buf); } }); } function sendIt(caller) { var url = link_to_php_folder + "forms.php"; if (!$('#marker').length) { //introduce marker if missing $('#' + caller).append('
'); $('#' + caller).append(''); } $.ajax({ type: "POST", url: url, data: $("#" + caller).serialize(), success: function(data) { var marker = $('#marker'); var marker2 = $('#marker2'); if (data != 'ok') { var arr = data.split('*'); var target = $("[name='" + arr[0] +"']"); //console.log("[name='" + arr[0] +"']"); if (arr[1] == state) { //same state //console.log('show'); //console.log(); target.focus(); //marker.css({top: (target.position().top +1) + 'px', left: (target.position().left + target.width() + 15) + 'px'}); //marker.show(); if (target.is(":visible") == true) { marker2.css({top: (target.position().top - 7) + 'px', left: ($('#' + caller).width() - marker2.width() + 13) + 'px'}); } else { target.show(); marker2.css({top: (target.position().top - 47) + 'px', left: ($('#' + caller).width() - marker2.width() + 13) + 'px'}); target.hide(); } marker2.show(); $('html, body').animate({ scrollTop: marker2.offset().top - 80 }, 0); } else { //console.log('hide'); //marker.hide(); marker2.hide(); nextStep(state + 1); } } else { marker.hide(); finishIt(); } } }); }