// Header
// SiteCatalyst variable
var Prop10 = "Top_Job";
// Set defaults
if (!topjobs_tablewidth) {
	var tableWidth = 150;
}
else {
	var tableWidth = topjobs_tablewidth;
}
if (!topjobs_tableborder) {
var tableBorder = 1;
}
else {
	var tableBorder = topjobs_tableborder;
}
if (!topjobs_tablecellpadding) {
	var tableCellPadding = 1;
}
else {
	var tableCellPadding = topjobs_tablecellpadding;
}
if (!topjobs_tablecellspacing) {
	var tableCellSpacing = 0;
}
else {
	var tableCellSpacing = topjobs_tablecellspacing;
}
if (!topjobs_tablebgcolor) {
	var tableBgcolor = "#ffffff";
}
else {
	var tableBgcolor = topjobs_tablebgcolor;
}

var header = "<LINK REL='STYLESHEET' TYPE='text/css' HREF='http://www.courier-journal.com/includes/cjstylegen.css'><table border="+tableBorder+" cellpadding="+tableCellPadding+" cellspacing="+tableCellSpacing+" bgcolor="+tableBgcolor+" width="+tableWidth+"><tr><td align=center><table><tr><td align=center class=gcitopjobs><a href='http://courier-journal.gannettonline.com/careerbuilder/index.html' target=_blank><img src='http://www.courier-journal.com/framework/topjobs_careerbuilder.gif' border=0></a><hr size=1 color=000066 noshade></td></tr>";

var allHeader = "<html><head><LINK REL='STYLESHEET' TYPE='text/css' HREF='http://www.courier-journal.com/includes/cjstylegen.css'><title>Top Jobs</title></head><body><table width=250><tr><td align=center><a href='http://courier-journal.gannettonline.com/careerbuilder/index.html' target=_blank><img src='http://www.courier-journal.com/framework/topjobs_careerbuilder.gif' border=0></a><hr size=1 color=000066 noshade></td></tr>";

// All the postings
var allPostings = new Array("placeholder"
, Array('Executive/ Management/ Strategy Planning', '', 'WANT TO FEEL VALUED? Then join our dynam...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY1LG6MTWQWL8YGD75&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Skilled Labor', '', '1 PRINTING Welch Printing, one of the ar...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY3F76JKHN07C28W0W&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Hotel/ Hospitality', '', 'The Seelbach Hilton Hotel Is Looking For...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY10P6YR55422D8WY0&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Engineering', '', 'SERVICE ENGINEER /TECHNICIAN The success...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY6NQ6FPC5XGHDWRHH&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Accounting/ Finance/ Banking', '', 'Hoosier Hills Credit Union Vice Presiden...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY72Y79B8M34N52S10&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Engineering', '', 'DESIGNER Mann Hummel Advanced Filtration...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY6HC61F2M7N00NNHP&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Sales Marketing', '', 'SALES PROFESSIONAL $100,000 1st yr. pote...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY6PT6PTH2JC3RCFM9&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Training/ Education', '', 'Interested in earning teacher certificat...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY7JF6WFNC4DKC1TZ3&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Executive/ Management/ Strategy Planning', '', 'SERVICE MANAGER Technical Support Engine...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY2F06W08SSHL3NG65&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Other', '', '4TH STREET LIVE MARRIOTT UPS Brantley Se...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY75F6MTP92TSTGZ48&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Sales Marketing', '', 'MEDICAL DEVICE OUTSIDE SALES REPRESENTAT...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY7HX6GFSP0KVL8TYX&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Sales Marketing', '', 'LOUISVILLE SALES CENTER LOUISVILLE, KENT...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY5VB6Q67T8HVRNNGG&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Skilled Labor', '', 'ATTENTION Branch Manager R.E. MICHEL COM...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY6PW5XQ5YDVX42JC6&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Professional Services', '', 'ASSISTANT DEVELOPMENT DIRECTOR The Mason...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY4087071KBZR5CYCX&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Healthcare', '', 'MCSI OPPORTUNITIES Investigate our New P...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY6076PSQP82RKGYZZ&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Accounting/ Finance/ Banking', '', 'VP Finance The Greater Louisville Conven...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY7177959NKF617YT9&lr=cbga_lcj&siteid=cbcg_lcj060')
);
// Footer

var footer = "<tr><td class=gcitopjobs><a href=\"http://courier-journal.gannettonline.com/topjobs/detail/LCJ-detail-v1.html?topjobscount=99999\" target=\"topjobs\" onClick=\"window.open('','topjobs','directories=no,height=500,width=300,scrollbars=1,location=no,resizable=yes,screenx=15,screeny=15,toolbar=no,opener=orig')\">All Top Jobs</a></td></tr><tr><td><center><a href=\"http://courier-journal.gannettonline.com/courier-journal/content/AboutTopJobs.html\" target=_blank><font class=gcitopjobs><b>About Top Jobs</b></font></a></center></td></tr></table></td></tr></table>";

var allFooter = "</table></body></html>";

///////////////////////////////////////////////////////////////////////////////////

function display_postings() {

	// Handle no postings situation

	if (allPostings.length == 1) {
		document.write(header);
	document.write("<tr><td><center><font class=gcitopjobs>Watch for Top Jobs coming to this space soon.</font></center><hr size=1 color=000066 noshade></td></tr>");
	document.write("</table></table>");
	return;
}


if (!FORM_DATA['topjobscount']) {
	if (!topjobs_count) {
		var displayCount = 5;
	}
	else {
		var displayCount = topjobs_count;
	}
}
else {
	var displayCount = FORM_DATA['topjobscount'];
}
// Create target array
var displayPostings;
var allPostingsCount = allPostings.length;
var i;
if (displayCount == 99999) {
	document.write(allHeader);
	// Remember array entry 0 is placeholder, so start at index 1
	for (i = 1; i < allPostingsCount; i++) {
		if (!allPostings[i][1]) {
			document.write("<tr><td><font class=gcitopjobs><a href='" + allPostings[i][3] + "'target=_blank><b>" + allPostings[i][0] + "</b><br>" +
				allPostings[i][2] + "</a></font><hr size=1 color=000066 noshade></td></tr>");
		}
		else {
			document.write("<tr><td><font class=gcitopjobs><a href='" + allPostings[i][3] + "'target=_blank><b>" + allPostings[i][0] + "</b><br>" +
				allPostings[i][1] + "</a></font><hr size=1 color=000066 noshade></td></tr>");
		}
	}
	document.write(allFooter);
}
else {
	// Delete array entry 0 ("placeholder")
	for (i = 0; i < allPostings.length - 1; i++)
		allPostings[i] = allPostings[i + 1];
		allPostingsCount--;

		document.write(header);
		displayPostings = new Array();
		while (displayCount > 0 && allPostingsCount > 0) {
			// Move a random entry from allPostings to displayPostings
			var targetIndex = Math.floor(Math.random() * allPostingsCount %
				allPostingsCount);
			displayPostings[displayPostings.length] = allPostings[targetIndex];

			for (i = targetIndex; i < allPostings.length - 1; i++)
				allPostings[i] = allPostings[i + 1];
			allPostingsCount--;
			displayCount--;
		}
		// Display Job Title only
		if (topjobs_option == 1) {
			for (i = 0; i < displayPostings.length; i++) {
				document.write("<tr><td><font class=gcitopjobs><a href='" +
					displayPostings[i][3] + "' target=_blank><b>" + displayPostings[i][0] +
					"</b><br></a></font><hr size=1 color=000066 noshade></td></tr>");
			}
		}
		// Display Employer Name only. If Employer name does not exist display Job Title
		else if (topjobs_option == 2) {
			for (i = 0; i < displayPostings.length; i++) {
				if (!displayPostings[i][1]) {
					document.write("<tr><td><font class=gcitopjobs><a href='" +
						displayPostings[i][3] + "' target=_blank><b>" + displayPostings[i][0] +
						"</b><br></a></font><hr size=1 color=000066 noshade></td></tr>");
				}
				else {
					document.write("<tr><td><font class=gcitopjobs><a href='" +
						displayPostings[i][3] + "' target=_blank><b>" + displayPostings[i][1] +
						"</b><br></a></font><hr size=1 color=000066 noshade></td></tr>");
				}
			}
		}
		// Display Description only
		else if (topjobs_option == 3) {
			for (i = 0; i < displayPostings.length; i++) {
				document.write("<tr><td><font class=gcitopjobs><a href='" +
					displayPostings[i][3] + "' target=_blank><b>" + displayPostings[i][2] +
					"</b><br></a></font><hr size=1 color=000066 noshade></td></tr>");
			}
		}
		// Display Job Title followed by Employer Name. If Employer name does not exist display Job Description
		else if (topjobs_option == 4) {
			for (i = 0; i < displayPostings.length; i++) {
				if (!displayPostings[i][1]) {
					document.write("<tr><td><font class=gcitopjobs><a href='" +
						displayPostings[i][3] + "' target=_blank><b>" + displayPostings[i][0] + "</b><br>" +
						displayPostings[i][2] + "</a></font><hr size=1 color=000066 noshade></td></tr>");
				}
				else {
					document.write("<tr><td><font class=gcitopjobs><a href='" +
						displayPostings[i][3] + "' target=_blank><b>" + displayPostings[i][0] + "</b><br>" +
						displayPostings[i][1] + "</a></font><hr size=1 color=000066 noshade></td></tr>");
				}
			}
		}
		// Display Job Title followed by Job Description
		else if (topjobs_option == 5) {
			for (i = 0; i < displayPostings.length; i++) {
				document.write("<tr><td><font class=gcitopjobs><a href='" +
					displayPostings[i][3] + "' target=_blank><b>" + displayPostings[i][0] + "</b><br>" +
					displayPostings[i][2] + "</a></font><hr size=1 color=000066 noshade></td></tr>");
			}
		}
		// Display Employer Name followed by Job Title. If Employer name does not exist display Job Description
		else if (topjobs_option == 6) {
			for (i = 0; i < displayPostings.length; i++) {
				if (!displayPostings[i][1]) {
					document.write("<tr><td><font class=gcitopjobs><a href='" +
						displayPostings[i][3] + "' target=_blank><b>" + displayPostings[i][2] + "</b><br>" +
						displayPostings[i][0] + "</a></font><hr size=1 color=000066 noshade></td></tr>");
				}
				else {
					document.write("<tr><td><font class=gcitopjobs><a href='" +
						displayPostings[i][3] + "' target=_blank><b>" + displayPostings[i][1] + "</b><br>" +
						displayPostings[i][0] + "</a></font><hr size=1 color=000066 noshade></td></tr>");
				}
			}
		}
		// Display Employer Name followed by Job Description. If Employer name does not exist display Job Title
		else if (topjobs_option == 7) {
			for (i = 0; i < displayPostings.length; i++) {
				if (!displayPostings[i][1]) {
					document.write("<tr><td><font class=gcitopjobs><a href='" +
						displayPostings[i][3] + "' target=_blank><b>" + displayPostings[i][0] + "</b><br>" +
						displayPostings[i][2] + "</a></font><hr size=1 color=000066 noshade></td></tr>");
				}
				else {
					document.write("<tr><td><font class=gcitopjobs><a href='" +
						displayPostings[i][3] + "' target=_blank><b>" + displayPostings[i][1] + "</b><br>" +
						displayPostings[i][2] + "</a></font><hr size=1 color=000066 noshade></td></tr>");
				}
			}
		}
		// Display Job Description followed by Job Title
		else if (topjobs_option == 8) {
			for (i = 0; i < displayPostings.length; i++) {
				document.write("<tr><td><font class=gcitopjobs><a href='" +
					displayPostings[i][3] + "' target=_blank><b>" + displayPostings[i][2] + "</b><br>" +
					displayPostings[i][0] + "</a></font><hr size=1 color=000066 noshade></td></tr>");
			}
		}
		// Display Job Description followed by Employer Name. If Employer name does not exist display Job Title
		else if (topjobs_option == 9) {
			for (i = 0; i < displayPostings.length; i++) {
				if (!displayPostings[i][1]) {
					document.write("<tr><td><font class=gcitopjobs><a href='" +
						displayPostings[i][3] + "' target=_blank><b>" + displayPostings[i][2] + "</b><br>" +
						displayPostings[i][0] + "</a></font><hr size=1 color=000066 noshade></td></tr>");
				}
				else {
					document.write("<tr><td><font class=gcitopjobs><a href='" +
						displayPostings[i][3] + "' target=_blank><b>" + displayPostings[i][2] + "</b><br>" +
						displayPostings[i][1] + "</a></font><hr size=1 color=000066 noshade></td></tr>");
				}
			}
		}
		// Default to Job Title followed by Employer Name. If Employer name does not exist display Job Description
		else {
			for (i = 0; i < displayPostings.length; i++) {
				if (!displayPostings[i][1]) {
					document.write("<tr><td><font class=gcitopjobs><a href='" +
						displayPostings[i][3] + "' target=_blank><b>" + displayPostings[i][0] + "</b><br>" +
						displayPostings[i][2] + "</a></font><hr size=1 color=000066 noshade></td></tr>");
				}
				else {
					document.write("<tr><td><font class=gcitopjobs><a href='" +
						displayPostings[i][3] + "' target=_blank><b>" + displayPostings[i][0] + "</b><br>" +
						displayPostings[i][1] + "</a></font><hr size=1 color=000066 noshade></td></tr>");
				}
			}
		}
		document.write(footer);
	}
}


function createRequestObject() {
	FORM_DATA = new Object();
	// The Object (Array) where our data will be stored.
	separator = ',';
	// The token used to separate data from multi-select inputs
	query = '' + this.location;
	qu = query
	// Get the current URL so we can parse out the data.
	// Adding a null-string '' forces an implicit type cast
	// from property to string, for NS2 compatibility.
	query = query.substring((query.indexOf('?')) + 1);
	// Keep everything after the question mark '?'.
	if (query.length < 1) { return false; } // Perhaps we got some bad data?
	keypairs = new Object();
	numKP = 1;
	// Local vars used to store and keep track of name/value pairs
	// as we parse them back into a usable form.
	while (query.indexOf('&') > -1) {
		keypairs[numKP] = query.substring(0,query.indexOf('&'));
		query = query.substring((query.indexOf('&')) + 1);
		numKP++;
		// Split the query string at each '&', storing the left-hand side
		// of the split in a new keypairs[] holder, and chopping the query
		// so that it gets the value of the right-hand string.
	}
	keypairs[numKP] = query;
	// Store what's left in the query string as the final keypairs[] data.
	for (i in keypairs) {
		keyName = keypairs[i].substring(0,keypairs[i].indexOf('='));
		// Left of '=' is name.
		keyValue = keypairs[i].substring((keypairs[i].indexOf('=')) + 1);
		// Right of '=' is value.
		while (keyValue.indexOf('+') > -1) {
			keyValue = keyValue.substring(0,keyValue.indexOf('+')) + ' ' + keyValue.substring(keyValue.indexOf('+') + 1);
			// Replace each '+' in data string with a space.
		}
		keyValue = unescape(keyValue);
		// Unescape non-alphanumerics
		if (FORM_DATA[keyName]) {
			FORM_DATA[keyName] = FORM_DATA[keyName] + separator + keyValue;
			//document.write('The value of ' +keyName+ ' is:'+FORM_DATA[keyName]+'<br>');
			// Object already exists, it is probably a multi-select input,
			// and we need to generate a separator-delimited string
			// by appending to what we already have stored.
		}
		else {
			FORM_DATA[keyName] = keyValue;
			//document.write('The value of ' +keyName+ ' is:'+FORM_DATA[keyName]+'<br>');
			// Normal case: name gets value.
		}
	}
	return FORM_DATA;
}


// MAINLINE

FORM_DATA = createRequestObject();
// This is the array/object containing the GET data.
// Retrieve information with 'FORM_DATA [ key ] = value'.

// Display jobs 
display_postings();

