

function writeFlash(id, src, height, width, param, param_val){

  output = ("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"" + width + "\" height=\"" + height + "\" id=\"" + id + "\" align=\"top\">");
  var scale = "";
  var wmode = "";
  var allowScriptAccess = "";

  for(i=0; i<param.length; i++){

    output += ("<param name=\"" + param[i] + "\" value=\"" + param_val[i] + "\" />\n");

    if(param[i] == "scale"){

      scale = "scale=\"" + param_val[i] + "\"";

    }

    if(param[i] == "wmode"){

      wmode = "wmode=\"" + param_val[i] + "\"";

    }

    if(param[i] == "allowScriptAccess"){

      allowScriptAccess = "allowScriptAccess=\"" + param_val[i] + "\"";

    }
 
  }

  output += ("<embed src=\"" + src + "\" quality=\"high\" bgcolor=\"#ff0000\" width=\"" + width + "\" height=\"" + height + "\" name=\"" + id + "\" salign=\"t\" align=\"top\" " + allowScriptAccess + " " + wmode + " type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"  border=\"0\" " + scale + " />");
  output += ("</object>");

  document.write(output);

}

function charCount(trig_id, targ_id, max, critlim, normclass, critclass){

  var trig_obj = document.getElementById(trig_id);
  var targ_obj = document.getElementById(targ_id);

  charcount = max - trig_obj.value.length;

  if(charcount < 0){

    trig_obj.value = trig_obj.value.substring(0, max);
    charcount = 0;

  }

  targ_obj.value = charcount + " characters remaining";

  targ_obj.className = normclass;

  if(charcount <= critlim){

    targ_obj.className = critclass;

  }

}

function delete_confirm(item_type, item_name, delete_url, return_url){

  if(confirm('Are you sure you want to delete the ' + item_type + ' \'' + item_name + '\'?')){

    location.href = delete_url + '&rurl=' + encodeURIComponent(return_url);

  }

}

function formatphone(id){

  var valid = "0123456789";
  var obj = typeof(id) == 'string' ? document.getElementById(id) : id;
  var tnum = new String();
  var num = new String();

  if(obj.value.length > 0){

    for(i=0; i<obj.value.length; i++){

      if(valid.indexOf(obj.value.substr(i, 1)) != -1){

        tnum += obj.value.substr(i, 1);

      }

    }

    num = "(" + tnum.substr(0, 3) + ") " + tnum.substr(3, 3) + "-" + tnum.substr(6, 4);

    if(tnum.length > 10){

      num += " x" + tnum.substr(10, 4);

    }

    obj.value = num;

  }

}


function formatMoney(obj){

  if(obj.value.length > 0){

    var valid = "0123456789.";
    var tnum = new String();
    var num = new String();

    for(i=0; i<obj.value.length; i++){

      if(valid.indexOf(obj.value.substr(i, 1)) != -1){

        tnum += obj.value.substr(i, 1);

      }

    }

    tnum = parseFloat(tnum);
    obj.value = tnum.toFixed(2).toString();

  }else{

    obj.value = '0.00';

  }

}


function getPosition(obj) {

  var objleft = 0;
  var objtop = 0;

  if(obj.offsetParent){

    do {

      objleft += obj.offsetLeft;
      objtop += obj.offsetTop;

    } while (obj = obj.offsetParent);

  }

  return [objleft, objtop];

}


function menuOptHL(obj) {

  obj.className = obj.className == "mnhl" ? "mhl" : "mnhl";

}


//---- Cookie Management Javascript ----//


function setCookie(cvar, cval, expires){

  if(!expires){ var expires = null; }

  var cstr = cvar + "=" + escape(cval);
  var eDate = new Date();
  
  if(expires != null){

    eDate.setTime(eDate.getTime() + expires * 24 * 60 * 60 * 1000);
    cstr += ";expires=" + eDate.toGMTString();

  }

  document.cookie = cstr;

}


function delCookie(cvar){

  if(!cvar){ alert("Please enter a cookie variable to remove."); }

  var dstr = document.cookie;
  var dstrarr = dstr.split(';');
  var eDate = new Date();
  eDate.setYear(eDate.getFullYear() - 1);

  for(var i in dstrarr){

    if(dstrarr[i].indexOf(cvar) == 0){

      document.cookie = dstrarr[i] + ";expires=" + eDate.toGMTString();

    }

  }

}


function getCookie(cvar){

  if(!cvar){ alert('Please identify a cookie value to retrieve.'); }

  var dstr = document.cookie;
  var dstrarr = dstr.split(';');

  for(var i in dstrarr){

    dstrarr[i] = dstrarr[i].split('=');

    if(dstrarr[i][0] == cvar){

      return(unescape(dstrarr[i][1]));

    }

  }

  return undefined;

}


//---- Cookie Management Javascript ----//

