callAjaxExecuting=false; callAjaxQ=new Array(); function addToCallAjaxQ(url, data, func){ var newEl={"strURL":url,"strPostData":data,"thefunction":func}; callAjaxQ.splice(callAjaxQ.length, 0, newEl); } function executeFromCallAjaxQ(){ if(callAjaxQ.length==0) return; var newEl=callAjaxQ[0]; callAjax(newEl.strURL, newEl.strPostData, newEl.thefunction); callAjaxQ.splice(0,1); } function callAjax(strURL,strPostData,thefunction) { if(callAjaxExecuting){ addToCallAjaxQ(strURL, strPostData, thefunction); return; } callAjaxExecuting=true; var xmlHttpReq = false; var self = this; var msg=""; // Mozilla/Safari var www=(window.location.href.toLowerCase().indexOf("//www.")>0)?"http://www.":"http://"; var strURL=strURL.replace("http://",www); if (window.XMLHttpRequest) { self.xmlHttpReq = new XMLHttpRequest(); } // IE else if (window.ActiveXObject) { self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } self.xmlHttpReq.open('POST', strURL, true); self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); self.xmlHttpReq.onreadystatechange = function() { if (self.xmlHttpReq.readyState == 4) { callAjaxExecuting=false; if(self.xmlHttpReq.status != 200){ alert('OOPS! Connection Error.\nPlease Check your Internet Connection.'); return; } if($.trim(self.xmlHttpReq.responseText)=='{"status":0,"msg":"Your Session seems to have expired. Please try refreshing the page to login again."}'){ alert('Your Session seems to have expired. Please try refreshing the page to login again.'); thefunction(''); return; } thefunction(self.xmlHttpReq.responseText); setTimeout('executeFromCallAjaxQ();', 5) ; } else { //alert(self.xmlHttpReq.readyState); } } self.xmlHttpReq.send(strPostData); } function selectDropDownValue(el, val){ if(!el) return; for(var i=0; i'); callAjax(listAjaxPage, data, function(t){ $('#' + listDisplayDiv).html(t); }); } function checkUnique(fld, tbl, tbl_fld, tbl_key, key_fld){ fld.addClass('field-processing'); $.ajax({ url: webroot + 'check-unique.php', type: 'POST', dataType: 'json', data: {'val':fld.val(), 'tbl':tbl, 'tbl_fld':tbl_fld, 'tbl_key':tbl_key, 'key_val':key_fld.val()}, success: function(ans){ fld.removeClass('field-processing'); if(ans.status==0){ alert(fld.attr('title') + " '" + fld.val()+ "' already exists."); fld.val(ans.existing_value); fld.focus(); } } }); } function parseJsonData(t){ if(t=='') return(false); if(t=='Your session seems to be timed out. Please try reloading the page.'){ t='{"status":0,"msg":"'+t+'"}'; } try { var ans=eval('['+t+']'); return(ans[0]); } catch (e) { return(false); } } function getQueryString() { var args = new Object(); var query = location.search.substring(1); var pairs = query.split("&"); for(var i = 0; i < pairs.length; i++) { var pos = pairs[i].indexOf('='); if (pos == -1) continue; var argname = pairs[i].substring(0,pos); var value = pairs[i].substring(pos+1); args[argname] = unescape(value); } return args; } (function($) { $.extend($.fn,{ scrollTo : function(speed, easing) { return this.each(function() { var targetOffset = $(this).offset().top; var targetLeft=$(this).offset().left; $('html,body').animate({scrollTop: targetOffset}, speed, easing); }); } }); })(jQuery); (function($) { $.extend($.fn,{ scrollToXY : function(speed, easing) { return this.each(function() { var targetOffset = $(this).offset().top; var targetLeft=$(this).offset().left; $('html,body').animate({scrollTop: targetOffset, scrollLeft: targetLeft}, speed, easing); }); } }); })(jQuery); jQuery.fn.caps = function(cb){ return this.keypress(function(e){ var w = e.which ? e.which : (e.keyCode ? e.keyCode : -1); //var s = e.shiftKey ? e.shiftKey : (e.modifiers ? !!(e.modifiers & 4) : false); var s = e.shiftKey ? e.shiftKey : (e.which==16); var c = ((w >= 65 && w <= 90) && !s) || ((w >= 97 && w <= 122) && s); cb.call(this, c); }); }; function mbsToggleColumn(options){ if(!options.tblId && !options.table) return; if(!options.colTitle && !options.colNumber) return; if(options.table){ var table=options.table; } else{ var table=$('#'+options.tblId); } //var table=(options.table || $('#'+options.tblId)); if(!options.colNumber && options.colTitle){ options.colNumber=-1; var ths=$('th', table); if(!(ths.length>0)){ ths=$('#'+options.tblId+' tr:eq(0) td'); } ths.each(function(index){ if($(this).text()==options.colTitle){ options.colNumber=index+1; } }); } if(options.colNumber<0) return; if(options.removeCells===true){ table.find('td:nth-child('+options.colNumber+')').remove(); table.find('th:nth-child('+options.colNumber+')').remove(); } else{ table.find('td:nth-child('+options.colNumber+')').toggle(); table.find('th:nth-child('+options.colNumber+')').toggle(); } } function dump(arr,level) { var dumped_text = ""; if(!level) level = 0; //The padding given at the beginning of the line. var level_padding = ""; for(var j=0;j \"" + value + "\"\n"; } } } else { //Stings/Chars/Numbers etc. dumped_text = "===>"+arr+"<===("+typeof(arr)+")"; } return dumped_text; }