/**
*
* A simple method to complete our e-mail addresses and prevent harvesting.
*
* Loops all anchors in the document and appends the domain name
* to the href and inner element of the tag if mailto: is included in the href.
*
* This is very specific to our site and is only meant to confuse rather 
* simple harvesters. 
*
*/

function complete_emails() {

  prefix = 'mailto:';
  suffix = '@trsproducts.com'

  anchors = document.getElementsByTagName('a');
  anchorlen = anchors.length;

  if(!anchorlen)
    return;

  for (i=0;i<anchorlen;i++) {
    if(!anchors[i].href)
      continue;
    
    s = new String(anchors[i].href);

    if (s.substring(0,prefix.length) == prefix) {
      anchors[i].href += suffix;
      anchors[i].innerHTML += suffix;
    } 
  }
  
}

/**

Clones a foxboro menu item into a new list.
Requires JQUERY.

@param title String to search for in the menu.
*/

function clone_foxboro_menu(title, heading) {


	$('<h3>' + heading + "<\/h3>").prependTo("#clone_div");

	c=0;
	$("#foxboro_menu ul :contains('" + title + "') li a").each(function(index) {
	
			if($(this).text()) {
				link = '<a href="' + $(this).attr("href") + '">' + $(this).text() + '<\/a>';
				$("\n" + '<li>' + link + '<\/li>').appendTo('#clone_list');
			c++;
		}
  });

	// Hide by default. Fade in just for fun.
	if(c > 0) 
        {
$('#clone_div').show();
//		$('#clone_div').fadeIn('fast', function() { } );
	}
}

/* Change the strings in the functions if we ever change the titles. */

function clone_whoneeds() {
	title = 'Who Uses Track Records?';
        heading = 'Industry Fields';
	clone_foxboro_menu(title, heading);
}

function clone_ds() {
	title = 'Direct Support (DS)';
        heading = 'Reporting Features';
	clone_foxboro_menu(title, heading);
}

function clone_cm() {
	title = 'Case Management (CM)';
        heading = 'Reporting Features';
	clone_foxboro_menu(title, heading);
}

