function randomImg(imgNumMax) {
	// return values will be integers from 1 to imgNumMax
	var imgNum;
	imgNum = Math.floor(Math.random() * imgNumMax) + 1;
	return imgNum;
}
function chp_right_image_link () {
  document.write ("<img src='"+ base_tpl_url +"/images/inner_image_about" + randomImg(3) + ".jpg' width='251' height='108' alt=''>");
}
function chp_left_image_link () {
  document.write ("<img src='"+ base_tpl_url +"/images/inner_side_image_" + randomImg(5) + ".gif' width='217' height='138' alt=''>");
}
function chp_open_popup(theURL,winName,features) {
  var win = window.open(theURL,winName,features);
  win.focus ();
}

function chp_open_abstract_popup (theURL, winName) {
  var features = 'scrollbars=yes,width=540,height=600,resizable=yes'
  chp_open_popup (theURL, winName, features);
}

function chp_left_link (text, link, match) {
  var path = document.location.href;
  // process special exceptions
  if (path.indexOf ("/about/abstract") >= 0) {
	// put abstracts in the same section as publications. pretend the
	// path is publications.
    path = "/about/publications.html";
	//alert ("abstracts will cause publications link to be highlighted");
  }
  // if you leave the match arg blank, use the link to match with instead.
  if (!match) match = link;
  var i = path.indexOf (match);
  var cssclass = "subnav";
  var downstate = (i >= 0);
  if (downstate) {
	//alert ("chp_left_link: the path is "+path+" so I will highlight "+text);
	cssclass = "subnav_downstate";
  }
  var out;
  out = "<tr>\n";
  out += "<td width=40><img src='"+ base_tpl_url +"/images/spacer.gif' width=40 height=20></td> \n";
  out += "<td class='" + cssclass + "'> \n";
  if (downstate)
	out += text;
  else 
	out += "<a href='" + link + "'>" + text + "</a> \n";
  out += "</td></tr> \n";
  document.write (out);
}

function chp_menu_link (text, link) {
  var path = document.location.href;
  var cssclass = "menulink";
  var i = path.indexOf (link);
  var downstate = (i >= 0);
  if (downstate) {
	//alert ("chp_menu_link: the path is "+path+" so I will highlight "+text);
	cssclass = "menulink_downstate";
  }
  var out;
  out = "<tr><td class='" + cssclass + "'> \n";
  if (downstate)
    out += text;
  else
    out += "<a href='" + link + "'>" + text + "</a> \n";
  out += "</td></tr> \n";
  document.write (out);
}

typeof $ == 'function' && $(function(){
	$('#registerform').each(function(){
		$(this).find('#user_login').closest('p').hide();
		$(this).find('[value="-Select-"]').val('');
		
		$(this).find('#email-p').after('<div id="names"><div style="float:left;">Name:</div> <div class="container"></div></div>').insertAfter( $(this).find('#email-p').next() );
		
		$(this).find('#first_name-p').appendTo('#names .container').find('label').text('First');
		$(this).find('#middle_init-p').appendTo('#names .container');
		$(this).find('#last_name-p').appendTo('#names .container').find('label').text('Last');
		
	});
});

