
function swap_content( span ) {
	var set=( document.getElementById( span ).style.display == 'none' ) ? 'block' : 'none';
	document.getElementById( span ).style.setAttribute("display", set, false);
}

function swapstatus( span ) {
	if(document.getElementById( span ).className == 'swapper') return false;
	else return true;
}
var swapnewscatvar=0;
function swapnewscat( id ) {
	swapout('cat['+swapnewscatvar+']');
	swapin('cat['+id+']');
	swapnewscatvar=id;
}

function swapper( span, clas ) {
	displayType = ( document.getElementById( span ).className == 'swapper' ) ? clas : 'swapper';
	document.getElementById( span ).className = displayType;
}

function swapin( span, clas ) {
	document.getElementById( span ).className = clas;
}

function swapout( span ) {
	document.getElementById( span ).className = 'swapper';
}

function swapid( id, lang) {
	for(var i=-10;i<=lang;i++) {
		if(document.getElementById( 'cat['+i+']' ) && id!=i) swapout( 'cat['+i+']');
	}
	swapper( 'cat['+id+']');
	//if(!swapstatus('cat['+id+']')) swapin( 'cat[1]' );
}

function swapcustomid( id, lang, pre) {
	for(var i=-10;i<=lang;i++) {
		if(document.getElementById( pre + i ) && id!=i) swapout( pre + i );
	}
	swapper( pre + id);
	//if(!swapstatus('cat['+id+']')) swapin( 'cat[1]' );
}

function swapid2( id, lang) {
	for(var i=-5;i<=lang;i++) {
		if(document.getElementById( 'cat['+i+']' ) && id!=i) {
			swapout( 'cat['+i+']');
			document.getElementById( 'clink['+i+']' ).style.fontWeight="normal";
		}
	}
	document.getElementById( 'clink['+id+']' ).style.fontWeight="bold";
	swapper( 'cat['+id+']');
}

function plus_minus( span, span2) {
	displayType = ( document.getElementById( span ).style.display == 'none' ) ? 'block' : 'none';
	document.getElementById( span ).style.display = displayType;
	displayType = ( document.getElementById( span2 ).innerText == '+' ) ? '-' : '+';
	document.getElementById( span2 ).innerText=displayType;
}

function checkall( form, el ) {
	var set = el.checked;
	for(x=0;x<document.forms[form].elements.length;x++){
		if(document.forms[form].elements[x].type == 'checkbox') document.forms[form].elements[x].checked = set;
	}
}

function decheck( el, form, all ) {
	if(!el.checked) document.forms[form].elements[all].checked=false;
	else {
		var checker=true;
		for(var x=0;x<document.forms[form].elements.length;x++){
			if(document.forms[form].elements[x].type == 'checkbox' && document.forms[form].elements[x].name!=all && !document.forms[form].elements[x].checked) {
				checker=false;
				break;
			}
		}
		if(checker) document.forms[form].elements[all].checked=true;
	}
}

function imageswap(id) {
	var el=document.getElementById('pm'+id).src;
	var s=el.substr(el.lastIndexOf("/")+1,el.length);
	if(s=="plus.gif") document.getElementById('pm'+id).src="images/minus.gif";
	else document.getElementById('pm'+id).src="images/plus.gif";
}

function swapimg(id) {
	var el=document.getElementById(id).src;
	var s=el.substr(el.lastIndexOf(".")-1,1);
	var img=el.substring(el.lastIndexOf("/")+1,el.lastIndexOf("."));
	var ext=el.substring(el.lastIndexOf(".")+1,el.length);
	if(s=="-") document.getElementById(id).src="images/"+img.substr(0,img.length-1)+"."+ext;
	else document.getElementById(id).src="images/"+img+"-."+ext;
}

function pfeilswap(id) {
	var el=document.getElementById('pm'+id).src;
	var s=el.substr(el.lastIndexOf("/")+1,el.length);
	if(s=="arrow.gif") document.getElementById('pm'+id).src="images/arrow-.gif";
	else document.getElementById('pm'+id).src="images/arrow.gif";
}

function messagesswap(id) {
	swapper('msg'+id);
	pfeilswap(id);
	if(document.getElementById('link'+id).style.fontWeight=="bold") {
		document.getElementById('link'+id).style.fontWeight="normal";
		document.msgreader.location.href="index.php?module=messagereader&read="+id;
	}
}

function boxswap(id) {
	swapper(id);
	swapper(id+'_img1');
	swapper(id+'_img2');
	WertSetzen(id,swapstatus(id),3600000);
}
function boxswapset(id) {
	if(WertHolen(id)=='false') {
		swapper(id);
		swapper(id+'_img1');
		swapper(id+'_img2');
	}
}

function CheckStr( input, max, lenfield ) {
	var StrLen = document.getElementById(input).value.length;
	if(StrLen>=max) document.getElementById(input).value=document.getElementById(input).value.substr(0,max-1);
	var StrLeft = max - StrLen;
	if(document.getElementById(lenfield)) document.getElementById(lenfield).value = StrLeft;
}

function swapvalue(id) {
	document.getElementById(id).value=(document.getElementById(id).value=='0')?'1':'0';
}

function preload()
{
	document.Vorladen = new Array();
	if(document.images)
	{
		for(var i=0; i<preload.arguments.length; i++)
		{
			document.Vorladen[i] = new Image();
			document.Vorladen[i].src = preload.arguments[i];
		}
	}
}

function clear_text (obj,text) {
	if (!obj.value) {
		obj.value=text;
	}
}

function favhighlight(w) {
	for (i=1; i<=3; i++) {
		document.getElementById("favmenu"+i).className="favnavi";
		document.getElementById("pixels"+i).className="swapper";
		if (i==w) {
			document.getElementById("favmenu"+i).className="favnaviactive";
			document.getElementById("pixels"+i).className="swapperv";
		}
	}
}


/********************* INPUTBOX BEGIN *****************************/
var inputevt;
var IField;
function begindrag() {
	document.onmousemove=draginputbox;
	gel("inputbox").style.cursor="move";
	document.onselectstart=retfalse;
}
function draginputbox(obj) {
	momX=document.all ? window.event.x : obj.pageX;
	momY=document.all ? window.event.y : obj.pageY;
	//hX=parseInt(inputevt.style.left.substr(0,inputevt.style.left.length-2));
	//hY=parseInt(inputevt.style.top.substr(0,inputevt.style.top.length-2));
	Input=gel("inputbox");
	Input.style.left=momX-Input.offsetWidth/2+getScrolling()[0]+"px";
	Input.style.top=momY-Input.offsetHeight/2+getScrolling()[1]+"px";
}
function enddrag() {
	document.onmousemove=null;
	gel("inputbox").style.cursor="auto";
	document.onselectstart=null;
	IField.focus();
}
function handleinput(callfunc) {
	gel("inputbox").style.visibility="hidden";
	inputted=IField.value;
	IField.value="";
	IField.blur();
	eval(callfunc);
}
function showinputbox(txtval,posX,posY,callfunc,txtValue,txtWidth,txtMaxlength) {
	Input=gel("inputbox");
	if (!Input) {
		var Input=document.createElement("div");
		Input.id="inputbox"; Input.className="greybox"; Input.onmousedown=begindrag; Input.onmouseup=enddrag;
		document.body.appendChild(Input);
		width=txtWidth? txtWidth-8 : 174;
		txtValue=txtValue? " value='"+txtValue+"'":"";
		txtMaxlength=txtMaxlength? " maxlength='"+txtMaxlength+"'":"";
		textbox="<table border='0' cellpadding='0' cellspacing='0' width=width height='17'><tr><td width='3'><img src='layouts/default/images/textfeld_white_l.gif' style='margin:0px;'></td><td width='"+(width-6)+"' background='layouts/default/images/textfeld_white_m.gif'><input style='width:"+(width-6)+"px;' class='textfeld2'"+txtValue+txtMaxlength+"></td><td width='3'><img src='layouts/default/images/textfeld_white_r.gif'></td></tr></table>";
		a="<div class='inputbox_text'></div><br><form onsubmit="+String.fromCharCode(34)+"handleinput('"+callfunc+"'); return false;"+String.fromCharCode(34)+">"+textbox+"</form>";
		Input.innerHTML=a;
	}
	Input=gel("inputbox");
	Input.style.visibility="visible";
	Input.firstChild.innerHTML="Enter your title:";
	Input.style.left=posX+"px";
	Input.style.top=posY+"px";
	IField=Input.childNodes[2].firstChild.firstChild.firstChild.childNodes[1].firstChild;
	IField.focus();
	return Input;
}
/********************* INPUTBOX END *****************************/

/********************* TEAMSWITCH ******************************/
function getScrolling() {
	var a = new Array();
	if (document.documentElement.scrollTop||document.documentElement.scrollLeft) {
		a[1] = document.documentElement.scrollTop;
  		a[0] = document.documentElement.scrollLeft
  	}
	else {
		a[1] = document.body.scrollTop;
		a[0] = document.body.scrollLeft;
	}
	return a;
}



var doslide=false;
var issliding=false;
function switchts(change) {
	if (!issliding) settspicpos(change,0);
}
function settspicpos(change,incr_count) {
	issliding=true;
	var speed=2; //pixelpermillisecond
	incr_count++;
	if (incr_count<Math.ceil(53/speed)) {
		window.setTimeout("settspicpos("+change+","+incr_count+")",1);
		factor=speed;
	}
	else factor=(53-Math.floor(53/speed)*speed);
	gel("tspics").style.left=gel("tspics").style.left.substr(0,gel("tspics").style.left.indexOf("px"))-(change*factor)+"px";
	if (incr_count==Math.ceil(53/speed)) { //letzter slidedurchlauf
		a=gel("tspics").style.left.substr(0,gel("tspics").style.left.indexOf("px"));
		if (a<0) {
			gel("ts_arl").className="ts_pl";
			gel("ts_arl").onmouseover=changetspicposleft;
			gel("ts_arl").onmouseout=endpicposchange;
		}
		else {
			gel("ts_arl").className="none";
			gel("ts_arl").onmouseover=null;
			gel("ts_arl").onmouseout=null;
			doslide=false;
		}
		//gel("tspics").firstChild.firstChild.firstChild.firstChild.childNodes.length*53) =^ gel("tspics").offsetWidth = tspicsoW
		tspicsoW = gel("tspics").firstChild.firstChild.firstChild.firstChild.childNodes.length*53;
		if (a>(-((tspicsoW-gel("tspics").parentNode.parentNode.offsetWidth)-3))) {
			gel("ts_arr").className="ts_pr";
			gel("ts_arr").onmouseover=changetspicposright;
			gel("ts_arr").onmouseout=endpicposchange;
		}
		else {
			gel("ts_arr").className="none";
			gel("ts_arr").onmouseover=null;
			gel("ts_arr").onmouseout=null;
			doslide=false;
		}
		issliding=false;
		if (doslide) switchts(change);
	}
}
function startpicposchange() {
	doslide=true;
}
function endpicposchange() {
	doslide=false;
}

function changetspicposleft() {
	startpicposchange();
	switchts(-1);
}
function changetspicposright() {
	startpicposchange();
	switchts(1);
}

function showteam(id, iteration) {
	strURL="?module=teamswitch&squadid="+id;
	sendRequest( strURL, null, null, '', 'refreshts(xmlHttp.responseText,'+iteration+')');
}
function refreshts(text, it) {
	var obj=gel('tsbox');
	obj.innerHTML = text;
// Highlighter
/*	for(var i=1; el=gel('switchteam_'+i); i++) {
		if(el.className=='subhead_blue') el.className='subhead';
		if(i==it) el.className='subhead_blue';
	}
*/
}