var $ = jQuery; $(document).ready(InitializeObjects); function InitializeObjects() { if($("#asd_competition").val() != null) { $(".secondary-menu").find("a").each( function(lol) { var patt = /idcomp/; if(!patt.test($(this).attr("href"))) $(this).attr("href",$(this).attr("href")+"?idcomp="+$("#asd_competition").val()); } ); } if($("#gol_button").length > 0) { $("#gol_button").click( function() { $(".tr_gol").each( function(lol) { $(this).css('display', '') } ); $("#gol_button").remove(); } ); } if($("#mv_button").length > 0) { $("#mv_button").click( function() { $(".tr_mv").each( function(lol) { $(this).css('display', '') } ); $("#mv_button").remove(); } ); } if($(".team").length > 0) { $(".team").each( function () { $(this).click(function() { var idc = $(this).attr("id").split("_")[1]; var idt = $(this).attr("id").split("_")[2]; request = $.ajax({ url: "http://www.asdcittavesuviana.com/asd/wp-content/themes/sportimo-theme/ASD/engine_teamStuff.php", type: "post", data: { idcomp : idc, idteam : idt, op : "pink" } }); request.done(function(html) { $("#table_p") .slideUp(function() { $(this).find("tbody").remove(); $("#table_p").append(html).slideDown(); } ); } ); request.error(function(data) { alert("Errore ajax"); } ); } ); } ); } if($(".gioc").length > 0) { $(".gioc").each( function () { $(this).click(function() { var idc = $(this).attr("id").split("_")[1]; var idt = $(this).attr("id").split("_")[2]; request = $.ajax({ url: "http://www.asdcittavesuviana.com/asd/wp-content/themes/sportimo-theme/ASD/engine_teamStuff.php", type: "post", data: { idcomp : idc, idteam : idt, op : "pink" } }); request.done(function(html) { $("#table_p") .slideUp(function() { $(this).find("tbody").remove(); $("#table_p").append(html).slideDown(); } ); } ); request.error(function(data) { alert("Errore ajax2"); } ); } ); } ); } if($("#container-struct").length > 0) { if (window.location.hash){ cercaStruttura(location.hash);} window.onpopstate = function(event) { if (window.location.hash){ cercaStruttura(location.hash);} }; $("#select-bob") .change( function() { location.hash = $("select option:selected").val(); cercaStruttura(location.hash); } ); } if($(".pop").length > 0) { $(".pop").click( function() { var obj = $(this).parent().find(".team"); var idc = $(obj).attr("id").split("_")[1]; var idt = $(obj).attr("id").split("_")[2]; request = $.ajax({ url: "http://www.asdcittavesuviana.com/asd/wp-content/themes/sportimo-theme/ASD/engine_teamStuff.php", type: "post", data: { idcomp : idc, idteam : idt, op : "gioc" } }); request.done(function(html) { MrBackground(html,"Partite giocate"); } ); request.error(function(data) { alert("Errore ajax"); } ); } ); } if($(".popGioc").length > 0) { $(".popGioc").click( function() { var obj = $(this).parent().find(".teamGioc"); var idc = $(obj).attr("id").split("_")[1]; var idt = $(obj).attr("id").split("_")[2]; request = $.ajax({ url: "http://www.asdcittavesuviana.com/asd/wp-content/themes/sportimo-theme/ASD/engine_teamStuff.php", type: "post", data: { idcomp : idc, idteam : idt, op : "gioc" } }); request.done(function(html) { MrBackground(html,"Partite giocate"); } ); request.error(function(data) { alert("Errore ajax"); } ); } ); } function cercaStruttura(obj){ $('#select-bob').val(obj.substr(1)); request = $.ajax({ url: "http://www.asdcittavesuviana.com/asd/wp-content/themes/sportimo-theme/ASD/engine_structures.php", type: "post", data: { ids : obj.substr(1), op : "get" } }); request.done(function(html) { $("#container-struct div").remove(); $("#default-image").remove(); $("#container-struct").append(html); var point = new google.maps.Geocoder(); var gr = point.geocode({address : $("#address-ficus").text()}, function(res,stat) { if(stat == google.maps.GeocoderStatus.OK) { var mapOptions = { zoom: 13, center: res[0].geometry.location, mapTypeId: google.maps.MapTypeId.ROADMAP } var map = new google.maps.Map(document.getElementById("other-struct"), mapOptions); var marker = new google.maps.Marker({ position: res[0].geometry.location, map: map }); } else { $("#other-struct").remove(); $("#map-title").remove(); } } ); } ); request.error(function(data) { alert("Errore ajax"); } ); } }