
//dom.aE(window, 'load', slideShowSWPlaymain, false);


// dIGI - M produkcija :::

function DoHover(element)
  { element.className += " hover";
  }
 
function RestoreHover(element)
  { element.className = element.className.replace(/\bhover\b/,'');
  }
function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}
function formatAsMoney(mnt) {
    mnt -= 0;
    mnt = (Math.round(mnt*100))/100;
    return (mnt == Math.floor(mnt)) ? mnt + '.00' 
              : ( (mnt*10 == Math.floor(mnt*10)) ? 
                       mnt + '0' : mnt);
}
function formatCurrency(strValue)
{
	strValue = strValue.toString().replace(/\$|\,/g,'');
	dblValue = parseFloat(strValue);

	blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
	dblValue = Math.floor(dblValue*100+0.50000000001);
	intCents = dblValue%100;
	strCents = intCents.toString();
	dblValue = Math.floor(dblValue/100).toString();
	if(intCents<10)
		strCents = "0" + strCents;
	for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
		dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+' '+
		dblValue.substring(dblValue.length-(4*i+3));
	return (((blnSign)?'':'-') + '' + dblValue + ',' + strCents);
}

// /dIGI -M


var currentSlideSWID = null;
var currentSlideSWTimeoutID = null;
var isPlay = true;

var currentSlideSWIDg = null;
var currentSlideSWTimeoutIDg = null;
var isPlayg = true;

var currentSlideSWIDt = null;
var currentSlideSWTimeoutIDt = null;
var isPlayt = true;

function slideShowSWPlaymain(){
 /* var offset=-24;
 // var offset=78;
  if($('banner-top')){
  coords=$('banner-top').getCoordinates()
    offset = offset +coords.height;
  }
  document.body.style.backgroundPosition='0px '+offset+'px';
  */
}
function MOD(nmb,divider)
{
  var div=Math.floor(nmb/divider);
  var rest=nmb-divider*div;
  return rest;
}
function tvperiod(nmb){
  var i=0;
  var d=0;
  var h=0;
  var elarr=$ES('.per_'+nmb);
  var off=3;
  //alert(off);
  for (i=0;i<elarr.length;i++)
  {
    d++;
    off=3
    if(d==3 || i+1==elarr.length){
     h=0;
     
     if(i+1==elarr.length){
      
      r=MOD(elarr.length,3);
      if(r!=0)
        off=r;
     // alert(off);
     }
     
     for(j=0;j<off;j++){
        if(elarr[i-j].getCoordinates().height>h)
          h=elarr[i-j].getCoordinates().height;
     }
     
     for(j=0;j<off;j++){
        elarr[i-j].style.height = h+'px';
     }
     
     // alert(h);
     d=0;    
    }
    
  }
}
var EurSkkRateN = 0;
function  tvfix(){
  tvperiod(0);
  tvperiod(5);
  tvperiod(12);
  tvperiod(16);
  tvperiod(20);
  tvperiod(24);
}

//var TipsEUR;

var EurSkkRate='30';
  EURTips = Tips.extend({
    build: function(el){
    
      var pattrn = '([1-9][0-9\., ]*[0-9]?)';
      var exp=new RegExp(pattrn, "g");
      //el.textContent
      
		  var match = exp.exec(el.innerHTML);
		  //alert(el.innerHTML);
		  if(match){
		    var str = match[0];
		    match=match[0].replace(/[.\s]/g, "");
		    match=match.replace(/[,]/g, ".");
		    el.$tmp.myTitle = str+' Sk = '+formatCurrency(roundNumber(match/30.126,2))+' €';
  		  //el.$tmp.myText = 'kurz z '+today+':'+EurSkkRate;
  		  el.$tmp.myText = 'konverzný kurz 30.126 SK';
  		  
  		  el.removeAttribute('title');
      }else{
         el.removeAttribute('title');
         el.removeClass(el.className);
         return false;
      }
     //alert(el.textContent);
 		
  		if (el.$tmp.myTitle && el.$tmp.myTitle.length > this.options.maxTitleChars) el.$tmp.myTitle = el.$tmp.myTitle.substr(0, this.options.maxTitleChars - 1) + "&hellip;";
  		el.addEvent('mouseenter', function(event){
  			this.start(el);
  			if (!this.options.fixed) this.locate(event);
  			else this.position(el);
  		}.bind(this));
  		if (!this.options.fixed) el.addEvent('mousemove', this.locate.bindWithEvent(this));
  		var end = this.end.bind(this);
  		el.addEvent('mouseleave', end);
  		el.addEvent('trash', end);
  	}});
 SKKTips = Tips.extend({
    build: function(el){
    
      var pattrn = '([1-9][0-9\., ]*[0-9]?)';
      var exp=new RegExp(pattrn, "g");
      //el.textContent
      
		  var match = exp.exec(el.innerHTML);
		  //alert(el.innerHTML);
		  if(match){
		    var str = match[0];
		    match=match[0].replace(/[.\s]/g, "");
		    match=match.replace(/[,]/g, ".");
		    el.$tmp.myTitle = str+' € = '+formatCurrency(roundNumber(match*EurSkkRateN,2))+' Sk';
  		  el.$tmp.myText = 'kurz z '+today+': '+EurSkkRate;
  		  el.removeAttribute('title');
      }else{
         el.removeAttribute('title');
         el.removeClass(el.className);
         return false;
      }
     //alert(el.textContent);
 		
  		if (el.$tmp.myTitle && el.$tmp.myTitle.length > this.options.maxTitleChars) el.$tmp.myTitle = el.$tmp.myTitle.substr(0, this.options.maxTitleChars - 1) + "&hellip;";
  		el.addEvent('mouseenter', function(event){
  			this.start(el);
  			if (!this.options.fixed) this.locate(event);
  			else this.position(el);
  		}.bind(this));
  		if (!this.options.fixed) el.addEvent('mousemove', this.locate.bindWithEvent(this));
  		var end = this.end.bind(this);
  		el.addEvent('mouseleave', end);
  		el.addEvent('trash', end);
  	}});
  	
function setTips(){
  //skk -> EUR tips$S('a.info, a.toolTip')
  //alert('asd');
  TipsEUR = new EURTips($ES('.eur-tip'), {
      maxTitleChars: 50,
    	initialize:function(){
    		this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
    	},
    	onShow: function(toolTip) {
    		this.fx.start(1);
    	},
    	onHide: function(toolTip) {
    		this.fx.start(0);
    	}
    }
  );
  TipsSKK = new SKKTips($ES('.skk-tip'), {
      maxTitleChars: 50,
    	initialize:function(){
    		this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
    	},
    	onShow: function(toolTip) {
    		this.fx.start(1);
    	},
    	onHide: function(toolTip) {
    		this.fx.start(0);
    	}
    }
  );
}
window.addEvent('domready', function() {
//fix the body background
	var offset=-324;
 // var offset=78;
  if($('banner-top')){
  coords=$('banner-top').getCoordinates();
    offset = offset +coords.height;
  }
  document.body.style.backgroundPosition='0px '+offset+'px';
  if(EurSkkRate){
    EurSkkRateN = EurSkkRate.replace(',','.');
    setTips();
  }
  tvfix();
});

// BEGIN Slide Show sexy zeny
function slideShowSWPlay() {
	isPlay = true;
	if(window.document.getElementById('sexyWoman_' + currentSlideSWID)) {
		window.document.getElementById('sexyWoman_' + currentSlideSWID).style.display = 'none';
	}
	if(!currentSlideSWID) {
		currentSlideSWID = 1;
	} else {
		currentSlideSWID = currentSlideSWID + 3;
	}
	if(window.document.getElementById('sexyWoman_' + currentSlideSWID)) {
		//alert(window.document.getElementById('sexyWoman_' + currentSlideSWID));
		window.document.getElementById('sexyWoman_' + currentSlideSWID).style.display = 'block';
		currentSlideSWTimeoutID = window.setTimeout('slideShowSWPlay()', 5000);
	} else {
		if(window.document.getElementById('sexyWoman_' + (currentSlideSWID - 3))) {
			window.document.getElementById('sexyWoman_' + (currentSlideSWID - 3)).style.display = 'none';
		}
    currentSlideSWID = 1;
    if(window.document.getElementById('sexyWoman_' + currentSlideSWID)){
	  window.document.getElementById('sexyWoman_' + currentSlideSWID).style.display = 'block';
		currentSlideSWTimeoutID = window.setTimeout('slideShowSWPlay()', 5000);}
		else isPlay = false;
	}
}

// Dalsi slide
function slideShowSWNext() {
	window.clearTimeout(currentSlideSWTimeoutID);
	slideShowSWPlay();
	slideShowSWPause();
	slideShowSWPlay();
}

// Predchadzajuci slide
function slideShowSWBack() {
	window.clearTimeout(currentSlideSWTimeoutID);
	window.document.getElementById('sexyWoman_' + currentSlideSWID).style.display = 'none';
	currentSlideSWID = currentSlideSWID - 6;
	switch(currentSlideSWID) {
		case -5: currentSlideSWID = 10; break;
		case -2: currentSlideSWID = 13; break;
	}
	slideShowSWPlay();
	slideShowSWPause();
}

// Pause slide
function slideShowSWPause() {
	if(isPlay == true) {
		window.clearTimeout(currentSlideSWTimeoutID);
	//	window.document.getElementById('sexyWomanPlayPauseButton').src = 'images/slideShow01/play.gif';
		isPlay = false;
	} else {
		slideShowSWPlay()
		//window.document.getElementById('sexyWomanPlayPauseButton').src = 'images/slideShow01/pause.gif';
	}
}
// END Slide Show sexy zeny

// BEGIN Slide Show sexy zeny
function slideShowSWPlayg() {
	isPlayg = true;
	if(window.document.getElementById('GADGET_' + currentSlideSWIDg)) {
		window.document.getElementById('GADGET_' + currentSlideSWIDg).style.display = 'none';
	}
	if(currentSlideSWIDg<=0) {
		currentSlideSWIDg = 1;
	} else {
		currentSlideSWIDg = currentSlideSWIDg + 1;
	}
	if(window.document.getElementById('GADGET_' + currentSlideSWIDg)) {
		//alert(window.document.getElementById('sexyWoman_' + currentSlideSWID));
		window.document.getElementById('GADGET_' + currentSlideSWIDg).style.display = 'block';
		currentSlideSWTimeoutIDg = window.setTimeout('slideShowSWPlayg()', 5000);
		return;
	} else {
		if(window.document.getElementById('GADGET_' + (currentSlideSWIDg - 1))) {
			window.document.getElementById('GADGET_' + (currentSlideSWIDg - 1)).style.display = 'none';
		}
		currentSlideSWIDg = 1;
		if(window.document.getElementById('GADGET_' + currentSlideSWIDg)){
	  window.document.getElementById('GADGET_' + currentSlideSWIDg).style.display = 'block';
		currentSlideSWTimeoutIDg = window.setTimeout('slideShowSWPlayg()', 5000);
		return;
		}else
		isPlayg = false;
	}
}

// Dalsi slide
function slideShowSWNextg() {
	window.clearTimeout(currentSlideSWTimeoutIDg);
	slideShowSWPlayg();
	slideShowSWPauseg();
}

// Predchadzajuci slide
function slideShowSWBackg() {
numofgad=window.document.getElementById('GADGETNUM').value;
	window.clearTimeout(currentSlideSWTimeoutIDg);
	window.document.getElementById('GADGET_' + currentSlideSWIDg).style.display = 'none';
	currentSlideSWIDg = currentSlideSWIDg - 2;
	switch(currentSlideSWIDg) {
		case  0: currentSlideSWIDg = numofgad; break;
		case -1: currentSlideSWIDg = numofgad-1; break;
	}
	slideShowSWPlayg();
	slideShowSWPauseg();
}

// Pause slide
function slideShowSWPauseg() {
	if(isPlayg == true) {
		window.clearTimeout(currentSlideSWTimeoutIDg);
		isPlayg = false;
	} else {
		slideShowSWPlayg()
	}
}
function slideShowShowg(id) {
numofgad=window.document.getElementById('GADGETNUM').value;
//	window.clearTimeout(currentSlideSWTimeoutIDg);
	window.document.getElementById('GADGET_' + currentSlideSWIDg).style.display = 'none';
	currentSlideSWIDg = id-1;
	switch(currentSlideSWIDg) {
		case  0: currentSlideSWIDg = numofgad; break;
		case -1: currentSlideSWIDg = numofgad-1; break;
	}
	window.clearTimeout(currentSlideSWTimeoutIDg);
	slideShowSWPlayg();
	slideShowSWPauseg();
	//slideShowSWPlayg();
}
// END Slide Show sexy zeny

// BEGIN Slide Show sexy zeny
function slideShowSWPlayt() {
	isPlayt = true;
	if(window.document.getElementById('TOPNEWSA_' + currentSlideSWIDt)) {
	
		window.document.getElementById('TOPNEWSA_' + currentSlideSWIDt).style.display = 'none';
		//alert(currentSlideSWIDt);
	}
	if(!currentSlideSWIDt) {
		currentSlideSWIDt = 1;
	} else {
		currentSlideSWIDt = currentSlideSWIDt + 1;
	}
	if(window.document.getElementById('TOPNEWSA_' + currentSlideSWIDt)) {
	
		window.document.getElementById('TOPNEWSA_' + currentSlideSWIDt).style.display = 'block';
		currentSlideSWTimeoutIDt = window.setTimeout('slideShowSWPlayt()', 5000);
		return;
	} else {
		if(window.document.getElementById('TOPNEWSA_' + (currentSlideSWIDt - 1))) {
			window.document.getElementById('TOPNEWSA_' + (currentSlideSWIDt - 1)).style.display = 'none';
		}
		currentSlideSWIDt = 1;
		if(window.document.getElementById('TOPNEWSA_' + currentSlideSWIDt)){
	  window.document.getElementById('TOPNEWSA_' + currentSlideSWIDt).style.display = 'block';
		currentSlideSWTimeoutIDt = window.setTimeout('slideShowSWPlayt()', 5000);
		return;
		}else
		isPlayt = false;
	}
}

// Dalsi slide
function slideShowSWNextt() {
	window.clearTimeout(currentSlideSWTimeoutIDt);
	slideShowSWPlayt();
	slideShowSWPauset();
}

// Predchadzajuci slide
function slideShowSWBackt() {
numofgadt=window.document.getElementById('TOPNEWSANUM').value;
	window.clearTimeout(currentSlideSWTimeoutIDt);
	window.document.getElementById('TOPNEWSA_' + currentSlideSWIDt).style.display = 'none';
	currentSlideSWIDt = currentSlideSWIDt - 2;
	switch(currentSlideSWIDt) {
		case  0: currentSlideSWIDt = numofgadt; break;
		case -1: currentSlideSWIDt = numofgadt-1; break;
	}
	slideShowSWPlayt();
	slideShowSWPauset();
}

// Pause slide
function slideShowSWPauset() {
	if(isPlayt == true) {
		window.clearTimeout(currentSlideSWTimeoutIDt);
		isPlayt = false;
	} else {
		slideShowSWPlayt()
	}
}
function slideShowShowt(id) {
numofgadt=window.document.getElementById('TOPNEWSANUM').value;
	window.clearTimeout(currentSlideSWTimeoutIDt);
	window.document.getElementById('TOPNEWSA_' + currentSlideSWIDt).style.display = 'none';
	currentSlideSWIDt = id-1;
	switch(currentSlideSWIDt) {
		case  0: currentSlideSWIDt = numofgadt; break;
		case -1: currentSlideSWIDt = numofgadt-1; break;
	}
	window.clearTimeout(currentSlideSWTimeoutIDt);
	slideShowSWPauset();
	slideShowSWPlayt();
}
// END Slide Show sexy zeny

// menu functions

function switchmenu(id){
          var lis=document.getElementById('menu').childNodes;
          for( var i = 0; i<lis.length; i++ ) {
            
             lis[i].className='';
             var id2=lis[i].id.substring(2);
             document.getElementById('dv'+id2).style.display='none';
             document.getElementById('lu'+id2).style.display='none';
             document.getElementById('a'+id2).style.color='';
          }
         
          document.getElementById('li'+id).className='menu-main-active';
          document.getElementById('a'+id).style.color='black';
          document.getElementById('dv'+id).style.display='block';
          document.getElementById('lu'+id).style.cssText='';
          document.getElementById('a'+id).click;
        }
  
function switchmenur(id){
        // getElementByTagName('li')
          var lis=document.getElementById('topreadmenu').childNodes;
          for( var i = 0; i<lis.length; i++ ) {
             lis[i].className='';
             var id2=lis[i].id.substring(3);
             document.getElementById('ar'+id2).style.cssText='';
             document.getElementById('lsr'+id2).style.cssText='display:none;';
          }
          document.getElementById('lir'+id).className='menu-red-head-active';
          document.getElementById('ar'+id).style.cssText='color:black;';
          document.getElementById('lsr'+id).style.cssText='';
        }
var currentnewstmenu=false;
function switchmenul(id){
  currentnewstmenu = id;
          var lis=document.getElementById('lastartdmenu').childNodes;
          for( var i = 0; i<lis.length; i++ ) {
             lis[i].className='';
             var id2=lis[i].id.substring(3);
             document.getElementById('al'+id2).style.cssText='';
             document.getElementById('lsl'+id2).style.cssText='display:none;';
          }
          document.getElementById('lil'+id).className='menu-red-head-active';
          document.getElementById('al'+id).style.cssText='color:black;';
          document.getElementById('lsl'+id).style.cssText='';
        }
//end menu functions
function  changefontsize(flag){
var step=1;
var current=parseInt(document.getElementById('content1').style.fontSize.substring(-1,2));
    if(flag){
      if(current<18){
      document.getElementById('content1').style.fontSize=current+step+'px';
      document.getElementById('content2').style.fontSize=current+step+'px';
      }
    }
    else{
      if(current>12){
      document.getElementById('content1').style.fontSize=current-step+'px';
      document.getElementById('content2').style.fontSize=current-step+'px';
      }
    }
    

}

var tLast = 'tab1';
var sLast = 'sk';
var SrTxt = new Array();
SrTxt['sk'] = 'Nájdi na internete:';
SrTxt['fr'] = 'Nájdi v obrázkoch:';
SrTxt['mp'] = 'Nájdi na mapách:';
SrTxt['rf'] = 'Nájdi v referátoch:';
SrTxt['sl'] = 'Nájdi v slovníkoch:';

function swSrch(tNow,sNow)
{
	if(sNow == sLast) return false;
	if(!sLast) sLast = 'sk'; if(!tLast) tLast = 'tab1';
	document.getElementById('li'+tNow).className = 'act';
	document.getElementById('li'+tLast).className = '';
	
	document.getElementById('searchText').innerHTML = SrTxt[sNow];
	document.getElementById('whatsearch').value = sNow;
	
	if(sNow == 'sl') { 
    document.getElementById('slsel').style.display = '';
    document.getElementById('phrase').style.width = '232px';
  } 
	else { 
    document.getElementById('slsel').style.display = 'none';
    document.getElementById('phrase').style.width = '300px';
    }
	sLast = sNow; tLast = tNow;
} 


function changeNewest(count){
  if (!currentnewstmenu) currentnewstmenu=2;//id of the first category
  new Ajax('images/newest_in.php', {
      		method: 'post',
      		postBody:'count='+count+'&current='+currentnewstmenu,
      		update: $('newestcontent')
      	   }).request();
}


function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) 
    elem = document.getElementById( whichLayer );
  else if( document.all ) 
      elem = document.all[whichLayer];
  else if( document.layers ) 
    elem = document.layers[whichLayer];
  vis = elem.style;
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function radioWin(url) {   
  	newwindow=window.open(url,'Moje_radio','height=450,width=670');
  	if (window.focus) {newwindow.focus()}
  	return false;
  }
function switchRadio(direc){
/*  if(!Boolean(typeof cur_radio != 'undefined' && cur_radio)){
    var cur_radio=1;
  }
  if(!Boolean(typeof radio_cnt != 'undefined' && radio_cnt)){
    var radio_cnt=7;
  }*/
  //alert(cur_radio);
  if(direc){//next
  $('radio_'+cur_radio).style.display="none";
    if(cur_radio+1<=radio_cnt)
      cur_radio=cur_radio+1;
    else
      cur_radio=1;
  $('radio_'+cur_radio).style.display="block";
  }else{
  $('radio_'+cur_radio).style.display="none";
    if(cur_radio-1>0 ){//previous
      cur_radio=cur_radio-1;  
    }else{
      cur_radio=radio_cnt;
    }
  $('radio_'+cur_radio).style.display="block";
  }
  //alert(cur_radio);
}        
