$(document).ready( function() {

/* Applicant Profile Links... */  
$("#applicant-link-1").hide(); 
$("#applicant-link-2").hide(); 
$("#applicant-link-3").hide(); 
$("#applicant-link-4").hide(); 

$('#twitter-domain-1').hide();		
$('#twitter-domain-2').hide();		
$('#twitter-domain-3').hide();	
$('#twitter-domain-4').hide();	

$('#my-resume-1').hide();		
$('#my-resume-2').hide();		
$('#my-resume-3').hide();		
$('#my-resume-4').hide();		


if ( $("#applicant-link-1 > input").val() != '' ) {
	$("#applicant-link-1").show(); 
}
if ( $("#applicant-link-2 > input").val() != '' ) {
	$("#applicant-link-2").show(); 
}
if ( $("#applicant-link-3 > input").val() != '' ) {
	$("#applicant-link-3").show(); 
}
if ( $("#applicant-link-4 > input").val() != '' ) {
	$("#applicant-link-4").show(); 
}
if ( $("select#applicant-links-selection-1 option:selected").val() == "Twitter" ) {			
			$('#twitter-domain-1').show();		
		}
if ( $("select#applicant-links-selection-2 option:selected").val() == "Twitter" ) {			
			$('#twitter-domain-2').show();		
		}
if ( $("select#applicant-links-selection-3 option:selected").val() == "Twitter" ) {			
			$('#twitter-domain-3').show();		
		}
if ( $("select#applicant-links-selection-4 option:selected").val() == "Twitter" ) {			
			$('#twitter-domain-4').show();		
		}		
if ( $("select#applicant-links-selection-1 option:selected").val() == "My Resume" ) {			
			$('#my-resume-1').show();					
			$('#applicant-link-1').hide();		
		}
if ( $("select#applicant-links-selection-2 option:selected").val() == "My Resume" ) {			
			$('#my-resume-2').show();		
			$('#applicant-link-2').hide();		
		}
if ( $("select#applicant-links-selection-3 option:selected").val() == "My Resume" ) {			
			$('#my-resume-3').show();					
			$('#applicant-link-3').hide();
		}
if ( $("select#applicant-links-selection-4 option:selected").val() == "My Resume" ) {			
			$('#my-resume-4').show();					
			$('#applicant-link-4').hide();
		}
	
$('select#applicant-links-selection-1').change(function() {			
		$(this).siblings('a.remove').show();			
		$('#twitter-domain-1').hide();		
		$('#my-resume-1').hide(); 
		$('#applicant-link-1').hide(); 		
		if ( $("select#applicant-links-selection-1 option:selected").val() == "My Resume" ) {	
			$('#my-resume-1').show();		
		} else if ( $("select#applicant-links-selection-1 option:selected").val() == "Twitter" ) {	
			$('#applicant-link-1').show(); 		
			$('#twitter-domain-1').show();		
		}	else if ( $("select#applicant-links-selection-1 option:selected").val() == "Choose..." ) {
			$('#applicant-link-1').hide(); 		
			$('#my-resume-1').hide();					
		}	else {
			$('#applicant-link-1').show(); 		
		}		
	}); 
$('select#applicant-links-selection-2').change(function() {			
		$(this).siblings('a.remove').show();			
		$('#twitter-domain-2').hide();		
		$('#my-resume-2').hide(); 
		$('#applicant-link-2').hide(); 		
		if ( $("select#applicant-links-selection-2 option:selected").val() == "My Resume" ) {	
			$('#my-resume-2').show();		
		} else if ( $("select#applicant-links-selection-2 option:selected").val() == "Twitter" ) {	
			$('#applicant-link-2').show(); 		
			$('#twitter-domain-2').show();		
		}	else if ( $("select#applicant-links-selection-2 option:selected").val() == "Choose..." ) {
			$('#applicant-link-2').hide(); 		
			$('#my-resume-2').hide();					
		}	else {
			$('#applicant-link-2').show(); 		
		}		
	}); 
$('select#applicant-links-selection-3').change(function() {			
		$(this).siblings('a.remove').show();			
		$('#twitter-domain-3').hide();		
		$('#my-resume-3').hide(); 
		$('#applicant-link-3').hide(); 		
		if ( $("select#applicant-links-selection-3 option:selected").val() == "My Resume" ) {	
			$('#my-resume-3').show();		
		} else if ( $("select#applicant-links-selection-3 option:selected").val() == "Twitter" ) {	
			$('#applicant-link-3').show(); 		
			$('#twitter-domain-3').show();		
		}	else if ( $("select#applicant-links-selection-3 option:selected").val() == "Choose..." ) {
			$('#applicant-link-3').hide(); 		
			$('#my-resume-3').hide();		
		}	else {
			$('#applicant-link-3').show(); 		
		}		
	}); 
$('select#applicant-links-selection-4').change(function() {		
		$(this).siblings('a.remove').show();			
		$('#twitter-domain-4').hide();		
		$('#my-resume-4').hide(); 
		$('#applicant-link-4').hide(); 		
		if ( $("select#applicant-links-selection-4 option:selected").val() == "My Resume" ) {	
			$('#my-resume-4').show();		
		} else if ( $("select#applicant-links-selection-4 option:selected").val() == "Twitter" ) {	
			$('#applicant-link-4').show(); 		
			$('#twitter-domain-4').show();		
		}	else if ( $("select#applicant-links-selection-4 option:selected").val() == "Choose..." ) {
			$('#applicant-link-4').hide(); 		
			$('#my-resume-4').hide();		
		}else {
			$('#applicant-link-4').show(); 		
		}		
	}); 

$('a.remove').click(function(){									
		$(this).parent().siblings(".twitter-domain").hide();	//Hide the previous Twitter domain text.
		$(this).siblings("span").hide(); // Hide the containing span.
		$(this).prev("input").val('');	//Make the input blank
		$(this).siblings("select").val('Choose...');	//Reset the previous select box.	
		$(this).siblings(".applicant-link").children("input").val('');
		$(this).hide();	//Reset this Remove link.
		return false;
	}); 
	
$('input:text[value=""]').parent().next('a.remove').hide();

// Show Remove button when My resume is already selected...
$("select").each(function() { 
	if ($(this).val() == "My Resume") { 
		$(this).nextAll("a.remove:first").show(); 
	} 
});		

//
$('select').change(function() {			
	if ( $(this).val() == "My Blog" || $(this).val() == "My Portfolio") {								
				$(this).siblings().children('input').val("URL (ex: www.site.com)");
				$(this).siblings().children('input').css("color","#cdcdcd");
			} 
	$(this).siblings().children('input').focus( function() {
		$(this).val('');
		$(this).css('color','#000');
	});
});


});

