//
// Biorhythmus
//
// (c) 2010 Horst Klier / All rights reserved
//
// This Script is NO Freeware.
//
// You can use it, but don't copy it.
//
// If you want use it, go to http://biorhythmik.info
//

// Example param:
// var date = '01011900';
// var time = '1200';
// var name = 'Alice Bob';
// var pre  = 13; // 9-13
// var fixdate = ''; Dont calc for today, calc for this date

function CodeName(c){
  var c2='';
  var c3='';
  var i=0;
  while(i<c.length){
    c3=c.substr(i,1);
    if(c3>='a'&&c3<='z'){
    }else{
      if(c3>='A'&&c3<='Z'){
      }else{
        if(c3=='ä'){
          c3='-ae-';
        }else{
          if(c3=='ö'){
            c3='-oe-';
          }else{
            if(c3=='ü'){
              c3='-ue-';
            }else{
              if(c3=='ß'){
                c3='-ss-';
              }else{
                if(c3=='Ä'){
                  c3='-Ae-';
                }else{
                  if(c3=='Ö'){
                    c3='-Oe-';
                  }else{
                    if(c3=='Ü'){
                      c3='-Ue-';
                    }else{
                      if(c3>='0'&&c3<='9'){
                      }else{
                        if(c3==' '){
                          c3='%20';
                        }else{
                          c3='';
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    c2=c2+c3;
    i++;
  }
  return c2
}

function CalcBio(){
  var c='';
  var cDay='';
  var cMonth='';
  var cYear='';
  var cHour='';
  var cMin='';
  var cName='';
  cDay=date.substr(0,2);
  cMonth=date.substr(2,2);
  cYear=date.substr(4,4);
  cHour=time.substr(0,2);
  cMin=time.substr(2,2);
  cName=CodeName(name);
  c=document.getElementById('biorhythmik').innerHTML;
  document.getElementById('biorhythmik').innerHTML='<img src="http://biorhythmik.info/custprg/biorhythmus.prg?'+'day='+cDay+'&month='+cMonth+'&year='+cYear+'&name='+cName+'&hour='+cHour+'&min='+cMin+'&pre='+pre+'&fix='+fixdate+'&img=1'+'">'+c;
}

function GenElements() {
  document.write('<div id="biorhythmik" style="position:relative;background-color:#1f4978;height:430px;width:'+(456+(pre-9)*36)+'px;">');
  document.write('</div>');

  // link formatieren
  document.getElementById('biorhythmiklink').style.color='#ffffff';
  document.getElementById('biorhythmiklink').style.fontFamily='tahoma, arial, helvetica, sans-serif;';
  document.getElementById('biorhythmiklink').style.fontSize='11px';

  // info node in div verschieben
  var DIV;
  DIV=document.getElementById('biorhythmikinfo');
  DIV.parentNode.removeChild(DIV);
  document.getElementById('biorhythmik').appendChild(DIV);

  // divs mit links in container div verlegen
  document.getElementById('biorhythmikinfo').style.position='absolute';
  document.getElementById('biorhythmikinfo').style.bottom='9px';
  document.getElementById('biorhythmikinfo').style.left='30px';
  document.getElementById('biorhythmikinfo').style.display='block';


};


GenElements();
CalcBio();



