var C_JOB_LIST 		= "2502";
var C_ASSIGNED_LIST = "2503";
var C_LOGOUT 		= "2504";

var C_ADD 		= "a" ;
var C_CHANGE 	= "c" ;
var C_DELETE 	= "d" ;
var C_EXPORT 	= "e" ;
var C_GET 		= "g";
var C_LIST 		= "l" ;
var C_NEW 		= "n";
var C_QUERY 	= "q" ;
var C_REPORT 	= "r" ;
var C_UPDATE 	= "u" ;
var C_VIEW 		= "v";
var C_PWD		= "4";

var	C_OK 		= "0";
var C_INFO 		= "6" ;
var C_INVALID 	= "7";
var C_CONFIRM 	= "8" ;
var C_ERROR 	= "9" ;

$(document).ready(function() {
	$('#btnLogout').click(function (e) {
		e.preventDefault();
		onLogout($(this));
	});
	// $("#myjob").click();
	$('#toolbar-right').hide();
	getMyJobList();
	getAssignedJobList();
}) ;
function getMyJobList() {
	var data = { "type": C_JOB_LIST } ;
	var url = "request.pzx?c=" + agent_url + "&d=" + new Date().getTime() ;
	callServer(url,"json",data,onResponseList,null) ;
}
function getAssignedJobList() {
	var data = { "type": C_ASSIGNED_LIST } ;
	var url = "request.pzx?c=" + agent_url + "&d=" + new Date().getTime() ;
	callServer(url,"json",data,onResponseList,null) ;
}
function onResponseList(obj,resp) {
	if (resp.status == C_OK) {
		if(resp.type == C_JOB_LIST) {
			$("#my_job_list").html(resp.data);
		} else {
			$("#assigned_job_list").html(resp.data);
		}
	} else {
		alert(resp.mesg);
	}
}
function onLogout(obj) {
	var data = { "type": C_LOGOUT } ;
	var url = "request.pzx?c=" + home_url  +"&d=" + new Date().getTime() ;		
	callServer(url,"json",data,onLogoutResponse) ;
}
function onLogoutResponse(data) {
	openSite("index.pzx");
}
function showPage(page,desc,type) {
	showProgress("loading " + desc) ;
	var data = { "type": type } ;
	var url = "request.pzx?c=" + page + "&t=" + type + "&d=" + new Date().getTime() ;
	callServer(url,"json",data,onHomeResponse,null) ;
}
function onHomeResponse(obj, resp) {
	if (resp.status != C_OK) 
		return false;
	
	$("#kt_content").html(resp.data.htmlContent);
	$("#kt_subheader_title").html(resp.data.headTitle);
}
