//Requires ajax.js function fav_toggle(target, id, pid) { // var loadingText = 'Please Wait'; // target.innerHTML = loadingText; var ajax_toggle_fav = function() { if (ajaxRequest.readyState==4) { try { if (ajaxRequest.status == 200) { if (ajaxRequest.responseText == "0") { //target.innerHTML = "Removing.."; //window.location.href = window.location.href; target.innerHTML = "Add"; clearFav(id, pid); } else if (ajaxRequest.responseText == "1") { //target.innerHTML = "Adding.."; //window.location.href = window.location.href; target.innerHTML = "Remove"; setFav(id, pid); } else if (ajaxRequest.responseText == "-1") { alert ("Your session has expired, please re-login"); } else { target.innerHTML = "Error"; alert ("Bad Response " + ajaxRequest.responseText); } ajaxRequest = null; } else { ajaxRequest = null; } } catch (e) { ajaxRequest = null; } } } args = new Array(); args["id"] = id; simpleAjaxQuery('/favourite_toggle.ajax', args, ajax_toggle_fav , true); } function setFav(id, pid) { changeImage("photoMain_" + id, getFavUrl(pid)); } function clearFav(id, pid) { changeImage("photoMain_" + id, getNonFavUrl(pid)); } function getFavUrl(id) { return "/image_jpeg/219/145/85/ao%7Bfav%7D/property/main/" + id + ".jpg"; } function getNonFavUrl(id) { return "/image_jpeg/219/145/85/a/property/main/" + id + ".jpg"; } function changeImage(id, src) { var img_element = document.getElementById(id); img_element.src = src; }