// April 05, 2005 - AMD 
// created

// Booleans
var skill_hid = false;
var experience_hid = false;
var reference_hid = false;
var award_hid = false;
var publication_hid = false;
var education_hid = false;
var benefit_hid = false;
var location_hid = false;
var desired_hid = false;


// Number of records to skip, and max record number to hide
var counts = new Array();

// Table names
var table_names = new Array();

// Path of nav images
var navPath = '/images/layout/profile/';
var navSelected = '/images/layout/profile/selected_arrow.gif';
var navNormal =   '/images/blank.gif';


// Sets numbers for how many of each record to use
// MUST BE USED BEFORE SHOW/HIDE FUNCTIONS
function setCount( type, skip, maximum )
{
	eval( 'var '+type+'_hid = false' );
	
	if( maximum > skip )
	{
		counts[type] = new Array();
		counts[type]['skip'] = skip;
		counts[type]['max'] = maximum;
	}
		
}


// Sets table names so that we know what tables to show/hide when needed
function setTables( tables )
{
	table_names = tables;
} 

// Hides all the tables and data
// if "tables_only" is true, only switch tables, do not manipulate data rows
function hideAll( tables_only )
{
	if( !tables_only )
	{
		manip( "skill" );	
		manip( "experience" );
		manip( "reference" );
		manip( "award" );
		manip( "publication" );
		manip( "education" );
		manip( "desired" );
	}
	
	
	if( !table_names[0] )
		return;

	for( i = 0; i < table_names.length; i++ )
	{	
		document.getElementById( 'show_'+table_names[i] ).style.display = 'none';
		document.getElementById( 'img_'+table_names[i] ).src = navNormal;
		navOff( table_names[i] );
	}
}



// Hides all tables, and then shows only the one selected
function showTable( table )
{
	var to_show = document.getElementById( 'show_'+table );
	var nav = document.getElementById( 'img_'+table );
			
	hideAll( true );
				
	to_show.style.display = '';
	nav.src = navSelected;
	
	navOn( table );
}				
			

// Expands or collapses information for 'type'
function manip( type )
{
	if( !counts[type] )		
		return;

	if( eval( type+'_hid' ) )
	{
		var style = '';
		eval( type+'_hid = false' );
		
		document.getElementById( 'show'+type ).style.display = 'none';
		document.getElementById( 'hide'+type ).style.display = '';
		
		// Check to see if this is a type of data that has a spacer beneath the rows
		var spacer = document.getElementById( type+'_spacer_0' );
	}
	else
	{
		var style = 'none';
		eval( type+'_hid = true' );
		
		document.getElementById( 'show'+type ).style.display = '';
		document.getElementById('hide'+type ).style.display = 'none';
		
		// Check to see if this is a type of data that has a spacer beneath the rows
		var spacer = document.getElementById( type+'_spacer_0' );
	}
	
	for( i = counts[type]['skip']; i < counts[type]['max']; i++ )
	{
		document.getElementById( type+'_row_'+i ).style.display = style;
		
		// If there are spacers for this data type
		if( spacer )
			document.getElementById( type+'_spacer_'+i ).style.display = style;
	}
}


// Alerts the user that they are not permitted to view the given information
function notPermitted()
{
	alert( 
		"You are not permitted to view this information, as you do not represent this candidate.\r"+
		"Please use the contact information displayed in this profile if you would like to obtain\r"+
		"this data from a representing client." );
}


// Changes tab image when moused over
function navOn( tab )
{
	document.getElementById( 'nav_'+tab ).src = navPath+'tab_'+tab+'_on.gif';
}

// Changes tab image when mouse is moved off
function navOff( tab )
{
	// If this table is showing, don't turn off the 'on' image when they mouse over and out
	if( document.getElementById( 'show_'+tab ).style.display == '' )
		return;
		
	document.getElementById( 'nav_'+tab ).src = navPath+'tab_'+tab+'.gif';
}
