// JavaScript Document
$(document).ready( function (){
	//Hide Jobs on Load
	$(".jobListing").hide();
	$(".jobListingLinks").hide();	
	
	var jobCounter = 0;
	$('div.position').each( function(){
		if( jobCounter > 0 ){
			// hide all but the first job position div
			$(this).hide();
		}
		jobCounter++;
	});

	// use the first job's text in the mailto
	var firstJobPositionText = $('.jobListingLinks li a:first').html();
	$('#applyNow').attr('href', 'mailto:employment@instanttaxservice.com?subject=' + firstJobPositionText + '&body=Please attach your resume');

	
	$('.jobListingLinks li a').click( function(e){
		e.preventDefault();	// stop normal anchor link from firing
		// remove all selected classes from quicklinks
		$('.jobListingLinks li a').removeClass( 'selected' );
		// add selected classes to clicked link
		$(this).addClass( 'selected' );
		// get the anchor name (without the #)
		var trgt = $(this).attr('href').replace( '#', '' );
		// slide up all job position divs
		$('div.position').slideUp();
		// slide down the parent div where the anchor link target was found
		$("a[name='" + trgt + "']").parents('div').slideDown();
		// set position name as email subject
		var positionText = $(this).html();
		$('#applyNow').attr('href', 'mailto:employment@instanttaxservice.com?subject=' + positionText + '&body=Please attach your resume');
	});
	
	// if current page includes an anchor #, fire the appropriate click event
	if( window.location.hash != '' ){
		showJobs();
		$('.jobListingLinks li a[href=' + window.location.hash + ']').trigger('click');
	}

});

function checkJobs(){
	if( window.location.hash != '' ){
		showJobsInFlash();
	}
}

function showJobs(){
$(".jobListing").slideDown();
$(".jobListingLinks").slideDown();
}
	
function hideJobs(){
$(".jobListing").slideUp();
$(".jobListingLinks").slideUp();
}

function showJobsInFlash() {
	callShowJobsInFlash();
}

function callShowJobsInFlash(){
	var flashMovie = getFlashMovieObject('careers_info');
	flashMovie.doJobs('test');
}

function getFlashMovieObject(movieName){
	if (window.document[movieName]){
		return window.document[movieName];
	}
	if (navigator.appName.indexOf('Microsoft Internet')==-1){
		if (document.embeds && document.embeds[movieName]){
			return document.embeds[movieName];
		}
	}
	else // if (navigator.appName.indexOf(”Microsoft Internet”)!=-1)
	{
		return document.getElementById(movieName);
	}
}
