function display(id) {
	document.getElementById('add_file').style.display = 'none';
	document.getElementById('add_folder').style.display = 'none';
	document.getElementById(id).style.display = 'table-row';
}




function meny(objId) {
	var image = document.images[objId+'_img'];
	var o1 = (document.all) ? document.all[objId] : document.getElementById(objId);

	if(o1.style.display == 'block') {
		o1.style.display = 'none';
		image.src = 'plus.jpg';
	} else if(o1.style.display == 'none') {
		o1.style.display = 'block';
		image.src = 'minus.jpg';
	}
}

window.onload = function() {
	var loaded = new Image();
	loaded.src = 'minus.jpg';
}






var addthis_options = 'facebook, google, live, email, myspace, favorites, more';
var addthis_language = "sv";
var addthis_header_color = "#eaeaea";
var addthis_header_background = "#373737";
var addthis_pub="edgren";
var addthis_hover_delay = 200;

var addthis_localize = {
	share_caption: "Dela / Bokmärk <b>Koroth Nyhet</b>",
	email_caption: "Skicka denna nyhet till en kompis",
	email: "Epost",
	favorites: "Favoriter",
	more: "Mer..."
};


/*
* Simple Tooltip Object v.1.0
*
* @author Bobo Wieland, bobo@plucera.se 
* @copyright (C) 2007-2008, Plucera AB, http://www.plucera.se
*/
var Tip = {

box : null,

fadeInInterval : null,
fadeOutInterval : null,

init : function() {
	/*
	this.box = document.createElement("div");
	this.box.id = "tooltip";
	*/

	document.getElementsById.style.background = "url(images/50_bg.png)";
	document.getElementsById.box.style.padding = "5px";
	document.getElementsById.box.style.opacity = 0;
	document.getElementsById.box.style.filter = "alpha(opacity=0)";
	document.getElementsById.box.style.display = "none";
	document.getElementsByTagName("body").item(0).appendChild(this.box);
},

show : function(_lmnt, _tip) {

if (!this.box) { this.init(); }

var curleft = curtop = 0;
if (_lmnt.offsetParent) {
	curleft = _lmnt.offsetLeft
	curtop = _lmnt.offsetTop
	while (_lmnt = _lmnt.offsetParent) {
		curleft += _lmnt.offsetLeft
		curtop += _lmnt.offsetTop
	}
}

this.box.style.left = Math.max((curleft - 215),5) + "px";
this.box.style.top = (curtop + 20) + "px";
this.box.innerHTML = _tip;
clearInterval(this.fadeOutInterval);
this.box.style.display = "block";
this.fadeInInterval = setInterval(function() {
	if (parseFloat(Tip.box.style.opacity) >= 0.9) {
		Tip.box.style.opacity = 0.9;
		Tip.box.style.filter = "alpha(opacity=90)";
		clearInterval(Tip.fadeInInterval);
	} else {
		var fract = parseFloat(Tip.box.style.opacity) + 0.1;
		Tip.box.style.opacity = fract;
		Tip.box.style.filter = "alpha(opacity=" + (fract*100) + ")";
	}
}, 50);
},

hide : function() {

if (!this.box) { this.init(); }

clearInterval(this.fadeInInterval);
this.fadeOutInterval = setInterval(function() {
if (parseFloat(Tip.box.style.opacity) <= 0) {
	Tip.box.style.opacity = 0;
	Tip.box.style.filter = "alpha(opacity=0)";
	Tip.box.style.display = "none";
	Tip.box.innerHTML = "";
	clearInterval(Tip.fadeOutInterval);
} else {
	var fract = parseFloat(Tip.box.style.opacity) - 0.1;
	Tip.box.style.opacity = fract;
	Tip.box.style.filter = "alpha(opacity=" + (fract*100) + ")";
}
},50);
}
}




function checkbox(id1, id2) {
	id1 = document.getElementById(id1);
	id2 = document.getElementById(id2);

	if(id1.value == '0') {
		id2.src = 'images/checkbox_checked.png';
		id1.value = '1';
	} else {
		id2.src = 'images/checkbox_unchecked.png';
		id1.value = '0';
	}
}





function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;

// OBS! ingen radbrytning i texten nedan
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable,dependent'
//slut på område utan radbrytning

win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}


function openMoveTopicPopup() {
	document.getElementById("popup_movetopic").style.display="block";
}

function closeMoveTopicPopup() {
	document.getElementById("popup_movetopic").style.display="none";
}


function openDeletePopup() {
	document.getElementById("popup_delete").style.display="block";
}

function closeDeletePopup() {
	document.getElementById("popup_delete").style.display="none";
}


function addText(text) {
	var txtarea = document.getElementById('my_text');
	txtarea.value += text;
	txtarea.focus();
}


function checkAll(field) {
	for(i = 0; i < field.length; i++)
	field[i].checked = true ;
	document.myform.structure.checked = false;
	document.myform.sameServer.checked = false;
}


function start_ajax(id) {
	MakeRequest(id);
	setTimeout("start_ajax('"+id+"')", 1000);
}


function start_serverajax(ip, port) {
	MakeRequestServer(ip, port);
	setTimeout("start_serverajax('"+ip+"', '"+port+"')", 1000);
}


function start_statisticajax() {
	MakeRequestStatistic();
	setTimeout("start_statisticajax()", 5000);
}


function checkLen(x,y) {
	if(y.length==x.maxLength) {
		var next=x.tabIndex;

		if(next<document.getElementById("myForm").length) {
			document.getElementById("myForm").elements[next].focus();
		}
	}
}



function meny(objId) {
	var o1 = document.getElementById(objId);

	if(o1.style.display=="block") {
		o1.style.display = "none";
	} else if(o1.style.display == "none") {
		o1.style.display = "block";
	}
}



function warnLen(x,y) {
	if(y.length==x.maxLength) {
		x.style.border = "1px solid #d35454"
	} else {
		x.style.border = "1px solid #8c8271"
	}
}



function loadSplash() {
	var width = (screen.width / 2) - 495;
	var height = screen.height / 55;

	var dimlayer = document.getElementById('dimLayer');
	dimlayer.style.display = 'block';

	var splash = document.getElementById('splash');

	splash.style.top = height + 'px';
	splash.style.left = width + 'px';
	splash.style.display = 'block';
}

function closeSplash() {
	document.getElementById('splash').style.display = 'none';
	document.getElementById('dimLayer').style.display = 'none';
} 



function showhide(id1, id2) {
	if(document.getElementById) {
		var obj1 = document.getElementById(id1);
		var obj2 = document.getElementById(id2);
	} else if(document.all) {
		var obj1 = document.all(id1);
		var obj2 = document.all(id2);
	}

	if(obj1.style.display == 'none') {
		obj1.style.display = 'block';
		obj2.style.display = 'none';
	} else {
		obj1.style.display = 'none';
		obj2.style.display = 'block';
	}
}



// Ett nytt fönster
function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=730,height=700,left = 147,top = 184');");
}



// 
var maxChar = 5000000;
function checkChars() {
	countChars(document.getElementById('my_text'));
}

function countChars(field) {
	if(field.value.length > maxChar)
	field.value = field.value.substring(0, maxChar);

	if(field.value.length == maxChar) {
		color = '#efb0b0';
	} else {
		color = '#eaeaea';
	}

	document.getElementById('counter').innerHTML = "<span style=\"color: " + color + ";\">" + field.value.length + "</span>";
}



function countUp(divId, counter, score) {
	document.getElementById(divId).innerHTML = counter+'%';

	if(counter != score) {
		setTimeout("countUp('"+divId+"', "+(counter+1)+", "+score+")", 40);
	}
}