var active_anim=null;
var last_button = null;
var last_panel = null;
var last_button2 = null;
var last_panel2 = null;
var last_gradche = null;

var last_button_profile = null;
var last_panel_profile = null;

var last_button_twotabs = null;
var last_panel_twotabs = null;

var allow_toggle = 1;


	function vremetoSelect(grad){
			
			var gradche = document.getElementById('vremeto-'+grad);
			if (last_gradche != null){ 
				new Effect.Opacity('vremeto-'+last_gradche, {duration:0.3, from:1.0, to:0.0});
				setTimeout(function(){document.getElementById('vremeto-'+last_gradche).style.display = 'none'}, 300);
			}
			setTimeout(function(){
			gradche.style.display = '';
			last_gradche = grad;
			new Effect.Opacity('vremeto-'+grad, {duration:0.8, from:0.0, to:1.0});
			}, 300);
	}
	function daljina(id, limit){
		var obekt = document.getElementById(id);
		var span = document.getElementById(id+'_span');
		var daljina = obekt.value.length;
		if(limit < daljina){
			obekt.value = obekt.value.substring(0, limit);
		}
		span.innerHTML = limit-daljina+' ';
		

	}

	
var televizii_counter = 0;
	
	setInterval ("changeTelevizii()", 5000 );
	
	function changeTelevizii(){
		televizii_counter++;
		document.getElementById('tvprograma').innerHTML = document.getElementById('tvprograma_'+televizii_counter).innerHTML;
		if(televizii_counter=='3'){
			televizii_counter = 0;
		}
	}
	
	function obiava_toggle(id){
		var obiava = document.getElementById('obiava_'+id);
		
		if(obiava.style.display=='none'){
			new Effect.SlideDown(obiava, {duration:0.2});
		}else{
			new Effect.SlideUp(obiava, {duration:0.2});

		}
		
	}
	
		function obektToggle(id){
		var obekt = document.getElementById(id);
		
		if(obekt.style.display == 'none'){
			obekt.style.display = 'inline';
		}else{
			obekt.style.display = 'none';

		}
		
	}
	
var min = 11;
var max = 18;

	function novinaUpper(id){
   var p = document.getElementById(id);
      if(p.style.fontSize) {
         var s = parseInt(p.style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p.style.fontSize = s+"px"

	}
	function novinaSmaller(id){
   var p = document.getElementById(id);
      if(p.style.fontSize) {
         var s = parseInt(p.style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p.style.fontSize = s+"px"
	}
	

function slojiKvartaliAdd()
{
	var obj = document.getElementById('adddistrict');
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
	document.getElementById('adddistrict').disabled = '';
}
		
function slojiKvartali()
{
	var obj = document.getElementById('district');
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
	document.getElementById('district').disabled = '';
}

		function upper(id,elem)
		{
			//if (interval) window.clearInterval(interval);
			
		
			var a = document.getElementById(id);
			var el = document.getElementById(elem);
			if (last_button != null){ 
				document.getElementById(last_button).className = 'righttabs_nactive';
				document.getElementById(last_panel).style.display = 'none';
			}
			a.className = 'righttabs_active';
			//a.style.display='block';
			//new Effect.Opacity(elem, {duration:0.3, from:0.0, to:1.0});
			el.style.display = '';
			
			last_button = id;
			last_panel = elem;
		}

		function upper2(id,elem)
		{
			//if (interval) window.clearInterval(interval);
			
		
			var a = document.getElementById(id);
			var el = document.getElementById(elem);
			if (last_button2 != null){ 
				document.getElementById(last_button2).className = 'righttabs_nactive';
				document.getElementById(last_panel2).style.display = 'none';
			}
			a.className = 'righttabs_active';
			//a.style.display='block';
			el.style.display = '';
			last_button2 = id;
			last_panel2 = elem;
		}

		function upperProfile(id,elem)
		{
			//if (interval) window.clearInterval(interval);
			
		
			var a = document.getElementById(id);
			var el = document.getElementById(elem);
			if (last_button_profile != null){ 
				document.getElementById(last_button_profile).className = 'profiletabs_nactive';
				document.getElementById(last_panel_profile).style.display = 'none';
			}
			a.className = 'profiletabs_active';
			el.style.display = '';
			last_button_profile = id;
			last_panel_profile = elem;
		}

		function upperTwoTabs(id,elem)
		{
			//if (interval) window.clearInterval(interval);
			
		
			var a = document.getElementById(id);
			var el = document.getElementById(elem);
			if (last_button_twotabs == id){
						if(allow_toggle == 1){
							if(document.getElementById(id).className=='indextabs_active'){
							document.getElementById(last_button_twotabs).className = 'indextabs_nactive';
							document.getElementById(last_panel_twotabs).style.display = 'none';	
							}else{
								document.getElementById(last_button_twotabs).className = 'indextabs_active';
							document.getElementById(last_panel_twotabs).style.display = '';								
							}
						}
			}else{
				if (last_button_twotabs != null){ 
					document.getElementById(last_button_twotabs).className = 'indextabs_nactive';
					document.getElementById(last_panel_twotabs).style.display = 'none';
				}
				
				a.className = 'indextabs_active';
				el.style.display = '';
				last_button_twotabs = id;
				last_panel_twotabs = elem;
			}
		}


		function upperTVTabs(id,elem)
		{
			//if (interval) window.clearInterval(interval);
			
		
			var a = document.getElementById(id);
			var el = document.getElementById(elem);
			if (last_button_twotabs == id){
						if(allow_toggle == 1){
							if(document.getElementById(id).className=='tvtabs_active'){
							document.getElementById(last_button_twotabs).className = 'tvtabs_nactive';
							document.getElementById(last_panel_twotabs).style.display = 'none';	
							}else{
								document.getElementById(last_button_twotabs).className = 'tvtabs_active';
							document.getElementById(last_panel_twotabs).style.display = '';								
							}
						}
			}else{
				if (last_button_twotabs != null){ 
					document.getElementById(last_button_twotabs).className = 'tvtabs_nactive';
					document.getElementById(last_panel_twotabs).style.display = 'none';
				}
				
				a.className = 'tvtabs_active';
				el.style.display = '';
				last_button_twotabs = id;
				last_panel_twotabs = elem;
			}
		}
		
		var izbranDen = 2;
		
		function tabKinoCity(cityId){
		    izbranDen = cityId;
  		  var denFilter = '_dnes';
  		  if(document.getElementById('kinoFilterUtre').className=='mov-today'){
          denFilter = '_utre';
        }
        var objects = $$('td.mov-up-links-btn-active');
        objects.each(function(obj){ obj.className = 'mov-up-links-btn-inactive-right'; });
        
        var objects = $$('a.mov-up-link-active');
        objects.each(function(obj){ obj.className = 'mov-up-link-inactive'; });
        
        document.getElementById('kinoTd'+cityId).className = 'mov-up-links-btn-active';
        document.getElementById('kinoLink'+cityId).className = 'mov-up-link-active';
        
        $$('div.mov-right-program div').each(function(el){ el.style.display = 'none'; });
        document.getElementById('programCity'+cityId).style.display = '';
        document.getElementById('programCity'+cityId+denFilter).style.display = '';
    }
    
    function changeDenFilter(dnesutre){
      if(dnesutre=='dnes'){
        document.getElementById('kinoFilterDnes').className = 'mov-today';
        document.getElementById('kinoFilterUtre').className = 'mov-tom';
        document.getElementById('programCity'+izbranDen+'_utre').style.display = 'none';
        document.getElementById('programCity'+izbranDen+'_dnes').style.display = '';
      }else{
        document.getElementById('kinoFilterDnes').className = 'mov-tom';
        document.getElementById('kinoFilterUtre').className = 'mov-today';     
        document.getElementById('programCity'+izbranDen+'_dnes').style.display = 'none';
        document.getElementById('programCity'+izbranDen+'_utre').style.display = '';
      }
    }
