var selectedTab = null;
var selectedTabLink = null;

function initTabs() {
	var tabLinks = document.getElementById("tabs").getElementsByTagName("a");
	for(var i=0; i<tabLinks.length; i++) {
		var trigger = tabLinks[i];
		trigger.setAttribute("onclick", "toggleTab(this); return false;");
		trigger.onclick = function() {
								toggleTab(this);
								return false;
							};
		var tabContainer = document.getElementById(trigger.href.substring(trigger.href.lastIndexOf("#")+1, trigger.href.length));
		tabContainer.style.display = "none";
	}
	toggleTab(tabLinks[0]);
}
function toggleTab(o) {
	if(selectedTab != null) {
		selectedTab.style.display = "none";
		selectedTabLink.className = "";
	}
	
	var ref = o.href.substring(o.href.lastIndexOf("#")+1, o.href.length);
	var tab = document.getElementById(ref);
	if(tab) {
		if(tab.style.display == "block") {
			tab.style.display = "none";
			o.className = "";
		} else {
			tab.style.display = "block";
			o.className = "selected";
		}
		selectedTab = tab;
		selectedTabLink = o;
	}
}
/*
function expandcollapse(anchor, thecomment) {
    var span = document.getElementById(thecomment);
    span.style.display = 'block';
    anchor.style.display = 'none';
}
*/

function expandcollapse(anchor, thecomment, thecommentsummary) {
	
	var thecomment = document.getElementById(thecomment);
	var thecommentsummary = document.getElementById(thecommentsummary);
	
	thecomment.style.display = (thecomment.style.display=='none')?'inline':'none';
	thecommentsummary.style.display = (thecommentsummary.style.display=='inline')?'none':'inline';
	
	anchor.innerHTML = (anchor.innerHTML=='Visa kommentar')?'Dolj kommentar':'Visa kommentar';
}

/*
function expandcollapsebox(anchor, thebox) {
	var thebox = document.getElementById(thebox);
	thebox.style.display = (thebox.style.display=='block')?'none':'block';
	anchor.innerHTML = (anchor.innerHTML=='<img src="http://advantage-environment.com/arrow-right.gif">')?'<img src="http://advantage-environment.com/arrow-down.gif">':'<img src="http://advantage-environment.com/arrow-right.gif">';
}
*/

function expandcollapsebox(anchor, thebox) {
	var thebox = document.getElementById(thebox);
	thebox.style.display = (thebox.style.display=='block')?'none':'block';
	anchor.innerHTML = (anchor.innerHTML.match("arrow-right")) ? anchor.innerHTML.replace("arrow-right", "arrow-down") : anchor.innerHTML.replace("arrow-down", "arrow-right");
}