/*var createToolTip = function(element){

 new Ext.ToolTip({
        target: element,
        html: 'A very simple tooltip'
    });
}//end funk*/

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}//end funk



function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}//end funk



function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}//end funk



function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}//end funk



function validateEmpty(fld) {
    var error = "";  
    if (fld.value.length === 0) {
		CreateErrorElement(fld,'Required');
        error = "The required field '"+fld.alt+"' has not been filled in.\n";
    }
	var s= fld.value.replace(/ /g,'');
	if(s.length === 0) {
		CreateErrorElement(fld,'Required');
        error = "The required field '"+fld.alt+"' can't have only spaces or wild cards.\n";
    }
    return error;   
}//end



function validateSelect(fld) {
    var error = "";  
    if (fld.value=="") {
        CreateErrorElement(fld,'Required');
		
		if(fld.name=="app_state")
        	error = "The required field has not been filled in State.\n";
		else
			error = "The required field has not been filled in Country.\n";
    } 
    return error;   
}//end



function trim(s)
	{
	  return s.replace(/^\s+|\s+$/, '');
} //end



function validateEmail(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
    
    if (fld.value === "") {
        CreateErrorElement(fld,'Required');
        error = "You didn't enter an email address.\n";
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        CreateErrorElement(fld,'Invalid');
        error = "Please enter a valid email address.\n";
    } else if (fld.value.match(illegalChars)) {
        CreateErrorElement(fld,'Illegal');
        error = "The email address contains illegal characters.\n";
    }
    return error;
}//end



function getCheckedValue(reason,radioObj) {
	var error = "";
	if(radioObj.checked==undefined){
		
	}else{
		var radioLength = radioObj.length;
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				return radioObj[i].value;
			}
		}
	}
}//end



function validateFile(fld){
	var error = "";
	//start.elements[i].value.length
	/*if(fld.value.length > 50){
			CreateErrorElement(fld,'Illegal');
			error = "The field "+fld.alt+" name '"+fld.value+"' is more than 50 characters long .\n";
	}else*/ if(fld.value){//alert(fld.value.length);
		dots = fld.value.split(".");
		if(dots.length != 2){//alert(dots.length);
			CreateErrorElement(fld,'Illegal');
			error = "The file "+fld.alt+" name to many. '.' in it's name.\n";
		}
		fileType = "." + dots[dots.length-1].toLowerCase();
		if((fileType!=='.doc')&(fileType!=='.docx')&(fileType!=='.pdf')){
			CreateErrorElement(fld,'Illegal');
			error = "The file "+fld.alt+" is not a DOC, DOCX or PDF file.\n";
		}
	}else{
		CreateErrorElement(fld,'Required');
		if(fld.alt.length>0){
			error = "'"+fld.alt+"' - NO FILE SELECTED!\n";
		}else{
			error = "'"+fld.name+"' - NO FILE SELECTED!\n";
		}
	}
	return error;
}//end



function validateUsername(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
    if (fld.value === "") {
        CreateErrorElement(fld,'Required');
        error = "You didn't enter a username.\n";
		
    } else if ((fld.value.length <= 3) || (fld.value.length > 15)) {
        CreateErrorElement(fld,'Invalid');
        error = "The username is the wrong length.\n";
    } else if (illegalChars.test(fld.value)) {
        CreateErrorElement(fld,'Illegal');
        error = "The username contains illegal characters.\n";
    } 
    return error;
}//end



function validatePassword(fld) {
    var error = "";
    var illegalChars = /[\W_]/; // allow only letters and numbers 
 
    if (fld.value === "") {
        CreateErrorElement(fld,'Required');
        error = "You didn't enter a password.\n";
		
    } else if ((fld.value.length <= 3) || (fld.value.length > 15)) {
		CreateErrorElement(fld,'Invalid');
        error = "The password is the wrong length. \n";
        
    } else if (illegalChars.test(fld.value)) {
        CreateErrorElement(fld,'Illegal');
		error = "The password contains illegal characters.\n";
        
    } else if (!((fld.value.search(/(a-z)+/)) && (fld.value.search(/(0-9)+/)))) {
        CreateErrorElement(fld,'Invalid');
		error = "The password must contain at least one numeral.\n";
        
    } 
   return error;
}  //end



function validatePhone(fld) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');     
   if(stripped.length >12){
	   //alert("Phone is to long please keep it less than 12 numbers."); 
	   error = "Phone is to long please keep it less than 12 numbers.\n";
	   CreateErrorElement(fld,'To Long');
	   return error;
   }
   if (fld.value === "") {
	    CreateErrorElement(fld,'Required');
        error = "You didn't enter a "+fld.alt+" number.\n";
    }else{
		//fld.value=stripped;
		fld.value=fld.value;
	}
    return error;
}//end



function validateZip(fld) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');     

   if (fld.value === "") {
	    CreateErrorElement(fld,'Required');
        error = "You didn't enter a ZIP number.\n";
    } else if (isNaN(parseInt(stripped))) {
		CreateErrorElement(fld,'Illegal');
        error = "The ZIP number contains illegal characters.\n";
    } 
    return error;
}//end



/*function validateDate(fld) {
    var error = "";
	var validformat=/^\d{2}\/\d{2}\/\d{4}$/ //Basic check for format validi
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');    
	var dateformat = fld.value;
	var dateformat =dateformat.replace(pattern,"");
alert(dateformat);

   if (fld.value === "") {
	   CreateErrorElement(fld,'Required');
        error = "You didn't enter your DOB.\n";
    } else if (isNaN(parseInt(stripped))) {
		CreateErrorElement(fld,'Illegal');
        error = "Your Date contains illegal characters.\n";
    } else if (!(stripped.length == 8)) {
		CreateErrorElement(fld,'Invalid');
        error = "Your Date is the wrong length. MM\\DD\\YYYY.\n";
    } 
    return error;
}*/

function validateDate(fld){
	var error = "";
	var validformat=/^\d{2}\/\d{2}\/\d{4}$/; //Basic check for format validity
	var returnval=false;
	if (!validformat.test(fld.value)){
		//alert("Invalid Date Format. Please correct and submit again.")
		//alert(validformat.test(fld.value));
		CreateErrorElement(fld,'Invalid');
		error = "Your Date is the wrong format. MM/DD/YYYY.\n";
	}else{ //Detailed check for valid date ranges
		var monthfield=fld.value.split("/")[0];
		var dayfield=fld.value.split("/")[1];
		var yearfield=fld.value.split("/")[2];
		var dayobj = new Date(yearfield, monthfield-1, dayfield);
		if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield)){
			CreateErrorElement(fld,'Invalid');
			var error ="Invalid Day, Month, or Year range detected. Please correct and submit again.";
		}else
			fld.value=monthfield+"/"+dayfield+"/"+yearfield;
	}
	
return error;
}



function CreateErrorElement(fld,txt) {
	if(!document.getElementById(fld.id+'msg')){
	msg = document.createElement('span');
    msg.id = fld.id+'msg';
	msg.style.color='red';
	msg.innerHTML='<small>'+txt+'</small>'; //clear	
	document.getElementById(fld.id).parentNode.appendChild(msg);
	}
}//end funk



function CountWords(fld){	

	var char_count = fld.value.length;
	var fullStr = fld.value + " ";
	var left_trimmedStr = fullStr.replace(/^[^A-Za-z0-9]+/gi, "");
	var cleanedStr = left_trimmedStr.replace(/[^A-Za-z0-9]+/gi, " ");
	var splitString = cleanedStr.split(" ");	
	var word_count = splitString.length -1;//
	//if(fld.name === 'app_research_plan1'){alert(cleanedStr+" -- "+word_count);}
	return word_count;
}



function CreateSaveElement(fld,target) {
	var fld = document.getElementById(fld);
	if(fld){
		if(fld.type=='textarea'){
			msg = document.createElement(fld.type);
		}else{
			msg = document.createElement('input');
			//msg.type=fld.type;
			msg.setAttribute('type',fld.type);
		}
		msg.setAttribute('id',fld.id);
		msg.setAttribute('name',fld.name);
		msg.setAttribute('value',fld.value);
		document.getElementById(target).appendChild(msg);
	}
}//end funk



function download_doc(val,pram) {
	switch(pram)
	{
	case 1:
	  title="ARRS Residents in Radiology";
	  document.getElementById('control_checkbox_controler').checked=true;
	  document.getElementById('more_questions2').style.position='static';
	  break;    
	case 2:
	  title="ARRS Scholars/Bracco Scholars";
	  document.getElementById('control_checkbox_controler').checked=true;
	  document.getElementById('more_questions2').style.position='static';
	  break;
	default:
	  title="other";
	}
			if(val){
				document.getElementById("row"+pram).innerHTML='<div><b><u>'+title+'</u></b>: <br>Download this <a href="download.cfm?pram='+pram+'" ><b><u>File</u></b></a>.  Edit the doc file and upload the saved changs here.<br><input type="file" name="file_more_questions'+pram+'" alt="'+title+'" id="file_more_questions'+pram+'" /></div>';	
			}else{
				document.getElementById("row"+pram).innerHTML='';
			}
}//end funk



function download_doc_v2(pram) {
	
	var selected_rad=document.getElementById('radio1');
	//alert(selected_rad.value);
	switch(pram)
	{
	case 1:
		title="ARRS Residents in Radiology";
	  break;    
	case 2:
		title="ARRS Scholars/Bracco Scholars";
	  break;
	default:
		document.getElementById("row1").innerHTML="";
	}
	if(parseFloat(pram)>0){
		document.getElementById("row1").innerHTML='<div><b><u>'+title+'</u></b>: <br>Download this <a href="download.cfm?pram='+pram+'" ><b><u>File</u></b></a>.  Edit the doc file and upload the saved changs here.<br><input type="file" name="file_more_questions'+pram+'" alt="'+title+'" id="file_more_questions'+pram+'" /></div>';
	}
}//end funk	



function co_investigatorCheck() {
	var  CO_name=document.getElementById('co_investigatorName').value;
	var  CO_role=document.getElementById('co_investigatorRole').value;	
	var  CO_Inst=document.getElementById('co_investigatorInstitution').value;
	document.getElementById('co_investigatorName').value='';	
	document.getElementById('co_investigatorRole').value='';	
	document.getElementById('co_investigatorInstitution').value='';	
	var MaxNumberOf_Co=5;
if((CO_name.length == 0)||(CO_role.length == 0)||(CO_Inst.length == 0)){alert('All three fields must be filled out inorder to add an Investigator.');return false;}
if((CO_name.length > 100)||(CO_role.length > 1000)||(CO_Inst.length > 100)){alert(CO_name.length+' '+CO_role.length+' '+CO_Inst.length+'A field is too big, Name and Institution have a max character count of 100 and role has a max of 1000.');return false;}
	// funk data is set and reset remote val's now start looking for the hidden var packages in a for loop as they can be deleted in any order number order can't be maintaing consitantly start looking low to high keeping that in array because when adding we will add using the lowest number first.
	for(i=0;i<MaxNumberOf_Co;i++){
		if(! (document.getElementById('hidden_package_'+i)) ){
			var li = document.createElement('li');
			li.setAttribute('id', 'hidden_package_' + i);
			li.innerHTML='<a href="#" OnClick="javascript:REMOVE_ME('+i+'); return false" id="del_'+i+'" style="float:right"><img src="../images/Button-Delete-16x16.png" border="0"/></a>';
			li.innerHTML+='<div style="margin-left:275px" class="small_font_black"><input type="hidden" name="CO_name_hidden'+i+'" id="CO_name_hidden'+i+'" value="'+CO_name+'">Name:'+CO_name+'<br><input type="hidden" name="CO_role_hidden'+i+'" id="CO_role_hidden'+i+'" value="'+CO_role+'">Project Role:'+CO_role+'<br><input type="hidden" name="CO_Inst_hidden'+i+'" id="CO_Inst_hidden'+i+'" value="'+CO_Inst+'">Institution:'+CO_Inst+'</div><br>';
			document.getElementById('co_investigatorTarget').appendChild(li);
			i=10000;			//////////////////////////// ESCAPE out of for loop
		}//end if
	}//end for
}//end funk
function co_investigatorCheck_v3(i) {
	var  CO_name=document.getElementById('co_investigatorName').value;
	var  CO_role=document.getElementById('co_investigatorRole').value;	
	var  CO_Inst=document.getElementById('co_investigatorInstitution').value;
	var target=document.getElementById('co_investigatorTarget');
	var var1 =document.createElement('input');
	var var2 =document.createElement('input');
	var var3 =document.createElement('input');
	
	var1.setAttribute("type","hidden");
	var1.setAttribute("name","CO_name_hidden"+i);
	var1.setAttribute("id","CO_name_hidden"+i);
	var1.setAttribute("value",CO_name);
	
	var2.setAttribute("type","hidden");
	var2.setAttribute("name","CO_role_hidden"+i);
	var2.setAttribute("id","CO_role_hidden"+i);
	var2.setAttribute("value",CO_role);
	
	var3.setAttribute("type","hidden");
	var3.setAttribute("name","CO_Inst_hidden"+i);
	var3.setAttribute("id","CO_Inst_hidden"+i);
	var3.setAttribute("value",CO_Inst);
	target.appendChild(var1);
	target.appendChild(var2);
	target.appendChild(var3);
	
}


function co_investigatorCheck_v2() {
	var  CO_name=document.getElementById('co_investigatorName').value;
	var  CO_role=document.getElementById('co_investigatorRole').value;	
	var  CO_Inst=document.getElementById('co_investigatorInstitution').value;
	document.getElementById('co_investigatorName').value='';	
	document.getElementById('co_investigatorRole').value='';	
	document.getElementById('co_investigatorInstitution').value='';	
	
	//alert(+ ' '+document.getElementById('Investigator_z'));
	
	//var clear_the_seed= REMOVE_BEST('Investigator_seed','Investigator_z');
	
	if((CO_name.length == 0)||(CO_role.length == 0)||(CO_name.CO_Inst == 0)){
			alert('All three fields must be filled out inorder to add an Investigator.');return false;}
	else{
		if(document.getElementById('Investigator_seed')){
			var kill_seed=document.getElementById('Investigator_seed').parentNode.removeChild(document.getElementById('Investigator_seed'));
		}
		// funk data is set and reset remote val's now start looking for the hidden var packages in a for loop as they can be deleted in any order number order can't be maintaing consitantly start looking low to high keeping that in array because when adding we will add using the lowest number first.
		var MaxNumberOf_Co=5;
		for(i=0;i<MaxNumberOf_Co;i++){
			if(! (document.getElementById('Investigator_'+i)) ){
				/*var li = document.createElement('li');
				li.setAttribute('id', 'hidden_package_' + i);
				li.innerHTML='<a href="#" OnClick="javascript:REMOVE_ME('+i+'); return false" id="del_'+i+'" style="float:right"><img src="../images/Button-Delete-16x16.png" border="0"/></a>';
				li.innerHTML+='<div style="margin-left:275px" class="small_font_black"><input type="hidden" name="CO_name_hidden'+i+'" id="CO_name_hidden'+i+'" value="'+CO_name+'">Name:'+CO_name+'<br><input type="hidden" name="CO_role_hidden'+i+'" id="CO_role_hidden'+i+'" value="'+CO_role+'">Project Role:'+CO_role+'<br><input type="hidden" name="CO_Inst_hidden'+i+'" id="CO_Inst_hidden'+i+'" value="'+CO_Inst+'">Institution:'+CO_Inst+'</div><br>';
				document.getElementById('co_investigatorTarget').appendChild(li);*/
				var del_button='<a href="#" OnClick="javascript:REMOVE_ME('+i+'); return false" id="del_'+i+'" style="float:right"><img src="../images/Button-Delete-16x16.png" border="0"/></a>';
				
				var tr_start = document.createElement('tr');
				tr_start.setAttribute('id', 'Investigator_' + i);
				document.getElementById('Investigator_z').appendChild(tr_start);
				var tr_mid=document.getElementById('Investigator_'+i);
				
				CO_nametext = document.createTextNode(CO_name);
				td_start = document.createElement("td");
				td_start.appendChild(CO_nametext);
				
				CO_roletext = document.createTextNode(CO_role);
				td_mid = document.createElement("td");
				td_mid.appendChild(CO_roletext);
				
				CO_Insttext = document.createTextNode(CO_Inst);
				td_end = document.createElement("td");
				td_end.appendChild(CO_Insttext);
				
				//CO_del_button = document.createTextNode(del_button);
				td_end_del = document.createElement("td");
				td_end_del.setAttribute('id', 'del_' + i);
				td_end_del.appendChild(CO_del_button);
				
				tr_start.appendChild(td_start);
				tr_start.appendChild(td_mid);
				tr_start.appendChild(td_end);
				tr_start.appendChild(td_end_del);
				
	
				i=10000;			//////////////////////////// ESCAPE out of for loop
			}//end if
		}//end for
	}//else
}//end funk


function push_investigatorCheck(co_investigatorName,co_investigatorRole,co_investigatorInstitution) {	
	var  CO_name=co_investigatorName;
	var  CO_role=co_investigatorRole;	
	var  CO_Inst=co_investigatorInstitution;
	if((CO_name.length == 0)||(CO_role.length == 0)||(CO_name.CO_Inst == 0)){return false;}// we call this and try four or five time weather there is data or not this is to prevent js errors

	var MaxNumberOf_Co=5;
	for(i=0;i<MaxNumberOf_Co;i++){
		if(! (document.getElementById('hidden_package_'+i)) ){
			var li = document.createElement('li');
			li.setAttribute('id', 'hidden_package_' + i);
			li.innerHTML='<a href="#" OnClick="javascript:REMOVE_ME('+i+'); return false" id="del_'+i+'" style="float:right"><img src="../images/Button-Delete-16x16.png" border="0"/></a>';
			li.innerHTML+='<div style="margin-left:275px" class="small_font_black"><input type="hidden" name="CO_name_hidden'+i+'" id="CO_name_hidden'+i+'" value="'+CO_name+'">Name:'+CO_name+'<br><input type="hidden" name="CO_role_hidden'+i+'" id="CO_role_hidden'+i+'" value="'+CO_role+'">Project Role:'+CO_role+'<br><input type="hidden" name="CO_Inst_hidden'+i+'" id="CO_Inst_hidden'+i+'" value="'+CO_Inst+'">Institution:'+CO_Inst+'</div><br>';
			document.getElementById('co_investigatorTarget').appendChild(li);
			i=10000;			//////////////////////////// ESCAPE out of for loop
		}//end if
	}//end for
}//end funk




function co_LoRCheck() {
	var MaxNumberOf_Co=5;
	for(i=0;i<MaxNumberOf_Co;i++){
		if(! (document.getElementById('hidden_file_'+i)) ){
			var li = document.createElement('li');
			li.setAttribute('id', 'hidden_file_' + i);
			li.innerHTML='<a href="#" OnClick="javascript:REMOVE_FILE('+i+'); return false" id="file_del_'+i+'" style="float:right"><img src="../images/Button-Delete-16x16.png" border="0"/></a>';
			li.innerHTML+='<input type="file" accept="doc" size="30" name="app_research_plan6_'+i+'" id="app_research_plan6_'+i+'" alt="Letters of Recommendation" class="button_css" />';
			document.getElementById('LoR_Target').appendChild(li);
			i=10000;			//////////////////////////// ESCAPE out of for loop
		}//end if
	}//end for
}//end funk




function REMOVE_ME(targert) {
	var parent =document.getElementById('co_investigatorTarget');
	var child=document.getElementById('hidden_package_'+targert);
	var throwawayNode = parent.removeChild(child);
	}//end funk
	



function REMOVE_FILE(targert) {
	var parent =document.getElementById('LoR_Target');
	var child=document.getElementById('hidden_file_'+targert);
	var throwawayNode = parent.removeChild(child);
	}//end funk
	

function REMOVE_BETER(targert,parent) {
	var parent =document.getElementById(parent);
	var child=document.getElementById(targert);
	var throwawayNode = parent.removeChild(child);
	}//end funk

function push_pull(target) {
	if(target =='Other'){
		var li = document.createElement('p');
		li.setAttribute('id', 'other_field');
		li.innerHTML ='&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="other_field" class="button_css" size="30" />';
		document.getElementById('other').appendChild(li);
	}else if(document.getElementById('other_field')){
		var parent =document.getElementById('other');
		var child=document.getElementById('other_field');
		var throwawayNode = parent.removeChild(child);
	}
}//end funk	



function login() {
	var reason = "";
	var u =document.getElementById('username');
	var p =document.getElementById('password');
	
	reason += validateUsername(u); 
	reason += validatePassword(p); 
	
	if (reason != "") {
		alert("Some fields need correction:\n" + reason);
		reason="";
	}else{			
		document.form_login.submit();
		// sumbit the postback on postback i query, validate error and kickback to login else remove the content positioning land left
	}
}//end funk




function C_login() {
	var reason = "";
	var c_u =document.getElementById('C_username');
	var c_p =document.getElementById('C_password');
	var c_e =document.getElementById('C_email');
	var c_f=document.getElementById('C_first');
	var c_l=document.getElementById('C_last');	
	
	reason += validateUsername(c_u); 
	reason += validatePassword(c_p);
	reason += validateEmail(c_e); 
	reason += validateEmpty(c_f);
	reason += validateEmpty(c_l); 
	
	if (reason !== "") {
		alert("Some fields need correction:\n" + reason);
		reason="";
	}else{
		document.form_login.submit();		
		// sumbit the postback on postback i query, validate error and kickback to login else remove the content positioning land left
	}
}//end funk	




function validateFormOnSubmit(Application) {
	//alert('validateFormOnSubmit');
	
  var errorID='errormsg';
  var errorClass='error';
  var errorMsg='required';
  var reason = "";
  var lor = LORPDF();
  if(lor==false){
	  return false;
	  }
  var app_5 = app5();
  if(app_5==false){
	  return false;
	  }	
  var app_6 = app6();
  if(app_6==false){
	  return false;
	  }	  	  
  var app_7 = app7();
  if(app_7==false){
	  return false;
	  }	  	  
  var app_8 = app8();
  if(app_8==false){
	  return false;
	  }	  	  
  var app_question = appquestion();
  if(app_question==false){
	  return false;
	  }	  	  

  
  reason += validateFile(Application.letter_of_intent); 
  reason += validateEmpty(Application.Project_Title);  
  	if(CountWords(Application.Project_Title)>100){
		reason += "The required field '"+Application.Project_Title.title+"' has to many words.\n";		 //textarea don't have alt use title
		CreateErrorElement(Application.Project_Title,'Invalid');
		}
  reason += validateEmpty(Application.Investigarors_Name);
  reason += validateEmpty(Application.Investigarors_Degrees);  
  reason += validateEmpty(Application.Training_Dates); 
  	if(CountWords(Application.Training_Dates)>100){
		reason +="The required field '"+Application.Training_Dates.title+"' has to many words.\n";
		CreateErrorElement(Application.Training_Dates,'Invalid');
	}
  reason += validateEmpty(Application.Current_Institution); 
	if(CountWords(Application.Current_Institution)>100){
		reason +="The required field '"+Application.Current_Institution.title+"' has to many words.\n";
		CreateErrorElement(Application.Current_Institution,'Invalid');
		}
  reason += validateEmpty(Application.Institution_Department); 	
	if(Application.Rank_or_Position !== 'Option'){
		reason += validateEmpty(Application.Rank_or_Position); 
	}

  reason += validatePhone(Application.app_phone);
  reason += validateEmail(Application.app_email);   
  reason += validateEmpty(Application.precent_time);  
  
  	reason += validateEmpty(Application.app_research_plan1);  // not emplty and less than X many char
	
	if(CountWords(Application.app_research_plan1)>=302){
		reason +="The required field '"+Application.app_research_plan1.title+"' has to many words.\n";
		CreateErrorElement(Application.app_research_plan1,'Invalid');}
  reason += validateFile(Application.app_research_plan5);
  	//if(Application.app_research_plan6){
	if(Application.app_research_plan6.length > 0){
		reason += validateFile(Application.app_research_plan6);} // if exists test for added LoR
	/*if(Application.app_research_plan6_0.length > 0){
		reason += validateFile(Application.app_research_plan6_0);}
	if(Application.app_research_plan6_1.length > 0){
		reason += validateFile(Application.app_research_plan6_1);}
	if(Application.app_research_plan6_2){
		reason += validateFile(Application.app_research_plan6_2);}
	if(Application.app_research_plan6_3){
		reason += validateFile(Application.app_research_plan6_3);}
	if(Application.app_research_plan6_4){
		reason += validateFile(Application.app_research_plan6_4);}*/
  
  reason += validateFile(Application.app_research_plan7);
  reason += validateFile(Application.app_research_plan8);
  
	if(document.getElementById('file_more_questions')){
		reason += validateFile(Application.file_more_questions);}
/*
	var  CO_name=document.getElementById('co_investigatorName').value;
	var  CO_role=document.getElementById('co_investigatorRole').value;	
	var  CO_Inst=document.getElementById('co_investigatorInstitution').value;
	if(CO_name.length >0 && CO_role.length >0 && CO_Inst.length >0){		
		co_investigatorCheck_v3(1);
	}
*/	


  if(getCheckedValue(reason,Application.elements['app_base_yes_no'])==1){
	  reason += validateEmpty(Application.app_history_name);
	  reason += validateDate(Application.app_history_date);
	  reason += validateEmpty(Application.app_history_title);
	  reason += validateEmpty(Application.app_history_outcome);
	  reason += validateEmpty(Application.app_history_reviewers); 
  }else{
	  Application.app_history_name.style.background = 'White';
	  Application.app_history_date.style.background = 'White';
	  Application.app_history_title.style.background = 'White';
	  Application.app_history_name.style.background = 'White';
	  Application.app_history_outcome.style.background = 'White';
	  Application.app_history_reviewers.style.background = 'White';
  }    
  //if(validateEmpty(Application.co_investigatorName) and validateEmpty(Application.co_investigatorRole) and validateEmpty(Application.co_investigatorInstitution)){co_investigatorCheck()}
  //if(document.getElementById('co_investigatorName').value and document.getElementById('co_investigatorRole').value and document.getElementById('co_investigatorInstitution').value){
	  
  //}co_investigatorCheck();

  if (reason !== "") {
  	document.getElementById('good').value="";
    alert("Some fields need correction:\n" + reason);
	reason="";
	//document.getElementById('content').removeAttribute("class");
	//document.getElementById('Submit').setAttribute("display", "block");
	//document.getElementById('Submit').visible = true;
	document.Application.Submit.disabled = false;
    return false;
  }
  document.getElementById('good').value="good";
 /* document.getElementById('content').setAttribute("display","none");
  document.getElementById('content').disabled = true;
  d=document.createElement("img");
  d.src = "../images/ajax-loader.gif";
  document.getElementById('Master_container').appendChild(d);
  //d= document.getElementById('Master_container').createElement("img");
  
  //='<img src="../images/ajax-loader.gif" />';
  */
  document.Application.action="read_write_test.cfm"
  document.Application.submit();
  document.getElementById('content').removeAttribute("class");
  return true;
}//end




function save_for_push2(){
	var reason = "";
	var start=document.getElementById('Application');
	start.action='step3.cfm';//alert(start.action);
	var msg = document.createElement("input");
	msg.setAttribute('type','hidden');
	msg.setAttribute('id','save');
	msg.setAttribute('name','save');
	msg.setAttribute('value','1');
	start.appendChild(msg);
	var  CO_name=document.getElementById('co_investigatorName').value;
	var  CO_role=document.getElementById('co_investigatorRole').value;	
	var  CO_Inst=document.getElementById('co_investigatorInstitution').value;
	if(CO_name.length >0 && CO_role.length >0 && CO_Inst.length >0){		
		co_investigatorCheck_v3(1);
	}
	for(var i = 0; i < start.length; i++)
	{
		if(start.elements[i].value.length > 0){
			
			if(start.elements[i].type=='text'){
				if(start.elements[i].name =='app_phone')
					reason += validatePhone(start.elements[i]);
				else if(start.elements[i].name =='app_email')
					reason += validateEmail(start.elements[i]);
				else if(start.elements[i].name =='app_history_date')
					reason += validateDate(start.elements[i]);
				else
					reason += validateEmpty(start.elements[i]);
			}else if(start.elements[i].type=='textarea'){
				if(start.elements[i].name =='app_research_plan1'){
					if(CountWords(start.elements[i])>=302){
					reason +="The required field '"+start.elements[i].title+"' has to many words.\n";
					CreateErrorElement(start.elements[i],'Invalid');}
				}else if(start.elements[i].name =='app_history_reviewers'){
					if(CountWords(start.elements[i])>1000){
					reason +="The required field '"+start.elements[i].title+"' has to many words.\n";
					CreateErrorElement(start.elements[i],'Invalid');}
				}else{
					if(CountWords(start.elements[i])>100){
					reason +="The required field '"+start.elements[i].title+"' has to many words.\n";
					CreateErrorElement(start.elements[i],'Invalid');}
				}
			}else if(start.elements[i].type=='file'){
				reason += validateFile(start.elements[i]);
			}
			 
		}
	} 
	
	if(reason == ""){
		document.Application.submit();
	}else{
		alert(reason);
	}
	//document.Application.Submit.click();
}



function save_for_push(){
	document.getElementById('save_target').innerHTML='';//clear save for multi click
	if( CountWords(document.getElementById('Project_Title'))>100 && document.getElementById('Project_Title').value.length!=0 ){
		CreateErrorElement(document.getElementById('Project_Title'),'Invalid');
		return false;}
	CreateSaveElement('Project_Title','save_target');
	CreateSaveElement('Investigarors_Name','save_target');
	CreateSaveElement('Investigarors_Degrees','save_target');
	
	CreateSaveElement('Training_Dates','save_target');
	if( CountWords(document.getElementById('Current_Institution'))>100 && document.getElementById('Current_Institution').value.length!=0 ){
		CreateErrorElement(document.getElementById('Current_Institution'),'Invalid');
		return false;}
	CreateSaveElement('Current_Institution','save_target');
	CreateSaveElement('Institution_Department','save_target');
	
	if( validatePhone(document.getElementById('app_phone')) && document.getElementById('app_phone').value.length!=0 ){
		CreateErrorElement(document.getElementById('app_phone'),'Invalid');
		return false;}
	var stripped = document.getElementById('app_phone').value;
	var stripped =stripped.replace(/[\(\)\.\-\ ]/g, ''); 
	document.getElementById('app_phone').value=stripped;
	CreateSaveElement('app_phone','save_target');
	
	
	if( validateEmail(document.getElementById('app_email')) && document.getElementById('app_email').value.length!=0 ){
		CreateErrorElement(document.getElementById('app_email'),'Invalid');
		return false;}
	CreateSaveElement('app_email','save_target');
	
	
	CreateSaveElement('precent_time','save_target');


	
	if( CountWords(document.getElementById('app_research_plan1'))>=302 && document.getElementById('app_research_plan1').value.length!=0 ){
		CreateErrorElement(document.getElementById('app_research_plan1'),'Invalid');
		return false;}
	CreateSaveElement('app_research_plan1','save_target');
	
		
	
	if(document.getElementById('CO_name_hidden0')){
		CreateSaveElement('CO_name_hidden0','save_target');
		CreateSaveElement('CO_role_hidden0','save_target');
		CreateSaveElement('CO_Inst_hidden0','save_target');
	}
	if(document.getElementById('CO_name_hidden1')){
		CreateSaveElement('CO_name_hidden1','save_target');
		CreateSaveElement('CO_role_hidden1','save_target');
		CreateSaveElement('CO_Inst_hidden1','save_target');
	}
	if(document.getElementById('CO_name_hidden2')){
		CreateSaveElement('CO_name_hidden2','save_target');
		CreateSaveElement('CO_role_hidden2','save_target');
		CreateSaveElement('CO_Inst_hidden2','save_target');
	}
	if(document.getElementById('CO_name_hidden3')){
		CreateSaveElement('CO_name_hidden3','save_target');
		CreateSaveElement('CO_role_hidden3','save_target');
		CreateSaveElement('CO_Inst_hidden3','save_target');
	}
	if(document.getElementById('CO_name_hidden4')){
		CreateSaveElement('CO_name_hidden4','save_target');
		CreateSaveElement('CO_role_hidden4','save_target');
		CreateSaveElement('CO_Inst_hidden4','save_target');
	}
	if(document.getElementById('letter_of_intent')&&document.getElementById('letter_of_intent').value.length!=0&&document.getElementById('letter_of_intent').type=='text'){
		CreateSaveElement('letter_of_intent','save_target');
	}else{
		var pclone=document.getElementById("letter_of_intent").cloneNode(true);//alert('true '+pclone.id);
		document.getElementById('save_target').appendChild(pclone);
		
	}
	if(document.getElementById('app_research_plan5')&&document.getElementById('app_research_plan5').value.length!=0&&document.getElementById('app_research_plan5').type=='text'){CreateSaveElement('app_research_plan5','save_target');}
		else{p=document.getElementById('app_research_plan5');pclone=p.cloneNode(true);document.getElementById('save_target').appendChild(pclone);}
	if(document.getElementById('app_research_plan6')&&document.getElementById('app_research_plan6').value.length!=0&&document.getElementById('app_research_plan6').type=='text'){CreateSaveElement('app_research_plan6','save_target');}
		else{
			if(document.getElementById('app_research_plan6')){p=document.getElementById('app_research_plan6');pclone=p.cloneNode(true);document.getElementById('save_target').appendChild(pclone);}}
	if(document.getElementById('app_research_plan6_0')&&document.getElementById('app_research_plan6_0').value.length!=0&&document.getElementById('app_research_plan6_0').type=='text'){CreateSaveElement('app_research_plan6_0','save_target');}
		else{
			if(document.getElementById('app_research_plan6_0')){p=document.getElementById('app_research_plan6_0');pclone=p.cloneNode(true);document.getElementById('save_target').appendChild(pclone);}}
	if(document.getElementById('app_research_plan6_1')&&document.getElementById('app_research_plan6_1').value.length!=0&&document.getElementById('app_research_plan6_1').type=='text'){CreateSaveElement('app_research_plan6_1','save_target');}
		else{
			if(document.getElementById('app_research_plan6_1')){p=document.getElementById('app_research_plan6_1');pclone=p.cloneNode(true);document.getElementById('save_target').appendChild(pclone);}}
	if(document.getElementById('app_research_plan6_2')&&document.getElementById('app_research_plan6_2').value.length!=0&&document.getElementById('app_research_plan6_2').type=='text'){CreateSaveElement('app_research_plan6_2','save_target');}
		else{
			if(document.getElementById('app_research_plan6_2')){p=document.getElementById('app_research_plan6_2');pclone=p.cloneNode(true);document.getElementById('save_target').appendChild(pclone);}}
	if(document.getElementById('app_research_plan6_3')&&document.getElementById('app_research_plan6_3').value.length!=0&&document.getElementById('app_research_plan6_3').type=='text'){CreateSaveElement('app_research_plan6_3','save_target');}
		else{
			if(document.getElementById('app_research_plan6_3')){p=document.getElementById('app_research_plan6_3');pclone=p.cloneNode(true);document.getElementById('save_target').appendChild(pclone);}}
	if(document.getElementById('app_research_plan6_4')&&document.getElementById('app_research_plan6_4').value.length!=0&&document.getElementById('app_research_plan6_4').type=='text'){CreateSaveElement('app_research_plan6_4','save_target');}
		else{
			if(document.getElementById('app_research_plan6_4')){p=document.getElementById('app_research_plan6_4');pclone=p.cloneNode(true);document.getElementById('save_target').appendChild(pclone);}}
	if(document.getElementById('app_research_plan7')&&document.getElementById('app_research_plan7').value.length!=0&&document.getElementById('app_research_plan7').type=='text'){CreateSaveElement('app_research_plan7','save_target');}
		else{p=document.getElementById('app_research_plan7');pclone=p.cloneNode(true);document.getElementById('save_target').appendChild(pclone);}
	if(document.getElementById('app_research_plan8')&&document.getElementById('app_research_plan8').value.length!=0&&document.getElementById('app_research_plan8').type=='text'){CreateSaveElement('app_research_plan8','save_target');}
		else{p=document.getElementById('app_research_plan8');pclone=p.cloneNode(true);document.getElementById('save_target').appendChild(pclone);}



	if(document.getElementById('Rank_or_Position')){
		CreateSaveElement('Rank_or_Position','save_target');
	}
	
	if(document.getElementById('app_base_yes_no')){
		CreateSaveElement('app_base_yes_no','save_target');
	}
	if(document.getElementById('app_history_name')){
		CreateSaveElement('app_history_name','save_target');
	}
	if(document.getElementById('app_history_date')){
		CreateSaveElement('app_history_date','save_target');
	}
	if(document.getElementById('app_history_title')){
		CreateSaveElement('app_history_title','save_target');
	}
	if(document.getElementById('app_history_outcome')){
		CreateSaveElement('app_history_outcome','save_target');
	}
	if(document.getElementById('app_history_reviewers')){
		CreateSaveElement('app_history_reviewers','save_target');
	}
	if(document.getElementById('app_history_reviewers')){
		CreateSaveElement('app_history_reviewers','save_target');
	}
	
	var elem = document.getElementById('save')
	var temp='';
	for(var i = 0; i < elem.length; i++)
	{
		temp=temp+elem.elements[i].name+' /'+elem.elements[i].value+'</n>';
	}
	//alert(temp);
	
	var save_form=document.getElementById('save');
}




function mid_area_check(){
    var reason = "";
	radios = document.getElementsByName('radio1');

	for (i = 0; i < radios.length; i++) {
            if (radios[i].checked){
				//alert('true');
				document.form_socity.submit();
				return true;
			}
        }
	CreateErrorElement(document.getElementById('row1'),'Please select a society')
	
}




function mid_area_push_v2(idx,x){
	var target=document.getElementsByName("radio1");
	for(i=0; i <target.length; i++){
		//alert('v'+target[i].value+'id: '+target[i].id+' -'+idx+'-');
		if(target[i].value == idx){
			target[i].checked=true;
			if(document.getElementById('socity_radio')){
				document.getElementById('socity_radio').value=x;
			}
		}
	}
return true;
}




function mid_area_push_v3(idx){
	var start=document.getElementById('form_socity');
	for(var i = 0; i < start.length; i++)
	{
	//alert('id '+form_socity.elements[i].name +' '+form_socity.elements[i].value);
	} 
return false;
}




function mid_area_push(idx,namex){
var set_val='';
var set_target='';
switch(namex)
{
	case 'ARRS Residents in Radiology':
		set_val='checkbox1';
		set_target='radio1';
	 break;    
	case 'ARRS Scholars/Bracco Scholars':
		set_val='checkbox2';
		set_target='radio2';
	 break;    
	case 'AUR/GE-Radiology Research Academic Fellowship (GERRAF) Program':
		set_val='checkbox3';
		set_target='radio3';
	 break;    
	case 'RSNA Research Scholar Grant':
		set_val='checkbox4';
		set_target='radio4';
	break;
	case 'SPR Research and Education Foundation Seed Grant':
		set_val='checkbox13';
		set_target='radio13';
	break;
	default:
		set_val='checkbox4';
		set_target='radio4';
}
if(document.getElementById('socity_radio')){
		document.getElementById('socity_radio').value=idx;
	}
	document.getElementById(set_target).checked=true;
	return true;
}



function find_destroy_create_w_button(id_x,content_x){
	
	var value_set=content_x;
	var find_parent=document.getElementById(id_x).parentNode;
		find_parent.removeChild(document.getElementById(id_x));
	var input_create= document.createElement("input");
		input_create.setAttribute("type","text");
		input_create.setAttribute("class","button_css");
		input_create.setAttribute("id",id_x);
		input_create.setAttribute("name",id_x);
		input_create.setAttribute("value",content_x);
		input_create.setAttribute('readOnly','true');
		input_create.setAttribute('size','30');

	find_parent.appendChild(input_create);
	var input_create_del= document.createElement("span");
		input_create_del.id=id_x+"-del";
		input_create_del.name=id_x+"-del";
		input_create_del.style.float="right";
		input_create_del.innerHTML='<a href="#" OnClick="javascript:find_destroy_create_input_type_file(\''+id_x+'\'); return false" id="'+id_x+'-delete" style="float:right"><img src="../images/Button-Close-16x16.png" border="0"/></a>';
	find_parent.appendChild(input_create_del);
	
	//alert(document.getElementById(id_x).value);
	return true;
}

function find_destroy_create_input_type_file(id_x){//alert(id_x+'test');
	var find_parent=document.getElementById(id_x).parentNode;
		find_parent.removeChild(document.getElementById(id_x));
		find_parent.removeChild(document.getElementById(id_x+"-del"));
	var input_create= document.createElement("input");
		input_create.setAttribute("type","file");
		input_create.setAttribute("class","button_css");
		input_create.setAttribute("id",id_x);
		input_create.setAttribute("name",id_x);
		input_create.setAttribute("alt",id_x);
		input_create.setAttribute("size","30");
		input_create.name=id_x;
	find_parent.appendChild(input_create);
	var input_create_del= document.createElement("span");
		input_create_del.id=id_x+"-del";
		input_create_del.name=id_x+"-del";
		input_create_del.style.float="right";
		var last_num=id_x.length-1;
		var last_char=id_x.charAt(last_num);//charAt()
		input_create_del.innerHTML='<a href="#" OnClick="javascript:REMOVE_FILE('+last_char+'); return false"  id="file_del_'+last_char+'" style="float:right"><img src="../images/Button-Delete-16x16.png" border="0"/></a>';
	find_parent.appendChild(input_create_del);
}
function masking(){
	//alert('starting');
	//document.getElementById("content").setAttribute("class","loading-invisible");
	var loading=document.createElement('img');
	loading.setAttribute('id','pic');
	loading.setAttribute('src','..images/ajax-loader.gif');
	loading.setAttribute('width',208);
	loading.setAttribute('height',13);
	document.getElementById('content').appendChild(loading);
}
function masking_v2(){
	var x=window.confirm("It will take a few minutes to convert document, please don't interrupt the process until it is done.")
	if (x){
		document.Application.Submit.disabled = true;
		document.getElementById('content').disabled = true;
		//document.getElementById('content').setAttribute("display","none");
		//document.getElementById('content').setAttribute("visibility","hidden");
		document.getElementById('content').setAttribute("style","visibility:hidden");
		document.getElementById('content').setAttribute("style","display:none");
		d=document.createElement("img");
		d.src = "../images/ajax-loader.gif";
		newpara = document.createElement("p");
		sometext = document.createTextNode("It will take a few minutes to convert document, please don't interrupt the process until it is done.");
		newpara.appendChild(sometext);
		existingobject = document.getElementById("Master_container");		
		existingobject.appendChild(d);
		existingobject.appendChild(newpara);
	}
}
/*
function getdata(what,where) { // get data from source (what)
try {
xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) { }

document.getElementById(where).innerHTML ="<center><img src='img/indicator.gif'></center>";
// we are defining the destination DIV id, must be stored in global variable (ajaxdestination)
ajaxdestination=where;
xmlhttp.onreadystatechange = triggered; // when request finished, call the function to put result to destination DIV
xmlhttp.open("GET", what);
xmlhttp.send(null);
return false;
}

function triggered() { // put data returned by requested URL to selected DIV
if (xmlhttp.readyState == 4) if (xmlhttp.status == 200)
document.getElementById(ajaxdestination).innerHTML =xmlhttp.responseText;
}
*/

<!--- Adding a bunch of pdf checking functions for step3.cfm page. --->

   
    function ValidateLOR(form){
        
        if(form.letter_of_intent.value.length == 0){
            alert("Please select a filename to upload.");
            form.letter_of_intent.focus();
            return false;
            }
            
        if(form.letter_of_intent.value.length > 0){
            extArray = new Array('doc','docx','pdf');	
            file = form.letter_of_intent.value;
            
            filearray = file.split(".");
            ext = filearray[filearray.length -1].toLowerCase();
            //alert(ext);
            allowAsciiCheck = false;
            allowSubmit = false;
            badFile = false;
            badAscii = false;
                for (var i = 0; i < extArray.length; i++) 
                    {
                    if (extArray[i] == ext) { allowAsciiCheck = true;  break; }
                    //else {badFile =true;}
                    }
                    
                if (allowAsciiCheck){
                    allowSubmit = true;
                            for(i=0;i<form.letter_of_intent.value.length;i++){
                                if (form.letter_of_intent.value.charCodeAt(i) > 126){
                                    allowSubmit = false;
                                    badAscii = true;
                                }//end if 
                            }//end for
                }	
                else
                {
                    badFile = true;
                }	
                                    
                
                if (allowSubmit) 
                {
                <!--- document.postResume.client_filename.value = clientfile; --->
                //return true;
                }
                else
                {
                if (badFile){
                alert("Please only upload files that end in types:\n\n" 
                + (extArray.join("  ")) + "\n\nPlease select a new "
                + "file to upload and submit again.");
                form.letter_of_intent.focus();
                return false;
                }
                
                if(badAscii){
                alert("ALERT: Your file name contains unsupported characters!\n\n" 
                + "Please rename your file before you attempt to upload it. \n"
                + "Valid characters are A-Z and 0-9");
                form.letter_of_intent.focus();
                return false;
                
                }
                
                }			
            }		
    
        return true;
    }

function LORPDF() {
	var extension = new Array();
	
	var fieldvalue = document.Application.letter_of_intent.value;
	
	extension[0] = ".pdf";
	extension[1] = ".pdf";
	
	var thisext = fieldvalue.substr(fieldvalue.lastIndexOf('.'));
	for(var i = 0; i < extension.length; i++) {
		if(thisext == extension[i]) { return true; }
		}
	alert("Your Cover Letter/Letter of Intent does not appear to be a valid .pdf file. Please select a new file.");
	return false;
	}
	
	

function app5() {
	var extension = new Array();
	
	var fieldvalue = document.Application.app_research_plan5.value;
	
	extension[0] = ".pdf";
	extension[1] = ".pdf";
	
	var thisext = fieldvalue.substr(fieldvalue.lastIndexOf('.'));
	for(var i = 0; i < extension.length; i++) {
		if(thisext == extension[i]) { return true; }
		}
	alert("Your Detailed Plan does not appear to be a valid .pdf file. Please select a new file.");
	return false;
	}

function app6() {
	var extension = new Array();
	
	var fieldvalue = document.Application.app_research_plan6.value;
	
	extension[0] = ".pdf";
	extension[1] = ".pdf";
	
	var thisext = fieldvalue.substr(fieldvalue.lastIndexOf('.'));
	for(var i = 0; i < extension.length; i++) {
		if(thisext == extension[i]) { return true; }
		}
	alert("Your Letters of Recommendation does not appear to be a valid .pdf file. Please select a new file.");
	return false;
	}

function app7() {
	var extension = new Array();
	
	var fieldvalue = document.Application.app_research_plan7.value;
	
	extension[0] = ".pdf";
	extension[1] = ".pdf";
	
	var thisext = fieldvalue.substr(fieldvalue.lastIndexOf('.'));
	for(var i = 0; i < extension.length; i++) {
		if(thisext == extension[i]) { return true; }
		}
	alert("Your Budget does not appear to be a valid .pdf file. Please select a new file.");
	return false;
	}

function app8() {
	var extension = new Array();
	
	var fieldvalue = document.Application.app_research_plan8.value;
	
	extension[0] = ".pdf";
	extension[1] = ".pdf";
	
	var thisext = fieldvalue.substr(fieldvalue.lastIndexOf('.'));
	for(var i = 0; i < extension.length; i++) {
		if(thisext == extension[i]) { return true; }
		}
	alert("Your Curriculum Vitae does not appear to be a valid .pdf file. Please select a new file.");
	return false;
	}

function appquestion() {
	var extension = new Array();
	
	var fieldvalue = document.Application.file_more_questions.value;
	
	extension[0] = ".pdf";
	extension[1] = ".pdf";
	
	var thisext = fieldvalue.substr(fieldvalue.lastIndexOf('.'));
	for(var i = 0; i < extension.length; i++) {
		if(thisext == extension[i]) { return true; }
		}
	alert("Your supplemental material does not appear to be a valid .pdf file. Please select a new file.");
	return false;
	}	
