
function WrapOnOff_id(id) {
  return WrapOnOff_ref(document.getElementById(id));
}
function WrapOnOff_ref(curNod) {
  if (curNod.getAttribute("wrap")=="off")
      curNod.setAttribute("wrap","soft");
  else
      curNod.setAttribute("wrap","off");
  // ff bug 
  var
    parNod = curNod.parentNode, 
    nxtSib = curNod.nextSibling;
  parNod.removeChild(curNod); 
  parNod.insertBefore(curNod, nxtSib);
  // end ff bug 

  return true;
}


function textCounter_id(id, countid,maxlimit) {
  textCounter_ref(document.getElementById(id),document.getElementById(countid),maxlimit);
}
function textCounter_ref(field, countfield, maxlimit) {
  if (field.value.length > maxlimit)
    field.value = field.value.substring(0, maxlimit);
   else 
    countfield.value = maxlimit - field.value.length;
}


// Cookie handlers

/**
* Sets a cookie
*
* @param	string	Cookie name
* @param	string	Cookie value
* @param	date	Cookie expiry date
*/
function set_cookie(name, value, expires)
{
	document.cookie = name + '=' + escape(value) + '; path=/' + (typeof expires != 'undefined' ? '; expires=' + expires.toGMTString() : '');
}

/**
* Deletes a cookie
*
* @param	string	Cookie name
*/
function delete_cookie(name)
{
	document.cookie = name + '=' + '; expires=Thu, 01-Jan-70 00:00:01 GMT' +  '; path=/';
}

/**
* Fetches the value of a cookie
*
* @param	string	Cookie name
*
* @return	string
*/
function fetch_cookie(name)
{
	cookie_name = name + '=';
	cookie_length = document.cookie.length;
	cookie_begin = 0;
	while (cookie_begin < cookie_length)
	{
		value_begin = cookie_begin + cookie_name.length;
		if (document.cookie.substring(cookie_begin, value_begin) == cookie_name)
		{
			var value_end = document.cookie.indexOf (';', value_begin);
			if (value_end == -1)
			{
				value_end = cookie_length;
			}
			return unescape(document.cookie.substring(value_begin, value_end));
		}
		cookie_begin = document.cookie.indexOf(' ', cookie_begin) + 1;
		if (cookie_begin == 0)
		{
			break;
		}
	}
	return null;
}




