function Task(){
this.iTaskName=null;
this.iFailMessage=null;
this.iRequest=null;
this.iRequestTimer=null;
this.iButtonImage=null;
this.iButtonResetTimer=null;
this.iMouseOver=false;
this.iFeedback=false;
this.iSendNow=false;
this.iRequestObject=null;
this.handleResponse=function(){
var _1;
var _2=false;
if(this.iRequest.readyState==4){
window.clearTimeout(this.iRequestTimer);
if(this.iRequest.status==200){
_1=JSON.parse(this.iRequest.responseText);
_2=(_1&&_1.ok==true);
if(_2){
this.responseSuccess(_1);
}
}
if(!_2){
this.errorFeedback("server error");
}
this.iRequest=null;
this.iRequestTimer=null;
}
};
this.requestTimedOut=function(){
this.cancelRequest();
this.stopWorkingAnimation();
this.errorFeedback("request timed out");
};
this.mouseOver=function(){
this.iMouseOver=true;
this.updateButtonImage();
};
this.mouseOut=function(){
this.iMouseOver=false;
this.updateButtonImage();
};
this.errorFeedback=function(_3){
this.iFeedback=true;
this.setButtonImage("taskbar_cross");
this.stopWorkingAnimation();
var _4=_3?_3+" - ":"";
this.userMessage(_4+this.iFailMessage);
this.startButtonResetTimer();
};
this.successFeedback=function(){
this.iFeedback=true;
this.setButtonImage("taskbar_tick");
this.stopWorkingAnimation();
this.startButtonResetTimer();
};
this.resetButton=function(){
this.iFeedback=false;
this.updateButtonImage();
};
this.cancelRequest=function(){
if(this.iRequest){
this.iRequest.abort();
this.iRequest=null;
}
if(this.iRequestTimer){
window.clearTimeout(this.iRequestTimer);
this.iRequestTimer=null;
}
};
}
Task.prototype.init=function(){
this.iButtonImage=$(this.iTaskName+"Button");
var _5=$(this.iTaskName+"Title");
_5.onmouseover=function(){
Task.showHighlightTitle(this.id);
};
_5.onmouseout=function(){
Task.showNormalTitle(this.id);
};
};
Task.showHighlightTitle=function(_6){
$(_6).style.background=$(_6).style.background.replace(/jpg/,"gif");
};
Task.showNormalTitle=function(_7){
$(_7).style.background=$(_7).style.background.replace(/gif/,"jpg");
};
Task.prototype.submitRequest=function(){
this.iSendNow=true;
this.createRequestObject();
if(this.iSendNow){
this.completeSubmitRequest();
}
};
Task.prototype.completeSubmitRequest=function(){
if(this.iRequestObject!=null){
var _8=JSON.stringify(this.iRequestObject);
this.iRequest=HTTP.newRequest();
this.iRequest.open("POST",this.getServiceUrl());
this.iRequest.setRequestHeader("Content-type","text/plain");
this.iRequest.setRequestHeader("Content-length",_8.length);
this.iRequest.setRequestHeader("Connection","close");
this.setCallbacks();
this.iRequest.send(_8);
this.startWorkingAnimation();
}
};
Task.prototype.updateButtonImage=function(){
if(!this.iFeedback){
imageName=(this.iMouseOver?"taskbar_arrow_over":"taskbar_arrow");
this.setButtonImage(imageName);
}
};
Task.prototype.setButtonImage=function(_9){
if(this.iButtonImage!=null){
this.iButtonImage.src=this.iButtonImage.src.replace(/([^\/]+).gif$/,_9+".gif");
}
};
Task.prototype.startWorkingAnimation=function(){
$(this.iTaskName+"Working").style.display="inline";
$(this.iTaskName+"Button").style.display="none";
Task.showHighlightTitle(this.iTaskName+"Title");
};
Task.prototype.stopWorkingAnimation=function(){
$(this.iTaskName+"Working").style.display="none";
$(this.iTaskName+"Button").style.display="inline";
Task.showNormalTitle(this.iTaskName+"Title");
};
Task.prototype.userMessage=function(_a){
gPage.iDialog=new TimedAlert(this.iTaskName,_a);
gPage.iDialog.display();
};

