var Fire=true;$(window).bind("beforeunload",function(){Fire=false});var KJax={isSuccess:function(a){return"Success"in a&&Number(a.Success)==1}},ERROR_NONE=0,ERROR_CODE_CUSTOM=1,ERROR_CODE_LOGIN_AUTH=2,ERROR_CODE_EXCEPTION=4,ERROR_CODE_ASSERT=8,ERROR_CODE_MISC=16,ERROR_CODE_BAD_DATA=32,ERROR_CODE_TIMEOUT=64,ERROR_CODE_ERROR=128,ERROR_CODE_NOTMODIFIED=256,ERROR_CODE_PARSERERROR=512,ERROR_CODE_LOGGEDIN=1024,ERROR_CODE_UNKNOWN=1073741824;
function doKJaxCall(){for(var a=arguments[0],b=[],c=0;c<arguments.length;c++)c!=0&&b.push(arguments[c]);var d=b.length-1,g=0,g=typeof Client=="object"?Number(Client.Type=="User"):Number($("#LoggedIn").val()),h,i,f,j=null,e="post",k="json",c=b[d];if(typeof c=="object"){if(b[d].method)e=b[d].method;if(b[d].data_type)k=b[d].data_type;if(b[d].success)success_callback=b[d].success;if(b[d].complete)h=b[d].complete;if(b[d].error)i=b[d].error;b[d].ignoreLoginState&&(g=-1)}else d>=1?typeof c=="function"&&
typeof b[d-1]=="function"?(f=b[d-1],j=b[d]):f=b[d]:f=b[d],success_callback=function(a){if(!a||a.constructor!==Array&&a.constructor!==Object)f(a);else{var b=ERROR_NONE,c="",d=null,e=null;"ErrorMessage"in a&&(c=a.ErrorMessage);"ErrorCode"in a&&(b=a.ErrorCode);"ErrorThrown"in a&&(d=a.ErrorThrown);"Request"in a&&(e=a.Request);if(b>ERROR_CODE_CUSTOM&&j!=null)return j(a);if(b&ERROR_CODE_LOGIN_AUTH)HandleErrorCodeLoginAuth();else if(b&ERROR_CODE_EXCEPTION)HandleErrorCodeException(c);else if(b&ERROR_CODE_MISC)HandleErrorCodeMisc(c);
else if(b&ERROR_CODE_BAD_DATA)HandleErrorCodeBadData(c);else if(b&ERROR_CODE_TIMEOUT)HandleErrorCodeTimeout(e,d);else if(b&ERROR_CODE_ERROR)HandleErrorCodeError(e,d);else if(b&ERROR_CODE_NOTMODIFIED)HandleErrorCodeNotModified(e,d);else if(b&ERROR_CODE_PARSERERROR)HandleErrorCodeParserError(e,d);else if(b&ERROR_CODE_LOGGEDIN)HandleErrorCodeLoggedIn(e,d);else if(b&ERROR_CODE_CUSTOM||b==ERROR_NONE)return typeof checkKarmaChanged=="function"&&checkKarmaChanged(a),f(a)}};var m=typeof JSON!="undefined",
l=[];uri="jq="+a;for(c=0;c<d;c++)m&&typeof b[c]=="object"?(a=encodeURIComponent(JSON.stringify(b[c])),l.push(c)):a=encodeURIComponent(b[c]),uri+="&jqargs[]="+a;uri+="&jqargs[]="+k+"&jqloggedin="+g;l.length&&(uri+="&jqjsonargs="+l.join(","));b=window.location.href.replace(window.location.hash,"");e={type:e,url:b,dataType:k,data:uri,success:success_callback};h&&(e.complete=h);e.error=i?i:function(a,b,c){if(Fire)return ResponseData=[],ResponseData.ErrorThrown=c,ResponseData.Request=a,ResponseData.ErrorCode=
b=="timeout"?ERROR_CODE_TIMEOUT:b=="error"?ERROR_CODE_ERROR:b=="notmodified"?ERROR_CODE_NOTMODIFIED:b==""?ERROR_CODE_PARSERERROR:ERROR_CODE_UNKNOWN,success_callback(ResponseData)};return $.ajax(e)}function HandleErrorCodeLoginAuth(){var a=new Popup;a.setTitle("Login Required");a.setBody("It appears your session has timed out and you have been logged out of Koofers.com.  Please reload the page and login to perform this action.");a.addOkButton();a.display()}
function HandleErrorCodeException(a){var b=new Popup;b.setTitle("Error");var c="An error has occurred. <br/>";a!=""&&(c+=": "+a+"<br />");c+='Please try again.  If the problem persists, please send us an <a href="mailto:support@koofers.com">email</a>';b.setBody(c);b.addOkButton();b.display()}
function HandleErrorCodeMisc(a){var b=new Popup;b.setTitle("Error");var c="An error has occurred. <br/>";a!=""&&(c+=": "+a+"<br />");c+='Please try again.  If the problem persists, please send us an <a href="mailto:support@koofers.com">email</a>';b.setBody(c);b.addOkButton();b.display()}function HandleErrorCodeBadData(a){var b=new Popup;b.setTitle("Bad data encountered. <br/>");b.setBody(a+"<br /><br />Please try again.");b.addOkButton();b.display()}
function HandleErrorCodeTimeout(){var a=new Popup;a.setTitle("Error");a.setBody('Your request has timed out.  Please try again.  If the problem persists, please send us an <a href="mailto:support@koofers.com">email</a>');a.addOkButton();a.display()}function HandleErrorCodeError(){var a=new Popup;a.setTitle("Error");a.setBody('A server error has occurred.  Please try again.  If the problem persists, please send us an <a href="mailto:support@koofers.com">email</a>');a.addOkButton();a.display()}
function HandleErrorCodeNotModified(){var a=new Popup;a.setTitle("Error");a.setBody('An error has occurred.  Please try again.  If the problem persists, please send us an <a href="mailto:support@koofers.com">email</a>');a.addOkButton();a.display()}function HandleErrorCodeParserError(){var a=new Popup;a.setTitle("Error");a.setBody('An error has occurred.  Please try again.  If the problem persists, please send us an <a href="mailto:support@koofers.com">email</a>');a.addOkButton();a.display()}
function HandleErrorCodeLoggedIn(){(new Popup({body:'<div class="k_center"><img src="//d3vdtj41cje8r4.cloudfront.net/1327599732/images/common/CircleLoaderLarge.gif" height="32"/><div style="font-size: 20px; font-weight: bold;">Logging you in...</div></div>'})).display();setTimeout(reload,100)};

