var currentJobID = '';

$(function() {
	
	$('#apply-submit-link').livequery('click',function() {
		$('#employment-right-container').load("include/ajaxFiles/employment/submitApply.php","sid="+Math.random(),function() {
			$('#rightFooterSpan').load("include/templateFiles/footerBucketEmployment.php","sid="+Math.random()); // reload the employment footer
		});
		return false;
	});
	
	//////// Open the left side of the brain /////
	$('#applyLeft').livequery('click',function() {
		$('#employment-right-container').load("include/templateFiles/employment/personal.php","sid="+Math.random()+"&id="+currentJobID);
		return false;
	});

		//////// Open the left side of the brain /////
	$('#applyRight').livequery('click',function() {
		$('#employment-right-container').load("include/templateFiles/employment/questions.php","sid="+Math.random()+"&id="+currentJobID);
		return false;
	});
	
	////////// Hover state for the brain
	
	$('#applyLeft').livequery(function() {
		 $(this).hover(function(){ $('#brain-label-left').addClass('brain-label-left-active'); }, function(){ $('#brain-label-left').removeClass('brain-label-left-active'); });
	});
	
	$('#applyRight').livequery(function() {
		 $(this).hover(function(){ $('#brain-label-right').addClass('brain-label-right-active'); }, function(){ $('#brain-label-right').removeClass('brain-label-right-active'); });
	});
	
	////////// Open the modal on click ////////
	$('#jobs-list a').livequery('click',function() {
		currentJobID = $(this).attr('rel');
		openEmployment();
		return false;
	});
	
	$('.close-employment-section').livequery('click',function() {
		closeEmployment();
		return false;
	});
	
	function openEmployment() {
		$('#employment-left, #employment-right-container').html('');
		$('#employment-right-container').load("include/templateFiles/employment/brain.php","sid="+Math.random()+"&id="+currentJobID);
		$('#employment-left').load("include/ajaxFiles/employment/getDescription.php","sid="+Math.random()+"&id="+currentJobID);
		$('.employment-tabs').css('display','inline');
	}
	
	function closeEmployment() {
		$('.employment-tabs').css('display','none');
	}
});

///// Resource Upload Functions /////////////////////////////////////////////
function startUpload(){
	/*$(function() {
		$('#uploadProcess').get(0).style.display = '';
	});*/
	
	return true;
}

function loadTheBrain(uploadError){
	$(function() {
		$('#employment-right-container').load("include/templateFiles/employment/brain.php","sid="+Math.random()+"&id="+currentJobID);
		if(uploadError) {}
	});
	

	return true;   
}
