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;
}
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];}
}
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;
}

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];}}
}

var sel_row; // contains the id of the highlighted row
function select_row(id)
{
// set id to number to highlight
// description_id is id to hide
// tr_id

    var img = 'listing_image_'+id;
    var desc = 'description_'+id;
    var row = 'tr_'+id;
    document.getElementById(img).src='images/collapse_advanced.gif';
    document.getElementById(desc).className='visibleRow';
    document.getElementById(row).className='selectedRow';

    if (sel_row)
    {
        var img = 'listing_image_'+sel_row;
        desc = 'description_'+sel_row;
        row = 'tr_'+sel_row;
        document.getElementById(img).src='images/expand_advanced.gif';
        document.getElementById(desc).className = 'hiddenRow';
        document.getElementById(row).className='listingCompany';
        sel_row = sel_row == id ? false : id;
	}
        else
        {
    sel_row = id;
    }
}

function setPointer(theRow, thePointerColor) {
	if (typeof(theRow.style) == 'undefined' || typeof(theRow.cells) == 'undefined') {
		return false;
	}
	var row_cells_cnt = theRow.cells.length;
	//row_cells_cnt--;
	for (var c = 1; c < row_cells_cnt; c++) {
		theRow.cells[c].bgColor = thePointerColor;
	}
	return true;
}

function selectRow(theTable, theRow) {
	// Assign the passed table a handler...
    var tableList = document.getElementById(theTable);
	var chosenRow = "tr_"+theRow;

	// If a previous row was highlighted, de-highlight before continuing...
	if (document.forms.listingsDisplay.lastRow.value != "") {
		var lastRow = document.forms.listingsDisplay.lastRow.value;
		var cell_count = tableList.rows[lastRow].cells.length;

		// Step through each cell of the row and set it's class back to default...
		for (j=0; j < cell_count; j++) {
			tableList.rows[lastRow].cells[j].className = 'listCell';
		}

		// Reset the title/company links...
		var titleLink = "title_"+theRow;
		var setLink = document.getElementById(titleLink);
		setLink.className = 'listingTitle';
		var companyLink = "company_"+theRow;
		var setLink = document.getElementById(companyLink);
		setLink.className = 'listingCompany';
	}

	// Step through all the rows looking for the specific row to highlight...
	var row_count = tableList.rows.length;
	for (i=0; i < row_count; i++) {

		// Found the row we need to highlight...
		if (tableList.rows[i].id == chosenRow) {

			// Store this row's ID in the form container...
			document.forms.listingsDisplay.lastRow.value=chosenRow;

			// Go through each cell of the row and apply the appropriate style class...
			var cell_count = tableList.rows[i].cells.length;
			for (j = 1; j < cell_count; j++) {
				tableList.rows[chosenRow].cells[j].className = 'selectedCell';
			}

			// Highlight the title/company links...
			var titleLink = "title_"+theRow;
			var setLink = document.getElementById(titleLink);
			setLink.className = 'selectedTitle';
			var companyLink = "company_"+theRow;
			var setLink = document.getElementById(companyLink);
			setLink.className = 'selectedCompany';

		}
	}
    return true;
}

function forgotPword(EMAIL) {
        if (EMAIL && (EMAIL != "Email Address")) {
                document.location.href='/forgot_pwd.php?login_email=' + EMAIL;
        } else {
                alert('Please enter your email address.');
        }
}

function splashSeekerLogin() {
	if ((document.forms.login_form.login_email.value != '') && (document.forms.login_form.login_email.value != 'Email Address') && (document.forms.login_form.login_pass.value != '')) {
		document.location.href='/listings.php?login_email=' + document.forms.login_form.login_email.value + '&login_pass=' + document.forms.login_form.login_pass.value;
	} else { 
		alert("Please enter the email address you registered your Job Seeker account with and a valid password.");
	}
}

function splashSearch() {
  // need to change target to appropriate site...
  var theForm = document.getElementById('splash_search_form');
  var tgt = theForm.search_scope; // array of radio objects
  for (var i=0; i<tgt.length;i++)
  {
     if (tgt[i].checked)
     {
	var val = tgt[i].value;
	break;
     }
  }
  switch (val) {
    case 'resumes':
	// change this later...
	alert ('Resume search for member companies coming soon! For now, log into the members site and search from there.');
	theForm.action = 'http://member.seattlejobs.org/resume_search.php';
	theForm.keywords.value = theForm.keyword.value; //copy over to param for members site...
	return true;
	break;
      default:
	// go to default URL...
	return true;
  }
}

function deleteSeeker() {
  var frm=document.getElementById('signupForm');
  if (confirm('Are you sure you want to completely delete your account?'))
  {
    frm.delete_seeker.value=true;
    frm.submit();
  }
}

function deleteResume() {
  var frm=document.getElementById('signupForm');
   if (confirm('Are you sure you want to delete your resume?'))
  {
    frm.delete_resume.value = true;
    frm.submit();
  }
}

function CountWords (this_field, show_word_count, show_char_count) {
if (show_word_count == null) {
show_word_count = true;
}
if (show_char_count == null) {
show_char_count = false;
}
var char_count = this_field.value.length;
var fullStr = this_field.value + " ";
var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
var splitString = cleanedStr.split(" ");
var word_count = splitString.length -1;
if (fullStr.length <2) {
word_count = 0;
}
if (word_count == 1) {
wordOrWords = " word";
}
else {
wordOrWords = " words";
}
if (char_count == 1) {
charOrChars = " character";
} else {
charOrChars = " characters";
}
if (show_word_count & show_char_count) {
alert ("Word Count:\n" + "    " + word_count + wordOrWords + "\n" + "    " + char_count + charOrChars);
}
else {
if (show_word_count) {
alert ("Word Count:  " + word_count + wordOrWords);
}
else {
if (show_char_count) {
alert ("Character Count:  " + char_count + charOrChars);
      }
   }
}
return word_count;
}
