<!--
// saves a cookie on the client specified by name and value and optional expire.
function setCookie(name, value, expire) {
   document.cookie = name + "=" + escape(value)
   + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}

// retrieves a cookie specified by 'Name'.
function getCookie(Name) {
   var search = Name + "="
   if (document.cookie.length > 0) { // if there are any cookies
      offset = document.cookie.indexOf(search) 
      if (offset != -1) { // if cookie exists 
         offset += search.length 
         // set index of beginning of value
         end = document.cookie.indexOf(";", offset) 
         // set index of end of cookie value
         if (end == -1) 
            end = document.cookie.length
         return unescape(document.cookie.substring(offset, end))
      } 
   }
}

// saves cookie specified by name and value, which expires in 24 hours.
function saveCookie(name, value) {
   var today = new Date();
   var expires = new Date();
   expires.setTime((today.getTime() + 1000*60*60*24));
   setCookie(name, value, expires);
}

function removeCookie(name) {
// removes cookies immediately.
  var expires = new Date();
  setCookie(name, '', expires);
}

// tests if the browser supports cookies.
function cookieEnabled() {
  var result='';
  saveCookie('cookie','enabled');
  result = getCookie('cookie');
  return result;
}

// checks if the string 's' may contain numbers.
function isAlpha(s) {
  var re=/^\D+$/;
  return re.test(s);
}

// finds the object specified by 'n'.
function findObj(n, d) {
  var p,i,x;
  if(!d) 
    d=document;
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; 
    n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all) 
    x=d.all[n]; 
  for (i=0;!x&&i<d.forms.length;i++)
    x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++)
    x=MM_findObj(n,d.layers[i].document); 
  return x;
}

// validates forms.
function validateForm() {
  var i,p,q,nm,test,num,min,max,errors='';
  var args=validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { 
    test=args[i+2]; // parameter to field
    val=findObj(args[i]); // the field itself
    if (val) { 
      nm=args[i+1]; 
      if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { // check if e-mail
          p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) 
            errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test.indexOf('isAlpha')!=-1) {
          p = isAlpha(val);
          if (!p) errors+='- '+nm+' must not contain a number.\n'; 
        } else if (test!='R') { 
          num = parseFloat(val);
          if (val!=''+num) 
            errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { 
            p=test.indexOf(':');
            min=test.substring(8,p); 
            max=test.substring(p+1);
            if (num<min || max<num) 
              errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
          }
        } 
      } 
      else if (test.charAt(0) == 'R') 
        errors += '- '+nm+' is required.\n'; 
    }
  } 
  return errors;
}

// changes the values of form fields.
function changeValue(objName,newText) { //v3.0
  var obj = findObj(objName); if (obj) obj.value = ((newText==null) ? "" : newText);
}


// save client and cluster cookies
function saveCoClCookie(company, cluster) {
  setCookie('company',company);
  setCookie('cluster',cluster);
}

function savePosCookie(position) {
  setCookie('position',position);
}
//-->