// job offer object
function Job() {
	this.aNodes = new Array();
}

function JobNode(dept, title) {
	this.dept = dept;
	this.title = title;
	this.aDesc = new Array();
	this.aReq = new Array();
}

JobNode.prototype.addDesc = function(desc) {
	this.aDesc[this.aDesc.length] = desc;
}

JobNode.prototype.addReq = function(req) {
	this.aReq[this.aReq.length] = req;
}

Job.prototype.add = function(dept, title) {
	this.aNodes[this.aNodes.length] = new JobNode(dept, title);
}

Job.prototype.addDesc = function(desc) {
	if (this.aNodes.length > 0) this.aNodes[this.aNodes.length - 1].addDesc(desc);
}

Job.prototype.addReq = function(req) {
	if (this.aNodes.length > 0) this.aNodes[this.aNodes.length - 1].addReq(req);
}

Job.prototype.header = function() {
	var r = '';
	var dept = '';
	for (var i = 0; i < this.aNodes.length; i++) {
		var e = this.aNodes[i];
		if (i > 0 && e.dept != dept) r += '<br /><br />';
		if (e.dept != dept) r += '<div class="arial12red">' + e.dept.toUpperCase() + '</div>' + "\n";
		r += '<div class="arial12boldred"><a href="#vacancy' + i + '">' + e.title + '</a></div>' + "\n";
		dept = e.dept;
	}
	return r;
}

Job.prototype.toString = function() {
	var r = '';
	var dept = '';
	for (var i = 0; i < this.aNodes.length; i++) {
		r += '<p>&nbsp;</p>' + "\n";
		var e = this.aNodes[i];
		if (e.dept != dept) r += '<p class="arial12boldred" style="font-size:11pt;">' + e.dept.toUpperCase() + '</p>' + "\n";
		dept = e.dept;
		r += '<a name="#vacancy' + i + '"></a>' + "\n";
		r += '<div class="arial12bold">' + e.title.toUpperCase() + '</div>' + "\n";
		if (e.aDesc.length > 0) {
			r += '<div class="arial12bold"><u>Job Descriptions</u></div>' + "\n";
			r += '<ul style="list-style-image: url(' + "'../../image/common/black_dot.gif'" + ');">' + "\n";
			for (var j = 0; j < e.aDesc.length; j++) {
				r += '<li>' + e.aDesc[j] + '</li>' + "\n";
			}
			r += '</ul>' + "\n";
		}
		if (e.aReq.length > 0) {
			r += '<div class="arial12bold"><u>Requirements</u></div>' + "\n";
			r += '<ul style="list-style-image: url(' + "'../../image/common/black_dot.gif'" + ');">' + "\n";
			for (var j = 0; j < e.aReq.length; j++) {
				r += '<li>' + e.aReq[j] + '</li>' + "\n";
			}
			r += '</ul>' + "\n";
		}
	}
	return r;
}
