/* (c) 2010 WWW.iKAL.CZ – All rights reserved.*/
function _ikal_presny_cas(){
   this.eid=function(id){return document.getElementById(id);}
   this.trim=function(s){return s.replace(/^\s+|\s+$/g,"");}
   var ctime='000000';
   var csec='666666';
   var htime='22';
   var hsec='10';
   var showsec=1;
   var timerset=false;
   var otime=false;
   var osec=false;
   var timezd=':';
   this.init=function(params){
      var p=params.split(',');
      for(x=0;x<p.length;x++) {
         var pcode=p[x].split(':');
         try{if(pcode[0]&&pcode[1]) {var ec=this.trim(pcode[0])+'=\''+this.trim(pcode[1])+'\';'; eval(ec);}
         }catch(err){alert(err);}
      }
   }
   this.show=function(){
      var root=this.eid('ikal-cas');
      var blcheck=0; if(root) blcheck=root.innerHTML.indexOf('přesný čas'); 
      //if(root&&blcheck>0){
         root.innerHTML='<span id="ikal_atime"></span><span id="ikal_asec"></span>';
         this.otime=document.getElementById('ikal_atime');
         this.osec=document.getElementById('ikal_asec');
         root.style.textDecoration='none';
         this.otime.style.color='#'+ctime; this.osec.style.color='#'+csec;
         this.otime.style.fontSize=htime+'px'; this.osec.style.fontSize=hsec+'px';
         this.timerset=true;
         this.refreshtimer();
      /*}else{
         root.innerHTML='Neplatna instalace Widgetu pro přesný čas www.iKAL.cz!';
      }*/
   }
   this.refreshtimer=function(){
      if(this.timerset==true) {
         var local_time = new Date();
         var hod = local_time.getHours();
         var min = local_time.getMinutes();
         var sec = local_time.getSeconds();
         dz=this.timezd;this.timezd=(dz=='.'?':':'.');
         this.otime.innerHTML=(hod<10?'0':'')+hod+this.timezd+(min<10?'0':'')+min;
         if(showsec==1){this.osec.innerHTML=(sec<10?'0':'')+sec; }else{ this.osec.innerHTML='';}
      }
   }
}
iKAL_CAS = new _ikal_presny_cas();
window.setInterval(function () {iKAL_CAS.refreshtimer();}, 1000);



