jQuery(document).ready(function(){  

	//IF the querystring subject has a value of Employment
	var currentURL = window.location.href+'';

	if(currentURL.indexOf('subject=Employment') >= 0){
	
		//Adjust top text
		jQuery(".postEntry p").first().html('Our website tends to raise a few questions. Like, "Interested in hiring me?" and "How can I join your team?" Please contact us here with any questions of your own.');

		//Select the proper item
		jQuery("#emailSubject option[value=Employment]").attr("selected",true);
		
		//Show the resume upload box
		showResumeUpload();
		jQuery("#btnSend").click(function(){
								 		var selected = jQuery("#emailSubject :selected");    
		
										//If we've selected the Employment Option
										if(selected.text() == "Employment"){
											
												if(jQuery("#resumeUpload").val()=='')
												{
													var span = jQuery(".resumeUpload")[0];
													//span.appendText('&lt;span class="wpcf7-not-valid-tip"&gt;Please fill the required field.&lt;/span&gt;');
													
													span.innerHTML = span.innerHTML+'<span class="wpcf7-not-valid-tip" onmouseover="this.style.display=\'none\';">Please fill the required field.</span>';
													//jQuery(".resumeUpload").append('<span class="wpcf7-not-valid-tip">Please fill the required field.</span>');
													return false;
												}
												return true;
										}
                                                                                    
                                                                                return false;
								 });
	}
	
	//Displays resume upload box
	function showResumeUpload(){
	
		//If the div is hidden
		if(jQuery("#resumeDiv").is(":hidden")){
		
			//Slide it down
			jQuery("#resumeDiv").slideDown();
		}
	}
	
	//Hide the resume upload
	function hideResumeUpload(){
	
		//If the div is not hidden
		if(!jQuery("#resumeDiv").is(":hidden")){
		
			//Slide it up
			jQuery("#resumeDiv").slideUp();
		}
	}
	
	//If the dropdown changes

	jQuery("#emailSubject").change(function(){
	
		//Get the selected item
		var selected = jQuery("#emailSubject :selected");    
		
		//If we've selected the Employment Option
		
		if(selected.text() == "Employment"){

			//Show the resume upload
			showResumeUpload();
                       //jQuery("#emailRecipient").val("Jan").attr('selected',true);
                       //jQuery("#emailRecipient option[value=Sharon]").attr("selected",false);
                        
		}else{
			//Hide the resume upload
			hideResumeUpload();
                       //jQuery("#emailRecipient").val("Sharon").attr('selected',true);
                       //jQuery("#emailRecipient option[value=Sharon]").click();//.attr("selected","selected");
//                       jQuery("#emailRecipient option[value=Jan]").attr("selected",false);
		}
	});
	
});
