
function showhide(id){
	if(document.getElementById(id).style.display != 'none'){
		if(document.getElementById('switch_'+id)) document.getElementById('switch_'+id).src = 'http://skillfights.com/templates/images/symbols/plus.png';
		if(document.getElementById('anchor_'+id)) document.getElementById('anchor_'+id).className = 'black';
		document.getElementById(id).style.display = 'none';
	}else{
		if(document.getElementById('switch_'+id)) document.getElementById('switch_'+id).src = 'http://skillfights.com/templates/images/symbols/minus.png';
		if(document.getElementById('anchor_'+id)) document.getElementById('anchor_'+id).className = 'red';
		document.getElementById(id).style.display = '';
	}
}

function show(eid){
	if(document.getElementById(eid).style.display == 'none'){
		if(document.getElementById('switch_'+eid)) document.getElementById('switch_'+eid).src = 'http://skillfights.com/templates/images/symbols/minus.png';
		if(document.getElementById('anchor_'+eid)) document.getElementById('anchor_'+eid).className = 'red';
		document.getElementById(eid).style.display = '';
	}
}

function hide(eid){
	if(document.getElementById(eid).style.display != 'none'){
		if(document.getElementById('switch_'+eid)) document.getElementById('switch_'+eid).src = 'http://skillfights.com/templates/images/symbols/plus.png';
		if(document.getElementById('anchor_'+eid)) document.getElementById('anchor_'+eid).className = 'blue';
		document.getElementById(eid).style.display = 'none';
	}
}

function favswitch(){
	document.getElementById('favadd').src = (document.getElementById('favadd').src == 'http://skillfights.com/templates/images/symbols/favadd.png') ? 'http://skillfights.com/templates/images/symbols/favadd_over.png' : 'http://skillfights.com/templates/images/symbols/favadd.png';
}

function switchflag(flag){
	document.getElementById('flag').src = 'http://skillfights.com/templates/images/countries/'+flag+'.png';
}

function countchars(id,max){
	document.getElementById(id+'_chars').innerHTML = max-document.getElementById(id).value.length;
}

function popup(tpl,path,info){
	if(document.getElementById('popup')){
		document.body.removeChild(document.getElementById('popup'));
		document.body.removeChild(document.getElementById('overlay'));
	}else{
		var myWidth = 0, myHeight = 0;
		if(typeof(window.innerWidth ) == 'number'){
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		}else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)){
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		}else if(document.body && (document.body.clientWidth || document.body.clientHeight)){
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}

		var objBody = document.getElementsByTagName("body").item(0);
		var objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','overlay');
		objOverlay.style.height = myHeight+'px';
		objOverlay.style.width = myWidth+'px';
		objBody.insertBefore(objOverlay, objBody.firstChild);
		var box = document.createElement("div");
		box.setAttribute('id','popup');
		var headtitle = tpl.replace('_',' - ');
		box.innerHTML = '<div class="cathead"><div class="float75"><h1><img src="http://skillfights.com/templates/images/symbols/popup.png" alt="" /> '+headtitle+'</h1></div><div class="float25 right"><a href="javascript:popup()"><img src="http://skillfights.com/templates/images/symbols/close.png" alt="" /></a></div><div class="clearer"></div></div><div class="contentbox" id="popcont"><div class="center bold"><img src="http://skillfights.com/templates/images/ajax-loader.gif" alt="loading" /><br/>Loading</div></div>';
		box.style.left = (myWidth/2)-(myWidth/8)+'px';
		box.style.top = (myHeight/2)-(myHeight/8)+'px';
		objBody.insertBefore(box, objBody.firstChild);
		tpl = (tpl) ? tpl : 'about';
		tpl = (path) ? path+tpl : 'includes/help/en/'+tpl;
		new Ajax.Updater('popcont','http://skillfights.com/ajax', { parameters: { mode: 'showTpl', tpl: tpl, info:info } });
	}
}