function ajaxProcess(url,data,status,onsuccess,onfailure,returnResult){var toReturn=false;$.ajax({url:url,data:data,type:'POST',async:false,beforeSend:function(){status.html("<img src='images2/ajax-loader.gif' alt=''/>")},success:function(response){status.html("");var result=$.JSON.decode(response);toReturn=result.status==1?true:false;if($.type(onsuccess)=="function"&&result.status==1){onsuccess()}if($.type(onfailure)=="function"&&result.status==0){onfailure()}var showIcon=result.status==1?"images2/tick.png":"images2/fail.png";$("#freeow").freeow(result.status==1?"Success":"Error",result.message,{icon:showIcon,autoHide:true})}});if($.type(returnResult)=="boolean"){if(returnResult){return returnResult}}}function ajaxContent(url,data,container,onload){$.ajax({url:url,data:data,type:'POST',async:false,beforeSend:function(){container.html("<img src='images2/ajax-loader.gif' alt='Loading'/>")},success:function(response){container.css("display","none");container.html(response);if($.type(onload)=="function"){onload()}container.fadeIn(1000)}})}function jAlert(message,wrapperClass,options){var htmlMsg="";if(typeof message!=="string"){$.each(message,function(key,value){htmlMsg+=value+"<br/>"})}else{htmlMsg=message}if(wrapperClass){htmlMsg="<div class='"+wrapperClass+"'>"+htmlMsg+"</div>"}$('#dialogTemp').html(htmlMsg);$('#dialogTemp').dialog(options)}function is_int(value){if((parseFloat(value)==parseInt(value))&&!isNaN(value)){return true}else{return false}}function areDigits(strValue){var objRegExp=/(^-?\d\d*$)/;return objRegExp.test(strValue)}function login(){var errmsg=[],email=$('#loginEmail').val(),emailPattern=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}$/,pass=$('#loginPass').val();if(emailPattern.test(email)){$('#loginEmail').removeClass('error')}else{errmsg[errmsg.length]="Please enter a valid email.";$('#loginEmail').addClass('error')}if(pass==""){errmsg[errmsg.length]="Please enter your password.";$('#loginPass').addClass("error")}else{$('#loginPass').removeClass("error")}if(errmsg.length>0){jAlert(errmsg,"warnSign",{modal:true,resizable:false,title:"Please check the following",width:330,height:100,show:"fade",hide:"fade",buttons:[]})}else{var data={action:"login",email:email,password:pass};$.ajax({url:"ajax_user2.php",data:data,type:'POST',async:false,beforeSend:function(){$('#loginStatus').html("<img src='images2/ajax-loader.gif' alt='Loading'/>")},success:function(response){$('#loginStatus').html("");var res=$.JSON.decode(response);if(res.status){location.href="menu2.php?c="+$('#currentCategory').val()}else{$('#loginPass').addClass("error");$('#loginEmail').addClass('error');jAlert("User / password does not match.","warnSign",{modal:true,resizable:false,title:"Please check the following",width:330,height:100,show:"fade",hide:"fade",buttons:[]})}}})}return false}function logoff(){var data={action:"logoff"};$.ajax({url:"ajax_user2.php",data:data,type:'POST',async:false,beforeSend:function(){$('#loginStatus').html("<img src='images2/ajax-loader.gif' alt='Loading'/>")},success:function(response){$('#loginStatus').html();var res=$.JSON.decode(response);if(res.status){location.href="menu2.php?c="+$('#currentCategory').val()}else{jAlert("Not signed in!","warnSign",{modal:true,resizable:false,title:"Error!",width:330,height:100,show:"fade",hide:"fade",buttons:[]})}}})}function setAddress(source,target,status){var pc=source.val(),invalid=false;if(pc.length==6&&areDigits(pc)){var data={action:"getAddress",pc:pc};$.ajax({url:"ajax_service2.php",data:data,type:'POST',async:false,beforeSend:function(){status.html("<img src='images2/ajax-loader.gif' alt='Loading'/>")},success:function(response){status.html("");var res=$.JSON.decode(response);if(res.status){source.removeClass("error");target.removeClass("error");target.val(res.address)}else{invalid=true}}})}else{invalid=true}if(invalid){source.val("");target.val("");source.addClass("error");target.addClass("error");jAlert("Invalid postal code.","warnSign",{modal:true,resizable:false,title:"Error!",width:330,height:100,show:"fade",hide:"fade",buttons:[]})}}
