var generalFunctions = new Object; generalFunctions.mainFunctions = { images: "", branchId: "", currentImage: 0, totalImages: 1, interval: "", fieldTracker: "", dashDatatable: "", removeSearchText: function(eID) { if(document.getElementById(eID).style.color == "gray") { document.getElementById(eID).value = ""; document.getElementById(eID).style.color = "black"; } }, sendError: function(msg, elementId) { alert(elementId+": "+msg); document.getElementById(elementId).focus(); }, isValidEmailAddress: function(emailAddress) { AtPos = email.indexOf("@") StopPos = email.lastIndexOf(".") if (AtPos == -1 || StopPos == -1) { return false; } return true; }, cycleImages: function(images, branchId, fieldTracker) { generalFunctions.mainFunctions.clearCycleImages(); var timeDelay = 2; timeDelay *= 500; generalFunctions.mainFunctions.branchId = branchId; generalFunctions.mainFunctions.fieldTracker = fieldTracker; generalFunctions.mainFunctions.images = images; generalFunctions.mainFunctions.totalImages = images.length; generalFunctions.mainFunctions.interval = setInterval("generalFunctions.mainFunctions.slideshow()", timeDelay); }, slideshow: function() { generalFunctions.mainFunctions.currentImage++; if(generalFunctions.mainFunctions.currentImage == generalFunctions.mainFunctions.totalImages) { generalFunctions.mainFunctions.currentImage = 0; } var imageSrc = "show_image.php?i="+generalFunctions.mainFunctions.images[generalFunctions.mainFunctions.currentImage]+"&p="+generalFunctions.mainFunctions.branchId+"&w=70&h=70&hidebg=0" document.getElementById("thumbnail"+generalFunctions.mainFunctions.fieldTracker+"_"+generalFunctions.mainFunctions.branchId).src = imageSrc; }, clearCycleImages: function() { clearInterval(generalFunctions.mainFunctions.interval); }, resetCycleImages: function() { generalFunctions.mainFunctions.clearCycleImages(); var imageSrc = "show_image.php?i="+generalFunctions.mainFunctions.images[0]+"&p="+generalFunctions.mainFunctions.branchId+"&w=70&h=70&hidebg=0" document.getElementById("thumbnail"+generalFunctions.mainFunctions.fieldTracker+"_"+generalFunctions.mainFunctions.branchId).src = imageSrc; }, callAjaxAction: function(action, postDataObj, successCallBack) { successCallBack(); var sUrl = "ajax/ajaxProxy.php?ajaxAction="+action; var postData = ""; for(i in postDataObj) { postData += "&"+i+"="+escape(postDataObj[i]) } var callback = { success: function(o) { // expecting json respone try { resultObj = YAHOO.lang.JSON.parse(o.responseText); } catch (x) { alert("JSON Parse failed, please try again later."); return; } // failure on action if(resultObj.error == true) { alert(resultObj.data); return; } // success action successCallBack(resultObj.data); return; }, failure: function(o) { alert("There was a problem with your request, please try again later."); //FAILURE } } var transaction = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData); }, updateBranchStatus: function(branchId, status) { var postDataObj = new Object(); postDataObj.branchId = branchId; postDataObj.newStatus = status; generalFunctions.mainFunctions.callAjaxAction("updateBranchStatus", postDataObj, generalFunctions.mainFunctions.updateBranchStatus_success); }, updateBranchStatus_success: function(result) { if(result != undefined) { alert(result); } // refresh datatable generalFunctions.mainFunctions.dashDatatable.getDataSource().sendRequest('', { success: generalFunctions.mainFunctions.dashDatatable.onDataReturnInitializeTable, scope: generalFunctions.mainFunctions.dashDatatable }); }, removeFavourite: function(branchId) { var postDataObj = new Object(); postDataObj.branchId = branchId; generalFunctions.mainFunctions.callAjaxAction("removeFavourite", postDataObj, generalFunctions.mainFunctions.removeFavourite_success); }, removeFavourite_success: function(result) { if(result != undefined) { alert(result); } // refresh datatable generalFunctions.mainFunctions.dashDatatable.getDataSource().sendRequest('', { success: generalFunctions.mainFunctions.dashDatatable.onDataReturnInitializeTable, scope: generalFunctions.mainFunctions.dashDatatable }); } }