function checkAnketa(f) {
	var check = false;
	var len = f.answer_id.length;

	for(var i = 0; i < len; i++)
		if(f.answer_id[i].checked == true)
   			check = true;

	if(!check) {
		alert("Niste izbrali odgovora!");
		return false;
	}

	return true;
}


var currentContainer = 'tab1';

function clickTab(el){
	el.blur();
	var clickedContainer = $(el.id.replace('_button',''));	
	var cont = $(currentContainer);		
	var clickedButton = $(el.id);
	
	if(clickedContainer.id != currentContainer){
		resetButtons();
		clickedButton.className = 'active';
		clickedButton.tween('padding','7 34 5 34');	
	
		cont.style.visibility = 'hidden';
		clickedContainer.style.visibility = 'visible';
	
		currentContainer = el.id.replace('_button','');
	}
}

function resetButtons(){
	$('tab1_button').className = 'tab';
	$('tab2_button').className = 'tab';
	$('tab3_button').className = 'tab';
	$('tab1_button').tween('padding','7 12 5 13');	
	$('tab2_button').tween('padding','7 12 5 13');
	$('tab3_button').tween('padding','7 12 5 13');
}
		

var activepic = 1;
function overButton(el){	
	var number = el.id.replace('button','');
	if(activepic != number){
		
		
		$('fadepic'+activepic).tween('opacity',[1,0]);
		
		
		activepic = number;
		
		$('button1').className = 'button';
		$('button2').className = 'button';
		$('button3').className = 'button';
		$(el.id).className = 'button button_on';
		
		if(activepic == 1) {
			randno = Math.floor ( Math.random() * pekoPics.length ); 
			$('fadepic'+activepic).src = pekoPics[randno];
			var image = $('fadepic'+activepic);
		}
		else if(activepic == 2) {
			randno = Math.floor ( Math.random() * exPics.length ); 
			$('fadepic'+activepic).src = exPics[randno];
			var image = $('fadepic'+activepic);
		}
		else {
			randno = Math.floor ( Math.random() * orPics.length ); 
			$('fadepic'+activepic).src = orPics[randno];
			var image = $('fadepic'+activepic);
		}
			
		
		image.tween('opacity',[1,0]);
		image.tween('opacity',[0,1]);	
		
		$('playlink').href = $('link'+activepic).href;
	}
}
function goto_nextButton(){
	if(activepic == 1){
		overButton(document.getElementById('button2'));
	}
	else if(activepic == 2){
		overButton(document.getElementById('button3'));		
	}
	else if(activepic == 3){
		overButton(document.getElementById('button1'));
	}
}

var intval = '';
function startFader(){
	intval = window.setInterval("goto_nextButton()", 3000);	
}
function stopFader(){
	if(intval != ''){
		window.clearInterval(intval);
		intval = '';
	}
}

function setHome()
{
   document.body.style.behavior='url(http://www.n-tv.si/)';
   document.body.setHomePage(window.location.href);
}



