$(function() {
	/* this will ensure that the elemnts are in place for centering in germany */
	$('#subNavContainer div[id="subNavHeader"]').each(function() {
		var orgVal = $(this).html();
		$(this)
			.html('')
			.append(
				$("<div>")
					.addClass('leftnavTitleText')
					.html( orgVal )
			)
	})
	
	$('.leftnavTitleText').each(function() {
		/* this will center the text in the left nav title */
		var navTextPaddingTop = - ( $(this).height() - $(this).parent().height() ) / 2 - 2;
		$(this).css('paddingTop',navTextPaddingTop+'px');	
	})
	
	if ($('.leftnavTitleText').length) {
		var maxColspan = Number( $('table.jobSearchResult tr > td.jobHeader:first-child:first').attr('colspan') ) + 1;
		
		/* this will add the list seperator above the job header, but only if this is a account using the new kelly nav title */
		$('table.jobSearchResult tr > td.jobHeader:first-child, table.jobSearchResult tr > td.jobHeader:only-child').each(function() {
			$('<tr>')
				.append(
					$('<td>')
						.addClass('jobListSeperator')
						.attr('colSpan', maxColspan )
						.append(
							$('<div>')
								.addClass('jobListSeperatorCap')
						)
				)
				.insertBefore( $(this).parent() );
		})
		
		/* this will remove the stuff in the second columns */
		$('table.jobSearchResult tr > td.jobHeader:last-child').each(function(n) {
			if ($(this).parent().children().length > 1) {
				var newLocation = $('tr[id="idViewJobDetails"]:eq('+n+')');
				
				$('<tr>')
					.append(
						$(this)
							.removeClass('jobHeader')
							.attr('colSpan', maxColspan ) 
					)
					.insertAfter( newLocation );
			}
		})
		
		/* this will move the logo of the job from the jobbg tr to the job header as per the spec */
		$('.jobHeader').each(function() {
			var logoTD = $(this).parent().next('tr').find('#advertiserLogoCellID');
			logoTD.remove();
			
			$(this)
				.attr('colspan', 2 )
				.parent()
				.append(
					logoTD
						.attr('rowSpan',2)
				)
		})
		
		/* this will add the dropshadow to the job labels and job header on nav titled kelly accounts */
		$('table.jobDetailsBody').each(function() {
			$('td.detailsHeader, td.jobHeader', $(this) ).each(function() {
				var orgContent = $(this).html();
				$(this)
					.html('')
					.append(
						$('<div>')
							.addClass('text')
							.html(orgContent)
					)
				;
				$(this)
					.find('div:first')							
					.dropShadow({
						left:-5,
						top: 4,
						color:'black'
					})
				;
			})
			
			maxYoffset = -4;
			lists = $('td.jobLabel', $(this) );
			
			$(this)
				.find('.detailsBG').attr('cellSpacing','6px')
				.parent().css('padding','0px');
			lists.each(function(n){
				var orgContent = $(this).html();
				$(this)
					.html('')
					.append(
						$('<div>')
							.addClass('text')
							.html(orgContent)
					)
				;
			});
			lists.each(function(n){
				$(this)
					.find('div:first')							
					.dropShadow({
						left:-5,
						top:Math.round( maxYoffset/lists.length * (n+1) ),
						color:'black'
					})
				;
			})
		})
		
		//this fixes up the colspan on the next buttons on the job search details page
		$('span#spnNextButtonIDTOP, span#spnNextButtonIDBOTTOM').parent().attr('colSpan',3);
		
	}
});
