function jsbuttons()
{
	len1=document.getElementsByTagName("input").length;
	len2=document.getElementsByName("jsbutton").length;
	len=len1>len2?len1:len2;
	for (var i = 0; i < len; i++)
	{
		try { document.getElementsByName("jsbutton")[i].style.display="inline-block"; } catch(e){}
		try { if (document.getElementsByTagName("input")[i].className=="htmlsubmit") document.getElementsByTagName("input")[i].style.display="none"; } catch(e){}
	}
}

jsbuttons();

moveobj="";
objMoving=0;
currenttextarea="";
writing=0;
globalmsg="msg";
zcounter=0;
loadesapps="";


switchurltimeout=1000;

clientinfostoreinterval=500000;

function xhr()
{
    var xmlHttp;
    try
	{
		xmlHttp=new XMLHttpRequest();
	}
    catch (e) 
    {
        try
		{ 
			xmlHttp=new ActiveXObject('Msxml2.XMLHTTP');			
		}
        catch (e2) 
        {
			try
			{
				xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');
			}
			catch (e3)
			{
				xmlHttp=false;
			}
        }
     }
	 return xmlHttp;	
}


function rnd(numx)
{
	if (!numx) numx=7;
	return Math.ceil(Math.random()*Math.pow(10, numx));
}

function draw(obj, text)
{
	document.getElementById(obj).innerHTML=text;
}

function busy()
{
	//document.getElementById('status').style.visibility="visible";
}

function free()
{
	//document.getElementById('status').style.visibility="hidden";
}

function ajaxget(url, obj, ev, switchurl, noloadanim, bev, obj2, extratext)
{
	if (noloadanim!=true) busy();
	if (bev) eval(bev);
	var xmlreq=xhr();
	xmlreq.onreadystatechange = function()
	{
		if (xmlreq.readyState==4)
		{
			if (obj && obj!="__gadget") document.getElementById(obj).innerHTML=xmlreq.responseText; 
			if (obj && obj=="__gadget")
			{
				addapp(xmlreq.responseText);
				//showobj("gadget-"+tempname,tempx,tempy);
			}
			if (obj2) document.getElementById(obj2).value=xmlreq.responseText;
			if (ev && xmlreq.responseText && ev!="") eval(ev);
			if (extratext && !xmlreq.responseText) document.getElementById(obj).innerHTML=extratext;
			try { domxml=xmlreq.responseXML } catch(e) {}
			if (noloadanim!=true) free();
			if (switchurl!="" && switchurl) window.setTimeout("gotourl('"+switchurl+"')", switchurltimeout);
		}
	} ; 
	
	if (ie()) { if (!url.match("#\?#i")) url=url+"?cache="+Math.ceil(Math.random()*1000000);
	else url=url+"&cache="+Math.ceil(Math.random()*1000000); }
	
	xmlreq.open("GET", url, true);
	xmlreq.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');		
	xmlreq.send(null);
}

function addapp(html)
{
	var newapp=document.createElement("div");
	newapp.innerHTML=html;
	document.getElementById('ajaxapps').appendChild(newapp);
}

function ajax(url, obj, bev)
{
	if (bev) eval(bev);
	var xmlreq=xhr();
	xmlreq.open("GET", url, true);

	if (ie()) { if (!url.match("#\?#i")) url=url+"?cache="+Math.ceil(Math.random()*1000000);
	else url=url+"&cache="+Math.ceil(Math.random()*1000000); }	
	
	xmlreq.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');	
	xmlreq.send(null);
}

function makepost(str)
{
	return str.replace(/\&/gmi, '%26').replace(/\\+/gmi, '%2b');
}

function ajaxpostget(url, str, obj, ev, noloadanim, bev)
{
	if (noloadanim!=true) busy();
	if (bev) eval(bev);

	var xmlreq=xhr();
	xmlreq.onreadystatechange = function()
	{
		if (xmlreq.readyState==4)
		{
			if (obj && obj!="__gadget") document.getElementById(obj).innerHTML=xmlreq.responseText; 
			if (obj && obj=="__gadget")
			{
				addapp(xmlreq.responseText);
				//showobj("gadget-"+tempname,tempx,tempy);
			}
			if (ev && xmlreq.responseText && ev!="") eval(ev);						
			try { domxml=xmlreq.responseXML } catch(e) {}
			if (noloadanim!=true) free();
		}
	} ; 
	
	if (ie()) { if (!url.match("#\?#i")) url=url+"?cache="+Math.ceil(Math.random()*1000000);
	else url=url+"&cache="+Math.ceil(Math.random()*1000000); }	

	xmlreq.open("POST", url, true); 
	xmlreq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlreq.send(str);
}

function ajaxpost(url, str)
{
	var xmlreq=xhr();	
	
	if (ie()) { if (!url.match("#\?#i")) url=url+"?cache="+Math.ceil(Math.random()*1000000);
	else url=url+"&cache="+Math.ceil(Math.random()*1000000); }	

	xmlreq.open("POST", url, true); 
	xmlreq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlreq.send(str);
}

function input(ele)
{
	return document.getElementById(ele).value;
}

function gotourl(url)
{
	window.location.href=url;
}

function urlescape(str)
{
	return str.replace(/\&/gmi, '%26').replace(/\\+/gmi, '%2b');
}

function newpost()
{
	ajaxpostx="";
}

function addpost(name, val)
{
	add="";
	if (ajaxpostx!="") add="&";
	ajaxpostx=ajaxpostx+add+urlescape(name)+"="+urlescape(val);
}

function runpost(url, switchurl, ev, method, bev, noloadanim)
{
	if (method!=1) ajaxpostget(url, ajaxpostx, "__gadget", ev, noloadanim, bev);
	if (method==1) ajaxpost(url, ajaxpostx, bev);
	ajaxpostx="";
	if (switchurl!="" && switchurl) window.setTimeout("gotourl('"+switchurl+"')", switchurltimeout);
}

function iframeget(url, obj)
{ 
	var xmlreq=xhr();
	xmlreq.onreadystatechange = function()
	{
		if(xmlreq.readyState==4)
		{
			document.getElementById(obj).contentWindow.document.body.innerHTML=xmlreq.responseText; 
			try { domxml=xmlreq.responseXML } catch(e) {}
		}
	} ; 
	
	xmlreq.open("GET", url, true); 
	xmlreq.send(null);
}

function closeopenbar(id)
{
	if (document.getElementById("rb_element_" + id).style.display!="none")
	{
		document.getElementById("rb_control_" + id).src="<?=img()?>pl-plus.png";
		document.getElementById("rb_element_" + id).style.display="none";
		setcookie("rb_element_" + id + "_hidden", "1", 3600*24*365);
	}
	else
	{
		document.getElementById("rb_control_" + id).src="<?=img()?>pl-minus.png";
		document.getElementById("rb_element_" + id).style.display="block";
		killcookie("rb_element_" + id + "_hidden");
	}
}

function setcookie(n,w,e)
{
	var a = new Date();
	a = new Date(a.getTime() +e);
	document.cookie = n+'='+w+'; expires='+a.toGMTString()+';';
}

function getcookie(n)
{
	a = document.cookie;
	res = '';
	while(a != '')
	{
	    while(a.substr(0,1) == ' '){a = a.substr(1,a.length);}
	    cookiename = a.substring(0,a.indexOf('='));
	    if(a.indexOf(';') != -1)
	    {cookiewert = a.substring(a.indexOf('=')+1,a.indexOf(';'));}
	    else{cookiewert = a.substr(a.indexOf('=')+1,a.length);}
	    if(n == cookiename){res = cookiewert;}
	    i = a.indexOf(';')+1;
	    if(i == 0){i = a.length}
	    a = a.substring(i,a.length);
	}
	return(res);
}

function killcookie(n)
{
	document.cookie = n+'=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
}

function getbrowser()
{
    brows=navigator.appName;
    browser="";
    if (brows.match("Explorer")) browser="IE";
    if (brows.match("Opera")) browser="Opera";
    if (brows.match("PSP")) browser="PSP";
    if (brows.match("Firefox")) browser="Firefox";
    if (brows.match("Netscape")) browser="Netscape";
    if (brows.match("Safari")) browser="Safari";
    return browser;
}

function isie()
{
	if (getbrowser()=="IE") return 1;
}

function ie()
{
	if (getbrowser()=="IE") return 1;
}

function ie6()
{
	return (navigator.userAgent.match("MSIE 6") || navigator.userAgent.match("MSIE 5") || navigator.userAgent.match("MSIE 4"));
}

function ietag(msg, front, end)
{
	msg.focus();
	msg.caretPos.text = front + msg.caretPos.text + end;
}

function storeCaret(textEl)
{
	currenttextarea=textEl;
	writing=1;
	if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}

function gotext(txtarea, text)
{
	txtarea=document.getElementById(txtarea);
	if (getbrowser()!="IE")
	{
	    txtarea.value =
	    txtarea.value.substring(0, txtarea.selectionStart)
	    + text
	    + txtarea.value.substring(txtarea.selectionEnd, txtarea.value.length);
	}
	else ietag(txtarea, "", text);
}

function inserttext(txtarea, text1, text2)
{
	txtarea=document.getElementById(txtarea);
	if (getbrowser()!="IE")
	{
		selStart=txtarea.selectionStart;
	    txtarea.value =
	    txtarea.value.substring(0, txtarea.selectionStart)
	    + text1
	    + txtarea.value.substring(txtarea.selectionStart, txtarea.selectionEnd)
	    + text2
	    + txtarea.value.substring(txtarea.selectionEnd, txtarea.value.length);
	}
	else ietag(txtarea, text1, text2);
	txtarea.focus();
	txtarea.setSelectionRange(selStart, selStart)
}

function pushtext(txtarea, text)
{
	txtarea=document.getElementById(txtarea);
	txtarea.value=text+txtarea.value;
}

function blank(elem)
{
	elem.value="";
}

function hide(elem)
{
	document.getElementById(elem).style.display="none";
}

function show(elem)
{
	document.getElementById(elem).style.display="block";
}

var cursorX, cursorY, msgBoxMoving, difX, difY;

function cursorCoords(e)
{
	if (isie())
	{
	    cursorX = event.clientX - document.documentElement.scrollLeft;
	    cursorY = event.clientY - document.documentElement.scrollTop;
	}
	else
	{
	    cursorX = e.pageX - window.pageXOffset;
	    cursorY = e.pageY - window.pageYOffset;
	}
}

function showobj(elem, x, y)
{
	if (!x) x=5;
	if (!y) y=5;
	if (x=="topleft")
	{
		document.getElementById(elem).style.left=y+"px";
		document.getElementById(elem).style.top=y+"px";		
	}
	else
	{

		document.getElementById(elem).style.left=cursorX+x+"px";
		document.getElementById(elem).style.top=cursorY+y+"px";
	}
	if (document.getElementById(elem).style.display=='block') document.getElementById(elem).style.display='none';
	else document.getElementById(elem).style.display='block';	
}

function loadgadget(elem, x, y)
{

	if (!document.getElementById('gadget-'+elem)) 
	{
		tempx=x;
		tempy=y;
		tempname=elem;
		ajaxget("/gadgets/"+elem, "__gadget");
	}
	else showobj("gadget-"+elem,x,y);
}

function objMove(e)
{
	cursorCoords(e);
	if (objMoving)
	{
		finalX = cursorX - difX;
		finalY = cursorY - difY;

	    if (!isie()) { document.getElementById(moveobj).style.left = finalX + "px";
	        document.getElementById(moveobj).style.top = finalY + "px"; }

		else { document.getElementById(moveobj).style.posLeft = finalX;
    	    document.getElementById(moveobj).style.posTop = finalY; }
	}
}

function objNoMove()
{
	objMoving=0;	
}

function focusMovedObj(obj)
{
	if (obj!=moveobj && moveobj!="") document.getElementById(moveobj).style.zIndex=500+zcounter;
	moveobj=obj;
	document.getElementById(moveobj).style.zIndex=5000+zcounter;
	zcounter=zcounter+1;
}


function objHold(obj)
{
	objMoving=1;
	
	focusMovedObj(obj);
	
	if (!ie6()) document.getElementById(moveobj).style.position="fixed";	
	if (ie6()) document.getElementById(moveobj).style.position="absolute";
	
    if (!isie()) { 	difX = cursorX - document.getElementById(moveobj).style.left.replace(/px/i, "");
		difY = cursorY - document.getElementById(moveobj).style.top.replace(/px/i, ""); }

	else { 	difX = cursorX - document.getElementById(moveobj).style.posLeft;
		difY = cursorY - document.getElementById(moveobj).style.posTop; }
}

function successClose(box)
{
	if (getcookie("success-"+box)) document.getElementById(box).style.display='none';
}


function objClose(box)
{
	document.getElementById(box).style.display='none';
}

document.onmousemove = objMove;
document.onmouseup = objNoMove;

// AJAX

function quote(saveid)
{
	xmlHttp=new XMLHttpRequest();
	xmlHttp.open("GET", "<?=fulladdr()?>readthread.php?showpost=" + saveid, true);
	xmlHttp.onreadystatechange=quote2;
	xmlHttp.send(null);
}

function quote2(user)
{
	if (xmlHttp.readyState==4)
	{
		text=xmlHttp.responseText;
		document.getElementById('msg').value='[quote=' + quoteuser + ']' + text + '[/quote]';
	}
}

// Misc

function showhide(elem, controller, texthidden, textopened)
{
	if (document.getElementById(elem).style.display!='block')
	{
	    document.getElementById(elem).style.display='block';
	    document.getElementById(controller).innerHTML=textopened;
	}
	else
	{
	    document.getElementById(elem).style.display='none';
	    document.getElementById(controller).innerHTML=texthidden;
	}
}

function sh(elem)
{
	if (document.getElementById(elem).style.display=='none') document.getElementById(elem).style.display='block';
	else document.getElementById(elem).style.display='none';
}

function byid(id)
{
	return document.getElementById(id);
}

function plswait(id)
{
	document.getElementById(id).innerHTML="Please wait...";
}

function normalize()
{
	var wincorrection = 99;
	var wincorrection2 = 130;
	if (document.getElementById('content').style.height!=(document.documentElement.clientHeight-wincorrection2)+"px")
	{
		document.getElementById('content').style.height=(document.documentElement.clientHeight-wincorrection2)+"px";
		document.getElementById('content').style.Width=(document.documentElement.clientWidth-wincorrection)+"px";
		document.getElementById('outline').style.height=(document.documentElement.clientHeight-wincorrection2)+"px";
	}
	window.setTimeout("normalize()", 250);
}



function starvoteover(prefix, stars, size)
{
	star1=document.getElementById(prefix + "1").style.backgroundPosition;
	star2=document.getElementById(prefix + "2").style.backgroundPosition;
	star3=document.getElementById(prefix + "3").style.backgroundPosition;
	star4=document.getElementById(prefix + "4").style.backgroundPosition;
	star5=document.getElementById(prefix + "5").style.backgroundPosition;
	
	for (i=1; i<=5; i++)
	{
		if (i<=stars) document.getElementById(prefix + i).style.backgroundPosition=imglibpos["votestar"+size];
		else document.getElementById(prefix + i).style.backgroundPosition=imglibpos["votestarempty"+size];
	}

	switch (stars)
	{
		case "1": text="Poor"; break;
		case "2": text="Nothing special"; break;
		case "3": text="Not bad"; break;
		case "4": text="Pretty cool"; break;
		case "5": text="Awesome!"; break;									
	}
	try { document.getElementById("textrating" + prefix).innerHTML=" - "+text; } catch(e) {}	
}

function starvoteout(prefix)
{
	try {
	document.getElementById(prefix + "1").style.backgroundPosition=star1;
	document.getElementById(prefix + "2").style.backgroundPosition=star2;
	document.getElementById(prefix + "3").style.backgroundPosition=star3;
	document.getElementById(prefix + "4").style.backgroundPosition=star4;
	document.getElementById(prefix + "5").style.backgroundPosition=star5;
	try { document.getElementById("textrating" + prefix).innerHTML=""; } catch(e) {}
	} catch(e) {}	
}

function starvote(code, value, size)
{
	xmlreq=xhr();
	
	xmlreq.onreadystatechange = function()
	{
		if(xmlreq.readyState==4)
		{
			document.getElementById("ratingstars"+code).innerHTML=xmlreq.responseText; 
		}
	} ; 
	
	if (size) sizeadd = "/" + size;
	else sizeadd="";
	
	xmlreq.open("GET", "/modules/rating/" + code + "/" + value + sizeadd, true); 
	xmlreq.send(null);
}

rtestarted=0;

function rte(msg, myheight)
{
	rtestarted=1;
	
	globalmsg=msg;

	document.getElementById("area"+msg).className="hidden";
	document.getElementById("area"+msg+"move").className="moveobj";
	document.getElementById("buttons"+msg).style.display="block";
	
	var editorframe = document.createElement("iframe");
	editorframe.name = editorframe.id = msg;
	editorframe.className = "frameEditor";

	frameborder=document.createAttribute("frameborder");
	frameborder.nodeValue="0";
	editorframe.setAttributeNode(frameborder);
	
	width=document.createAttribute("width");
	width.nodeValue="100%";
	editorframe.setAttributeNode(width);	

	myheight=myheight?myheight:256;
	height=document.createAttribute("height");
	height.nodeValue=myheight;
	editorframe.setAttributeNode(height);

	if (editorframe.addEventListener)
	{
		editorframe.addEventListener("load", function (e) { this.contentWindow.document.designMode = "on"; }, false);
	}
	else if (editorframe.attachEvent)
	{
		editorframe.attachEvent("load", function (e) { this.contentWindow.document.designMode = "on"; } );
	}

	document.getElementById(msg+"Holder").appendChild(editorframe);

	document.getElementById(msg).contentWindow.document.designMode="on";
	document.getElementById(msg).contentWindow.document.open();
	document.getElementById(msg).contentWindow.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-type" content="#php:rms:doctype; charset=#php:rms:charset;" /><link rel="stylesheet" type="text/css" href="#php:mainsheet;" media="all" /><style type="text/css">body.content { margin:0; padding:0; padding-left:5px; border:0; font-family:Arial,sans-serif,Trebuchet MS; font-size:14px; line-height:150%; } a { text-decoration:none; border:0; } a:hover { border:0; }</style><script type="text/javascript">msg=\'' + msg + '\';</script></head><body onkeyup="parent.document.getElementById(\'textarea\'+msg).value=document.body.innerHTML;" onfocus="parent.document.getElementById(\'textarea\'+msg).value=document.body.innerHTML;" onselect="parent.document.getElementById(\'textarea\'+msg).value=document.body.innerHTML;" onclick="parent.document.getElementById(\'textarea\'+msg).value=document.body.innerHTML;" onchange="parent.document.getElementById(\'textarea\'+msg).value=document.body.innerHTML;" class="content">' + parent.document.getElementById("textarea"+msg).value + '</body></html>');
	document.getElementById(msg).contentWindow.document.close();

	xchange(msg);
}

function format(msg, x,y)
{
	if (!y) y = null;
	document.getElementById(msg).contentWindow.document.execCommand(x,false,y);
	document.getElementById(msg).contentWindow.focus();
	frame2text(msg);
}

function html(msg, tag1, tag2)
{
	var sel=document.getElementById(msg).contentWindow.getSelection();
	if (!sel) return;
	var range=sel.getRangeAt(0);
	var pos1=range.startOffset;
	var pos2=range.endOffset;
	var container = range.startContainer;

	container.insertData(pos1, tag1);
	container.insertData(pos2+tag1.length, tag2);
    
	xhtml=document.getElementById(msg).contentWindow.document.body.innerHTML.replace(/&amp;mylt;/gmi, "<");
	xhtml=xhtml.replace(/&amp;mygt;/gmi, ">");
	document.getElementById(msg).contentWindow.document.body.innerHTML=xhtml;

    range.setStart(container, pos1);
    range.setEnd(container, pos2);

	frame2text(msg);    
}

function msgbox(title, content, width)
{
	document.getElementById("titleMsgBox").innerHTML=title;
	document.getElementById("contentMsgBox").innerHTML=content;
	document.getElementById("MsgBox").style.top="5px";
	document.getElementById("MsgBox").style.left="5px";
	document.getElementById("MsgBox").style.width=width;
	document.getElementById("MsgBox").style.display="block";
}

function ajaxbox(url, title, width)
{
	document.getElementById("titleMsgBox").innerHTML=title;
	ajaxget(url, "contentMsgBox");
	document.getElementById("MsgBox").style.top="5px";
	document.getElementById("MsgBox").style.left="5px";
	document.getElementById("MsgBox").style.width=width;
	document.getElementById("MsgBox").style.display="block";
}

htmledit=0;

function showhtml(msg)
{
	frame2text(msg);
	if (document.getElementById("area"+msg).className=="hidden" || document.getElementById("area"+msg).style.display=="none")
	{
		document.getElementById("area"+msg).className="box absbox box3 msgbox left areabox visible";
		document.getElementById("area"+msg).style.display="block";		
		document.getElementById("area"+msg).style.top="5px";	
		document.getElementById("area"+msg).style.left="5px";
		htmledit=1;
	}
	else
	{
		document.getElementById("area"+msg).className="hidden";
		document.getElementById("area"+msg).style.display="none";		
		htmledit=0;
	}
}

areawidth=0;
textareawidth=0;
textareaheight=0;

function areaexpand(msg, form, text, uri, file)
{
	document.getElementById("area"+msg).className="box absbox box3 msgbox left areabox visible";
	document.getElementById("area"+msg).style.display="block";		
	document.getElementById("area"+msg+"move").style.display="block";
	document.getElementById("area"+msg).style.top="5px";	
	document.getElementById("area"+msg).style.left="5px";

	areawidth=document.getElementById("area"+msg).style.width;
	textareawidth=document.getElementById("textarea"+msg).style.width;	
	textareaheight=document.getElementById("textarea"+msg).style.height;
	document.getElementById("area"+msg).style.width="1000px";
	
	document.getElementById("area"+msg+"moveobj").style.width="975px";	
	document.getElementById("textarea"+msg).style.width="990px";
	document.getElementById("textarea"+msg).style.height="660px";

	text=text?text:"Submit";

	document.getElementById("area"+msg+"submit").className="topspacer";
	document.getElementById("area"+msg+"submit").innerHTML="<a onclick=\"ajaxpost('"+uri+"?file="+file+"&ajax=1', 'mesg='+document.getElementById('textarea"+msg+"').value.replace(/\&/gmi, '%26').replace(/\\+/gmi, '%2b')); document.getElementById('area"+msg+"moveobj').innerHTML='Saved!';\" onmouseout=\"document.getElementById('area"+msg+"moveobj').innerHTML='Edit HTML';\" class=\"button submitbutton\" href=\"#\">AJAX "+text+"</a> <a onclick=\"document.getElementById('" + form + "').submit()\" class=\"button submitbutton\" href=\"#\">HTTP "+text+"</a> <span id='thisbox'> </span>";
}

function areaimplode(msg)
{
	if (!rtestarted)
	{
		document.getElementById("area"+msg).style.width=areawidth;
		document.getElementById("area"+msg).className="";
		document.getElementById("area"+msg).style.position="";				 
		document.getElementById("textarea"+msg).style.height=textareaheight;
		document.getElementById("textarea"+msg).style.width=textareawidth;
		document.getElementById("area"+msg+"move").style.display="none";
		document.getElementById("area"+msg+"submit").className="hidden";
	}
	else objClose('area' + msg);
}

function xchange(msg)
{
	if (!msg) msg=globalmsg;
	if (!htmledit) frame2text(msg);
	window.setTimeout("xchange()", 500);	
}

function text2frame(msg)
{
	if (rtestarted) { if (!msg) msg=globalmsg;
	document.getElementById(msg).contentWindow.document.body.innerHTML=document.getElementById("textarea"+msg).value; }
}

function frame2text(msg)
{		
	if (rtestarted) { if (!msg) msg=globalmsg;
	document.getElementById("textarea"+msg).value=document.getElementById(msg).contentWindow.document.body.innerHTML;	}
}

function showads()
{
	for (var i = 0; i < 10; i++)
	{
		try { document.getElementById("ad"+i).style.display="block"; } catch(e){}
	}
}

function reloadverimg()
{
	try { ele('imgver').src='/captcha-'+rnd(7)+'.jpg'; } catch(e){}
}

function editorget(sid, anzid)
{
	ajaxget('/bsanzeigen/index.php?action=modMine_ajax_get&sid='+sid+'&id='+anzid, 'output');
	document.getElementById('editbox').style.display='none';
	document.getElementById('output').style.display='block';
}

function clientinfostore()
{
	var str="";
	str=str+"width="+screen.availWidth+"///";
	str=str+"height="+screen.availHeight+"///";
	setcookie("clientinfo", str, 3600*24*365);
	window.setTimeout("clientinfostore()", clientinfostoreinterval);
}

liveeditorid="";
currentid="none";
mode="live";

function flipeditor(editorid, contentid, method, extraid1)
{
	liveeditorid=editorid;
	currentid=editorid;
	maincontentname=contentid;
	savemethod=method;
	extraidone=extraid1;	
}

function liveeditorset(id, contentid, method, extraid1, editoridlive)
{
	tinyMCE.execCommand("mceAddControl", true, editoridlive);
	liveeditorid=id;
	currentid=liveeditorid;
	mode="live";
	flipeditor(id, contentid, method, extraid1);
	window.setTimeout("liveeditorxchange()", 100);
	window.setTimeout("liveeditorsave()", 1000);
	//window.setTimeout("contentrefresh()", 1000);	
}

function liveeditorxchange()
{
	if (document.getElementById(maincontentname))
	{
		try{document.getElementById(maincontentname).innerHTML=document.getElementById(liveeditorid).contentWindow.	document.getElementsByTagName("body")[0].innerHTML;}catch(e){document.getElementById(maincontentname).value=	document.getElementById(liveeditorid).contentWindow.document.getElementsByTagName("body")[0].innerHTML;}
	}
	window.setTimeout("liveeditorxchange()", 100);	
}

function contentrefresh()
{
	if (mode!="live")
	{
		php_ajax_refreshcontent();
	}
	window.setTimeout("contentrefresh()", 3000);
}

function liveeditorsave()
{
	if (liveeditorid==currentid && savemethod=="content")
	{
		newpost();
		addpost("id", currentpageid);
		addpost("content", document.getElementById(liveeditorid).contentWindow.document.getElementsByTagName("body")[0].innerHTML);
		runpost("/ajax/plain/page_save.xts","","",1);
	}
	if (liveeditorid==currentid && savemethod=="box")
	{
		newpost();
		addpost("box_id", extraidone);
		addpost("content", document.getElementById(liveeditorid).contentWindow.document.getElementsByTagName("body")[0].innerHTML);
		runpost("/ajax/plain/box_save.xts","","",1);
	}	
	window.setTimeout("liveeditorsave()", 5000);	
}

function checkbox_rewrite(checkboxname, inputid)
{	
	var str="";
	for (i=0; i<100; i++)
	{
		if (document.getElementsByName(checkboxname)[i])
		{
			if (document.getElementsByName(checkboxname)[i].checked)
			{
				str=str+"{{{"+document.getElementsByName(checkboxname)[i].value+"}}}";
			}
		}
	}
	document.getElementById(inputid).value=str;
}


changeeditorid();
function changeeditorid()
{
	editor_id="rte"+Math.ceil(Math.random()*1000000);
	window.setTimeout("changeeditorid()", 3000);
}


function changeratingstars(md7, stars)
{
	stars=parseInt(stars);
	for (i=1; i<=stars; i++)
	{
		document.getElementById('star_'+md7+'_'+i).src='/media/misc/star-filled.png';
	}
	for (i=stars+1; i<=5; i++)
	{
		document.getElementById('star_'+md7+'_'+i).src='/media/misc/star-empty.png';
	}
}


// **************************************************************************************************************************************
