var IE = document.all?true:false;

String.prototype.ltrim = function (clist) {
   if (clist)
     return this.replace (new RegExp ('^[' + clist + ']+'), '');
   return this.replace (/^\s+/, '');
}

Array.prototype.trimAll = function ()
{
	var allNonEmpty = true;
	for (var i = 0; i < this.length; i++)
	{
		this[i] = this[i].trim();
		if (allNonEmpty) allNonEmpty = this[i] > '';
	}
	return allNonEmpty;
}

String.prototype.rtrim = function (clist) {
  if (clist)
    return this.replace (new RegExp ('[' + clist + ']+$'), '');
  return this.replace (/\s+$/, '');
}

String.prototype.trim = function (clist) {
   if (clist)
     return this.ltrim (clist).rtrim (clist);
   return this.ltrim ().rtrim ();
};

function isO(eo)
  {
  return typeof(eo) =='object';
  }

function $(id) {return document.getElementById(id);}

function addCSS(eo,css)
{
  var e = isO(eo) ? eo : $(eo);
  if (e.className.search(css) < 0)
    e.className += ' '+css;
}

function delCSS(eo,css)
{
  var e = isO(eo) ? eo : $(eo);
  if (e.className.search(css) >= 0)
    e.className = e.className.replace(css,'').trim();
}

function switchCSS(eo,oldcss,newcss)
{
  var e = isO(eo) ? eo : $(eo);
  delCSS(e,oldcss);
  addCSS(e,newcss);
}

function generateCloud() 
{
  data.sort(function (a,b) 
  {
    var A = a[2].toLowerCase();
    var B = b[2].toLowerCase();
    return A>B ? 1 : (A<B ? -1 : 0);
  });
  var html = "";
  for(var i=0;i<data.length;i++) {
	if (data[i])
	{
		var val = data[i][0];
		html += ' <a '+(data[i][3]? 'style="margin-right:'+data[i][3]+'px" ' : '')+'class="g'+data[i][0]+'" href="'+data[i][1]+'" title="'+data[i][0]+'">'+data[i][2]+'</a>';
	}
  }
  var cloud = document.getElementById("cloud");
  cloud.innerHTML = html;
}

function shDetails (id)
{
  var e=$(id);
  if (e.className.search('dshow') >= 0)
  {
		switchCSS(id,'dshow','dhide');
		$('l' + id).innerHTML = "&#187;";
	}	else 
	{
		switchCSS(id,'dhide','dshow');
		$('l' + id).innerHTML = "&#171;";
	}
}
