/* functions to synthesize and e-mail address and load a form (or a mailto:
   url on the fly when a USER clicks a form button
   created by Jim Lewis with form window programmed by Adam Critchley
   10/2006
   Modified 10/30/06 by Lewis to accept specific form label message and to specify specific box width, if none given, defaults to width in SendMail class style
   Modified 01/10/07 by Adam to dynamically build string used for input tag based on whether fwidth or addstyle have been defined
*/
function makeForm(nam1,nam2,msg,fwidth,addstyle)
{
frmString="<input name='" + msg + nam1 + "' type='button' class='SendMail' value='" + msg + "' onClick='OpenEmail(\"" + nam1 + "\",\"" + nam2 + "\");' ";

// if addstyle is defined then fwidth has to be defined
if(fwidth && addstyle)
{
    frmString += "style='width: " + fwidth + "em; " + addstyle + ";'";
}
else if(fwidth)
{
	frmString += "style='width: " + fwidth + "em;'";
}

frmString += " />";

/* The / mark at end of line above terminates INPUT tag without closing tag*/
document.write(frmString);
}

function OpenEmail(nam1,nam2) 
{
  var prefix;
  //nam2 for a work study is "" so following IF is O.K.
  if (nam2 == ""){
	 prefix = nam1;
     lastpart="lonestar.utsa.edu";
  }
  else {
 	 prefix = nam1+'.'+nam2;
     lastpart="utsa.edu";
  }
  
  var site='http://www.utsa.edu/safety/ContactUs/mailto.htm?mail='+prefix+'%40'+lastpart+'&name='+nam1+'%20'+nam2;
  window.open( site , 'SendEmail',
     'resizable=0,toolbar=0,location=0,directories=0,menubar=0,scrollbars=0,width=450,height=300');	
}