/**
 * tools.js 
 *
 * COPYRIGHT: All  title   and  proprietary  rights,  including  trade
 * secrets,   in   the   Software   and   any   copies thereof and the
 * accompanying  written   materials,   are  owned  by   schukai  GmbH
 * and  are  protected  by  German  copyright  laws,  other applicable
 * copyright   laws  and  international  treaty  provisions.
 *
 * @package    alvine
 * @author     schukai GmbH <info@schukai.de>
 * @copyright  Copyright (C) 2002, 2003, 2004, 2005, 2006 schukai GmbH
 * @license    http://www.alvine.de/license/
 * @version    20061114
 * @link       http://www.alvine.de/
*/


alvine.js.generateGuid = function(obj) {
  if(!this.guids) this.guids = [];
  var result, i, j;
  result = "";
  while (!j || this.guids[result]) {
    result = "ID-";
    for(j=0; j<32; j++) {
      if( j == 8 || j == 12|| j == 16|| j == 20) {
        result = result + "-";
      }
      i = Math.floor(Math.random()*16).toString(16).toUpperCase();
      result = result + i;
    }
  }
  obj.attr('id',result);
  this.guids[result] = obj;
  return result
} 



function fill(n, t){
  if(t==1)return '';
  if(t>3)return '';
  
  s = "";
    
  if(t==2) {
    if (n < 10) s += "0";
  }
  if(t==3){
    if (n < 10) {
      s += "00";
    } else if (n < 100) {
      s += "0";
    }
  }
    
  return (s + n).toString();  
}
