function otherIsSelected(){
	var otherField = document.getElementById('other_field');
	var selector = document.getElementById('inquiry_nature');
	if(selector.options[5].selected){
		otherField.className = 'visible';
	}else{
		otherField.className = 'hidden';
	}
}

function toggleVisibleWP(target){
	var block = document.getElementById(target);
	var button = document.getElementById(target + '_image');
	if(block.className == "visible"){
		block.className = "hidden";
		button.src = "/images/btn_get_this_paper.gif";
		button.alt = "Get This Paper";
	}else{
		block.className = "visible";
		button.src = "/images/btn_close.gif";
		button.alt = "Close White Paper";
	}
}
function toggleVisibleNews(target){
	var block = document.getElementById(target);
	var button = document.getElementById(target + '_image');
	if(block.className == "visible"){
		block.className = "hidden";
		button.src = "/images/btn_read_more.gif";
		button.alt = "Read More";
	}else{
		block.className = "visible";
		button.src = "/images/btn_close.gif";
		button.alt = "Close Story";
	}
}

function setJid(j_id) {

	document.application.jid.value = j_id;

	classChange('descript', 'DisplayBlock');
	
}	

 function classChange(element, newclass) {
 	 
 	 var elementid;
 
 	 if (document.getElementById) {
 	 	elementid = document.getElementById(element);
 	 } else {
 	 	elementid = document.all[element];
 	 }
 	 elementid.className = newclass;
 	 return;
 }
 
var filext = /^.+\.(DOC|TXT|PDF|HTML)$/i; //allowable resume formats
 

function checkExt(fpath, fnum) {


      	if( ( fpath.search(filext) != -1 ) || ( fpath == "" ) || ( fpath == " " ) ) {

      		//alert("Acceptable ext for file # " + fnum);

          	var rform = eval("document.application.res" + fnum);
 	        rform.value = "Y";
 	        
 	        //alert("set " + rform + " to " + rform.value + " .");
      		
     	} else {
          	alert("DOC, TXT, PDF and HTML extensions only!");
          	
          	var rform = eval("document.application.res" + fnum);
 	        rform.value = "N";
		//alert("Set " + rform + " to " + rform.value + " .");
          	//pathField.value = ""; browser security prevents
     	}
     
}    

function toggleApplicationForm(){
	var block = document.getElementById('application');
	var button = document.getElementById('apply');
	if(block.className == "visible"){
		block.className = "hidden";
		button.className = "visible";
	}else{
		block.className = "visible";
		button.className = "hidden";
	}
}

var qsParm = new Array();
function qs() {
	var query = window.location.search.substring(1);
	var parms = query.split('&');
	for (var i=0; i<parms.length; i++) {
	var pos = parms[i].indexOf('=');
		if (pos > 0) {
		var key = parms[i].substring(0,pos);
		var val = parms[i].substring(pos+1);
		qsParm[key] = val;
		}
	}
}
function openItem(target){
	if(target != null){
		toggleVisibleNews(target);	    
	}
}
/*function selectBoxItem(selector, option) {
	if(option != null){
		var selObj = document.getElementById(selector);
		if(selObj.options[option]){
			selObj.options[option].selected = document.getElementById('in_' + option).checked;
		}
	}
	otherIsSelected();
}*/
function selectBoxItem(selector, option)
{
	var selObj = document.getElementById(selector);
	selObj.selectedIndex = option;
}

function checkResForm() {


if( (document.application.fname.value == '') || (document.application.fname.value == ' ') ){
	alert("Please enter a valid first name.");
	document.application.fname.focus();
	return false;
}

if( (document.application.lname.value == '') || (document.application.lname.value == ' ') ){
	alert("Please enter a valid last name.");
	document.application.lname.focus();
	return false;
}

if (emailValid(document.application.email.value) == 0) {
	alert("Please enter a valid email.");
	document.application.email.focus();
	return false;
}

if( (document.application.phone.value == '') || (document.application.phone.value == ' ') ){
	alert("Please enter a valid phone #.");
	document.application.phone.focus();
	return false;
}

if(document.application.res1.value != 'Y') {
	alert("Please enter a valid file format for file #1.");
	document.application.file1.focus();
	return false;
}

if(document.application.res2.value != 'Y') {
	alert("Please enter a valid file format for file #2.");
	document.application.file2.focus();
	return false;
}

if(document.application.res3.value != 'Y') {
	alert("Please enter a valid file format for file #3.");
	document.application.file3.focus();
	return false;
}


return true;

} 
  
  
  
function emailValid (email) {

invalidChars = " /:,;`"

if (email == "") {						// cannot be empty
	return 0;
}

for (i=0; i<invalidChars.length; i++) {	// any invalid characters?
	

	badChar = invalidChars.charAt(i);
   	if (email.indexOf(badChar,0) > -1) {
   		return false;
   	}
}

atPos = email.indexOf("@",1);			// there must be one "@" symbol
if (atPos == -1) {
	return 0;
}
if (email.indexOf("@",atPos+1) != -1) {	// and only one "@" symbol
	return 0;
}
periodPos = email.indexOf(".",atPos);
if (periodPos == -1) {					// and at least one "." after the "@"
	return 0;
}
if (periodPos+3 > email.length)	{		// must be at least 2 characters after the "."
	return 0;
}
return 1;
   
}