function genLink(text, url, onClick, target, regularStyle, mouseOverStyle, mouseOverStatus)
{
  var str = "<a"

  if (regularStyle)
    str += " class=\""+regularStyle+"\""
  str += " href='"+url+"'"
  if (onClick)
    str += " onClick=\""+onClick+"\""
  if (target && (target != ""))
    str += " target=\""+target+"\""
  if (regularStyle && mouseOverStyle) {
    if (mouseOverStatus)
      str += " onMouseOver=\"this.className='"+mouseOverStyle+"';top.status='"+mouseOverStatus+"'\" onMouseOut=\"this.className='"+regularStyle+"'\""
    else
      str += " onMouseOver=\"this.className='"+mouseOverStyle+"'\" onMouseOut=\"this.className='"+regularStyle+"'\""
  }
  str += ">"+text+"</a>"
  return str
}


function createLink(text, url, target, regularStyle, mouseOverStyle, mouseOverStatus)
{
  var str  

  str = genLink(text,url,null,target,regularStyle,mouseOverStyle,mouseOverStatus)
  document.write(str)
  return str
}

function createDhtmlLink(text, url, onClick, target, regularStyle, mouseOverStyle, mouseOverStatus)
{
  var str  

  str = genLink(text,url,onClick,target,regularStyle,mouseOverStyle,mouseOverStatus)
  document.write(str)
  return str
}


function openWindow(url, namePrefix, features, unique, bringOnTop)
{
  var winname, msecs, d, win 

  if (unique || !namePrefix) {
    d = new Date()
    msecs = d.getTime()
    if (msecs < 0)
      msecs = 0-msecs
    nameSuffix = msecs
    if (!namePrefix)
      namePrefix = "win"
  }
  else
    nameSuffix = ""

  winname = namePrefix + nameSuffix
  win = open(url,winname,features)
  if (bringOnTop) {
    win.focus()
  }

  return win
}


function checkBrowser()
{
  var browserVersion
  
  if (window.navigator.appName == "Netscape") {
    browserVersion = parseFloat(window.navigator.appVersion)
    if (browserVersion < 5)
      alert("Warning: You are running an older version of Netscape, this site won't look very good due to the limitations of your browser.\n For best results please use Internet Explorer 5+, Netscape 6+ or Mozilla")
  }
}


function updateDbActionAndSubmit(value) 
{
  if (value == "delete") {
  	if (!confirm("Are you sure you want to delete this entry?"))
  	  return false;
  }
  // either doing save or have confirmed delete
  form = document.getElementById("editForm");
  form.dbAction.value = value;
  //alert(form.dbAction.value);
  form.submit();
}


function submitSupervisionForm() 
{
  var valid = true;
  form = document.getElementById("supervisionForm");
  // check to make sure all required fields have values
  if (form.firstName.value.length == "")
    valid = false;
  if (form.lastName.value == "")
    valid = false;
  if ((form.phoneNumber.value == "") && (form.email.value == ""))
    valid = false;
  
  if (valid)
  	form.submit();
  else
  	alert("Some of the required fields have not been filled in.\n\nYou need to provide your First Name, Last Name and either a Phone Number or Email address so that The Professional Matrix can contact you regarding supervision.");
}


function submitCEOrderForm() 
{
  var valid = true;
  form = document.getElementById("ceOrderForm");
  if (form.email.value == "")
    valid = false;
  
  if (valid)
  	form.submit();
  else
  	alert("Some of the required fields have not been filled in.\n\nYou need to provide your Email address so that The Professional Matrix can send you the CE materials.");
}


function submitVolunteerForm() 
{
  var valid = true;
  form = document.getElementById("volunteerForm");
  if (form.contact.value == "")
    valid = false;
  if (form.description.value == "")
    valid = false;
  
  if (valid)
  	form.submit();
  else
  	alert("Some of the required fields have not been filled in.\n\nYou need to provide a description of the Volunteer Position and your Contact Information.");
}


function goto(url)
{
  document.location.href=url;
}