// 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('Health Care', '', 'Health Care Attorney Premier, regional l...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JZ13B62N2M9Z0K54KJ&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Skilled Labor', '', 'CNC MACHINISTS We have immediate opening...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY3F2759D9S9M5VCBZ&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Sales Marketing', '', 'SALES/APPLICATIONS TECHNICIAN Local grow...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY5RL6L6F0FL9TQB4B&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Sales Marketing', '', 'DISTRICT SALES MANAGER Wolverine Brass I...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY70R60QX3H951X900&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Skilled Labor', '', 'BALANCE CONTROL TECHNICIAN- HVAC Harshaw...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY2MD6Q4Z2PB27W0YH&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Healthcare', '', 'MARKETING DEVELOPMENT National healthcar...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY33S6D28CBCCHG4HL&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Restaurant/ Food Service', '', 'WORKING CHEF/WEEKEND CHEF SUPERVISOR. FT...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY7NW74N623JQ759NW&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Accounting/ Finance/ Banking', '', 'Training Team Leader sought for a progre...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY3LZ6CFW9L743NNFD&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Engineering', '', 'PLASTICS PRODUCT ENGINEER Manufacturer o...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY6CT6GNMWS04V4C6R&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Information Technology', '', 'Business Analyst FARM CREDIT SERVICES a ...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY68K66LBYCD7QNSK5&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Sales Marketing', '', 'Discover the Difference Apply at: We pro...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY32R6X245NNKR82MP&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Accounting/ Finance/ Banking', '', 'BOOKKEEPER part-time with 4-5 years exp....', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY8736XDK3G4JRJ2SY&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Hotel/ Hospitality', '', 'SALES MANAGER Our "Guest Service" orient...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY1R26B0F5BB73T3V8&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Professional Services', '', 'LEASING SPECIALIST Outgoing friendly ind...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY0RP6SSY01WY7QFZJ&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Administrative/ Clerical', '', 'OFFICE ADMINISTRATOR Experienced office ...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY7046ZDH49P1CSTD9&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Other', '', 'MACHINE OPERATORS- Architectural wood do...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY7S061T3WZKP8QWYX&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Other', '', 'BLUE STAR PLASTICS MATERIALS MANAGER BLU...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY5M26QX0KWKM5BMVC&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Healthcare', '', ' PHYSICAL Therapy Outpatient clinic is s...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY49P6F77V1SZ807ZJ&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Accounting/ Finance/ Banking', '', 'TAX PREPARATION Full Part-Time Positions...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY1465WCH68WKCYCPT&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Engineering', '', 'ENGINEERING Louisville Water Company see...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY2VS68HTT3DQ9FSKS&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Training/ Education', '', ' 1Source - Courier Journal - Louisville,...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY67D629FXMZH872CN&lr=cbga_lcj&siteid=cbcg_lcj060')
, Array('Transportation', '', 'TRUCK DRIVERS PJAX, INC. - - LTL Reg, Tr...', 'http://www.careerbuilder.com/jobseeker/jobs/JobDetails.aspx?Job_DID=JY2QF7367Q87KT7MJZ&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();

