var ajax_url = "includes/"; function sendAjax(url, callbackFunction) { if (window.XMLHttpRequest) { var request = new XMLHttpRequest(); } else { var request = new ActiveXObject("Microsoft.XMLHTTP"); } request.open("POST", url, true); request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); request.onreadystatechange = function() { if (request.readyState == 4 && request.status == 200) { if (request.responseText) { callbackFunction(request.responseText); }else{ } } } request.send(null); } function saveOverallRating(g, r, t, c){ //alert("xx"); //alert("y"); //alert(g); //alert(r); //alert(t); //alert(ajax_url + 'ajax-save-rating.php?ground=' + g + '&rating=' + r + '&type=' + t); sendAjax(ajax_url + 'ajax-save-rating.php?ground=' + g + '&rating=' + r + '&type=' + t + '&class=' + c, updateRating); //alert("z"); } function updateRating(results){ //alert("updateRating"); //alert(results); if(results=="login"){ //USER ISN'T LOGGED-IN //alert('login'); document.getElementById('ratingloginprompt').style.display = "block"; //$( "#loginp" ).dialog(); }else{ //alert('split'); var parts = results.split("-"); //alert(parts[0]) //alert(parts[1]) //document.getElementById('ratingsaved'+parts[0]).style.display = "block"; document.getElementById(parts[0]).className = parts[1]; //alert('rating'+parts[0]); //alert(parts[1]); } } function checkUsername(){ var username = document.getElementById('username').value; sendAjax(ajax_url + 'ajax-check-username.php?username=' + username, updateUsername); } function updateUsername(results){ document.getElementById('usernamecheck').innerHTML = results; } function addGroundFootball(g){ document.getElementById('groundadded').style.display = "none"; document.getElementById('updatingground').style.display = "block"; sendAjax(ajax_url + 'ajax-add-ground-football.php?ground=' + g, updateGroundFootball); } function updateGroundFootball(results){ document.getElementById('updatingground').style.display = "none"; if(results=="login"){ //USER ISN'T LOGGED-IN document.getElementById('loginprompt').style.display = "block"; }else{ //EVERYTHING OKAY - UPDATE IMAGE document.getElementById('groundaddedfootball').src = results; document.getElementById('groundadded').style.display = "block"; } } function addGroundOther(g){ document.getElementById('groundadded').style.display = "none"; document.getElementById('updatingground').style.display = "block"; sendAjax(ajax_url + 'ajax-add-ground-other.php?ground=' + g, updateGroundOther); } function updateGroundOther(results){ document.getElementById('updatingground').style.display = "none"; if(results=="login"){ //USER ISN'T LOGGED-IN document.getElementById('loginprompt').style.display = "block"; }else{ //EVERYTHING OKAY - UPDATE IMAGE document.getElementById('groundaddedother').src = results; document.getElementById('groundadded').style.display = "block"; } } function addGroundWish(g){ document.getElementById('groundadded').style.display = "none"; document.getElementById('updatingground').style.display = "block"; sendAjax(ajax_url + 'ajax-add-ground-wish.php?ground=' + g, updateGroundWish); } function updateGroundWish(results){ document.getElementById('updatingground').style.display = "none"; if(results=="login"){ //USER ISN'T LOGGED-IN document.getElementById('loginprompt').style.display = "block"; }else{ //EVERYTHING OKAY - UPDATE IMAGE document.getElementById('groundaddedwish').src = results; document.getElementById('groundadded').style.display = "block"; } } /*function addGroundWish(g){ document.getElementById('groundadded').style.display = "none"; document.getElementById('updatingground').style.display = "block"; sendAjax(ajax_url + 'ajax-add-ground-wish.php?ground=' + g, updateGroundWish); } function updateGroundWish(results){ document.getElementById('updatingground').style.display = "none"; if(results=="login"){ //USER ISN'T LOGGED-IN document.getElementById('loginprompt').style.display = "block"; }else{ //EVERYTHING OKAY - UPDATE IMAGE document.getElementById('groundwishlist').innerHTML = results; document.getElementById('groundadded').style.display = "block"; } }*/ function showFact(){ if(document.getElementById('addfact').style.display=="none"){ document.getElementById('addfact').style.display = "block"; document.getElementById('fact').focus(); }else{ document.getElementById('addfact').style.display = "none"; } } function saveFact(){ var type = document.getElementById('facttype').value; var id = document.getElementById('factid').value; var fact = document.getElementById('fact').value; sendAjax(ajax_url + 'ajax-save-fact.php?id=' + id + "&type=" + type + "&fact=" + fact, updateFact); sendAjax(ajax_url + 'ajax-get-facts.php?id=' + id + "&type=" + type, getFacts); } function updateFact(results){ document.getElementById('addfact').innerHTML = results; } function getFacts(results){ document.getElementById('facts').innerHTML = results; } function showLink(){ if(document.getElementById('addlink').style.display=="none"){ document.getElementById('addlink').style.display = "block"; document.getElementById('url').focus(); }else{ document.getElementById('addlink').style.display = "none"; } } function saveLink(){ var type = document.getElementById('linktype').value; var id = document.getElementById('linkid').value; var url = document.getElementById('url').value; var title = document.getElementById('title').value; var desc = document.getElementById('desc').value; sendAjax(ajax_url + 'ajax-save-link.php?id=' + id + "&type=" + type + "&url=" + url + "&title=" + title + "&desc=" + desc, updateLink); sendAjax(ajax_url + 'ajax-get-links.php?id=' + id + "&type=" + type, getLinks); } function updateLink(results){ document.getElementById('addlink').innerHTML = results; } function getLinks(results){ document.getElementById('links').innerHTML = results; } function showReport(){ if(document.getElementById('reportreason').style.display=="none"){ document.getElementById('reportreason').style.display = "block"; }else{ document.getElementById('reportreason').style.display = "none"; } } function saveReport(){ var url = document.getElementById('pageurl').value; var reason = document.getElementById('reason').value; sendAjax(ajax_url + 'ajax-report-page.php?url=' + url + "&reason=" + reason, updateReport); } function updateReport(results){ document.getElementById('reportreason').innerHTML = results; } function saveRating(name, r){ var newclass = "rating nostar"; switch(r){ case 0.5: newclass = "rating halfstar"; break; case 1: newclass = "rating onestar"; break; case 1.5: newclass = "rating onehalfstar"; break; case 2: newclass = "rating twostar"; break; case 2.5: newclass = "rating twohalfstar"; break; case 3: newclass = "rating threestar"; break; case 3.5: newclass = "rating threehalfstar"; break; case 4: newclass = "rating fourstar"; break; case 4.5: newclass = "rating fourhalfstar"; break; case 5: newclass = "rating fivestar"; break; } document.getElementById(name + "rating").className = newclass; document.getElementById(name).value = r; } function followUser(u){ sendAjax(ajax_url + 'ajax-follow-user.php?user=' + u, updateFollowing); } function updateFollowing(results){ if(results=="login"){ //USER ISN'T LOGGED-IN document.getElementById('loginprompt').style.display = "block"; }else{ //EVERYTHING OKAY - UPDATE IMAGE document.getElementById('follow').innerHTML = results; } }