
//----------------------------------------------------------------------------------------------------------------
/**
* This function gets a cookie by name
* The return value is the content of the cookie
* @param {c_name} 
* @return {c_content} 
*/
function getCookie(c_name){
  if (document.cookie.length>0){
    c_start=document.cookie.indexOf(c_name + "=");
    if (c_start!=-1){
      c_start=c_start + c_name.length+1;
      c_end=document.cookie.indexOf(";",c_start);
      if (c_end==-1) c_end=document.cookie.length;
      return unescape(document.cookie.substring(c_start,c_end));
    }
  }
  return "";
}


//----------------------------------------------------------------------------------------------------------------
/**
* This function sets a cookie by name , value and expiredays
* There is no return datatype. Just call the method.
* @param {c_name} 
* @param {value} 
* @param {expiredays}  
*/
function setCookie(c_name,value,expiredays)
{
  var exdate=new Date();
  exdate.setDate(exdate.getDate()+expiredays);
  document.cookie=c_name+ "=" +escape(value)+
  ((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}


//----------------------------------------------------------------------------------------------------------------

/**
* This function encrypt a string 
* @param {theText} 
* @return {encryptText}
*/
function encrypt(theText) {
  output = new String;
  Temp = new Array();
  Temp2 = new Array();
  TextSize = theText.length;
  for (i = 0; i < TextSize; i++) {
    rnd = Math.round(Math.random() * 122) + 68;
    Temp[i] = theText.charCodeAt(i) + rnd;
    Temp2[i] = rnd;
  }
  
  for (i = 0; i < TextSize; i++) {
    output += String.fromCharCode(Temp[i], Temp2[i]);
  }
  return output;
}


//----------------------------------------------------------------------------------------------------------------

/**
* This function unencrypt a string 
* @param {theText} 
* @return {unencryptText}
*/
function unEncrypt(theText) {
  output = new String;
  Temp = new Array();
  Temp2 = new Array();
  TextSize = theText.length;
  for (i = 0; i < TextSize; i++) {
    Temp[i] = theText.charCodeAt(i);
    Temp2[i] = theText.charCodeAt(i + 1);
  }
  for (i = 0; i < TextSize; i = i+2) {
    output += String.fromCharCode(Temp[i] - Temp2[i]);
  }
  return output;
}



