QUERY_METHOD = '?';

function getJobType(job) {
	return job.match(/[a-z]+(?=\d)/);
}
function buildJobsHTML(type) {
	var ret = '';
	for (var job in JOB_LIST) {
		if (getJobType(job) == type) {
			/*ret += 	 '<p><span class="code">['+job+']</span>'*/
			ret += 	 '<p>'
					+'<a href="jobs.htm'+QUERY_METHOD+'id='+job+'" ' + (QUERY_METHOD=='#'? 'onclick="loadJob(\''+job+'\')"' : '') + '>'+JOB_LIST[job].title+'</a>'
					+ (JOB_LIST[job].status ? '<img src="images/'+JOB_LIST[job].status+'.gif" alt="'+JOB_LIST[job].status+'" align="top" /> ' : '')
					+'</p>';
		}
	}
	return ret;
}


function buildSectionsHTML(type) {
	switch (typeof type) {
		case 'string': 
			return '<h4>'+JOB_TYPES[type].title+'</h4>' + buildJobsHTML(type);
		case 'object':
			var ret = '';
			for (var t in type) {
				if (type.constructor==Array) { // Array
					ret += buildSectionsHTML(type[t]);
				} else { // Object
					ret += buildSectionsHTML(t);
				}
			}
			return ret;
		default:
			return buildSectionsHTML(JOB_TYPES);
	}
}
