//if ( document.location.href.indexOf("post.forum",1) == -1 && document.location.href.indexOf("posting.forum",1) == -1
//&& document.location.href.indexOf("msg.forum",1) == -1 && document.location.href.indexOf("groupcp.forum",1) == -1
//&& document.location.href.indexOf("/adminv1/",1) == -1 && document.location.href.indexOf("/admin/",1) == -1 && document.location.href.indexOf("donate.forum",1) == -1
//&& document.location.href.indexOf("report.forum",1) == -1 && document.location.href.indexOf("calendar_event.forum",1) == -1
//&& document.location.href.indexOf("privmsg.forum",1) == -1 && document.location.href.indexOf("chatbox",1) == -1 && document.location.href.indexOf("/gallery/",1) == -1
//&& document.location.href.indexOf("profile.forum",1) == -1)
//{
//	window.open = false;
//}
function resize_images() {
	for (i = 0; i < document.images.length; i++) {
		while ( !document.images[i].complete ) {
			break;
		}
		if ( document.images[i].width > 900 ) {
			document.images[i].width = 900;
		}
	}
}
// Startup variables
var imageTag = false;
var theSelection = false;
// Check for Browser & Platform for PC & IE specific bits
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion); // Get browser version
var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
&& (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
&& (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
var is_moz = 0;
var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
var is_mac = (clientPC.indexOf("mac")!=-1);
// Helpline messages
b_help = "Negrita: [b]texto[/b] (alt+b)";
i_help = "Cursiva: [i]texto[/i] (alt+i)";
u_help = "Subrayado: [u]texto[/u] (alt+u)";
q_help = "Cita: [quote]texto[/quote] (alt+q)";
c_help = "CÃ³digo: [code]cÃ³digo[/code] (alt+c)";
l_help = "Lista: [list]texto[/list] (alt+l)";
o_help = "Lista ordenada: [list=]texto[/list] (alt+o)";
p_help = "Insertar imagen: [img]http://url_imagen[/img] (alt+p)";
w_help = "Insertar URL: [url]http://url[/url] o [url=http://url]texto URL[/url] (alt+w)";
a_help = "Cerrar todas las balizas de bbCode abiertas";
s_help = "Color: [color=red]texto[/color] Nota: Puede usar color=#FF0000";
f_help = "TamaÃ±o: [size=x-small]texto pequeÃ±o[/size]";
k_help = "Texto desfilante: [scroll]text[/scroll] (alt+k)";
e_help = "Texto pÃ¡lido : [fade]text[/fade] (alt+e)";
r_help = "Texto borroso: [blur]text[/blur] (alt+r)";
j_help = "Texto al revÃ©s: [flipv]texto[/flipv] (alt+v)";
v_help = "Texto al revÃ©s: [fliph]texto[/fliph] (alt+j)";
m_help = "Texto alineado a la izquierda : [left]texto[/left](alt+m)";
d_help = "Texto que se mueve de arriba a abajo: [updown]text[/updown] (alt+d)";
t_help = "Texto centrado: [center]text[/center] (alt+t)";
g_help = "Texto a la derecha: [right]text[/right] (alt+g)";
x_help = "Texto rayado: [strike]text[/strike] (alt+x)";
y_help = "Alojar una imagen";
z_help = "Insertar un emoticon en tu mensaje";
h_help = "Texto sÃ³lo visible para los que han escrito un mensaje en el tema: [hide]texto[/hide] (alt+h)";
sp_help = "Texto oculto e indicado pulsando arriba: [spoiler]texto[/spoiler] (alt+o)";
wo_help = "Un objeto World of Warcraft : [wow]17104[/wow]";
ft_help = "Tipo de letra del texto:[font=Verdana]texto[/font]";
jt_help = "Texto justificado:[justify]texto[/justify](alt+j)";
sub_help = "Poner en Ã­ndice:[sub]texto[/sub](alt+m)";
sup_help = "Poner en exponente:[sup]texto[/sup](alt+n)";
tab_help = "Insertar una tabla";
hr_help = "Insertar una lÃ­nea : texto[hr]texto";
fl_help = "Insertar flash :[flash(anchura, altura)]url[/flash]";
vd_help = "Insertar un video (youtube, dailymotion)";
_help = "";

// Define the bbCode tags
bbcode = new Array();
bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list][*]','[/list]','[list=1][*]','[/list]','[img]','[/img]','[url]','[/url]','[scroll]','[/scroll]','[fade]','[/fade]','[blur]','[/blur]','[flipv]','[/flipv]','[fliph]','[/fliph]','[updown]','[/updown]','[center]','[/center]','[right]','[/right]','[strike]','[/strike]','[embed-flash(width,height)]','[/embed-flash]');
bbtags[40] = '[hide]';
bbtags[41] = '[/hide]';
bbtags[42] = '[spoiler]';
bbtags[43] = '[/spoiler]';
bbtags[44] = '[wow]';
bbtags[45] = '[/wow]';
bbtags[46] = '[justify]';
bbtags[47] = '[/justify]';
bbtags[48] = '[sub]';
bbtags[49] = '[/sub]';
bbtags[50] = '[sup]';
bbtags[51] = '[/sup]';
bbtags[52] = '[left]';
bbtags[53] = '[/left]';
bbtags[54] = '[table]';
bbtags[55] = '[/table]';
bbtags[56] = '[hr]';
bbtags[58] = '[tr]';
bbtags[59] = '[/tr]';
bbtags[60] = '[td]';
bbtags[61] = '[/td]';

var selectId = new Array ('px','color','font','other','table_gui','flash','url','img','servimg_upload_gui','video', 'sel_smilies','dices','wpx','wcolor','wfont','wother','wtable_gui','wflash','wurl','wimg','wservimg_upload_gui','wvideo', 'wsel_smilies', 'wdices');

imageTag = false;
// Shows the help messages in the helpline window
function helpline(help) {
	// document.post.helpbox.value = eval(help + "_help");
	if ( help.length<5 )
	{
		document.getElementById('helpbox').innerHTML = eval(help + "_help");
	}
	else
	{
		document.getElementById('helpbox').innerHTML = help;
	}
}
// Replacement for arrayname.length property
function getarraysize(thearray) {
	for (i = 0; i < thearray.length; i++) {
		if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null))
		return i;
	}
	return thearray.length;
}
// Replacement for arrayname.push(value) not implemented in IE until version 5.5
// Appends element to the array
function arraypush(thearray,value) {
	thearray[ getarraysize(thearray) ] = value;
}
// Replacement for arrayname.pop() not implemented in IE until version 5.5
// Removes and returns the last element of an array
function arraypop(thearray) {
	thearraysize = getarraysize(thearray);
	retval = thearray[thearraysize - 1];
	delete thearray[thearraysize - 1];
	return retval;
}
function checkForm() {
	formErrors = false;
	if (document.post.message.value.length < 3) {
		formErrors = "Debes escribir un mensaje antes de publicar.";
	}
	if (formErrors) {
		return false;
	} else {
		bbstyle(-1);
		//formObj.preview.disabled = true;
		//formObj.submit.disabled = true;
		return true;
	}
}
function emoticon(text) {
	var txtarea = document.post.message;
	text = ' ' + text + ' ';
	if (txtarea.createTextRange && txtarea.caretPos) {
		var caretPos = txtarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
		txtarea.focus();
	} else {
		txtarea.value += text;
		txtarea.focus();
	}
}
// Emoticons : Frame
function emoticonp(text) {
	if( parent.document.getElementById('html_edit') && parent.smilieoptions && parent.document.getElementById('html_edit').style.display!='none' )
	{
		var smiles = parent.smilieoptions;
		for (var i in smiles)
		{
			if ( smiles[i][2] == text )
			{
				var text = '<img src="' + smiles[i][0] + '" border="0" smilieid="' + i + '" />';
				text = '&nbsp;' + text + '&nbsp;';
				parent.vB_Editor['text_editor'].insert_text(text, false);
			}
		}
	}
	else
	{
		text = ' ' + text + ' ';
		if (parent.document.forms['post'].message.createTextRange && parent.document.forms['post'].message.caretPos) {
			var caretPos = parent.document.forms['post'].message.caretPos;
			caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
			parent.document.forms['post'].message.focus();
		} else {
			parent.document.forms['post'].message.value += text;
			parent.document.forms['post'].message.focus();
		}
	}
}
// Emoticons : Window
function emoticonw(text) {
	text = ' ' + text + ' ';
	if (opener.document.forms['post'].message.createTextRange && opener.document.forms['post'].message.caretPos) {
		var caretPos = opener.document.forms['post'].message.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
		opener.document.forms['post'].message.focus();
	} else {
		opener.document.forms['post'].message.value += text;
		opener.document.forms['post'].message.focus();
	}
}
function constructBBcode(bbcode,args,content) {
	var textarea = document.post.message;
	var i = 0;
	var tmp_args = '';
	var tmp_content = '';

	if (bbcode == 'flash' || bbcode == 'img' || (bbcode== 'url' && document.getElementById(content).value != '')) {
		tmp_content += document.getElementById(content).value;
	}
	else {
		tmp_content += document.getElementById(args[0]).value;
	}

	if (bbcode == 'flash' ) {
		if ( document.getElementById(args[0]).value > 0 && document.getElementById(args[1]).value > 0 ) {
			tmp_args += '(' + document.getElementById(args[0]).value + ',' + document.getElementById(args[1]).value + ')';
		}
	}
	else
	{
		if (bbcode == 'url' && document.getElementById(args[0]).value != '') {
			tmp_args += '=';
			if ( document.getElementById(args[0]).value.indexOf('www.') == 0 )
			{
				document.getElementById(args[0]).value = 'http://' + document.getElementById(args[0]).value;
			}
		}
		while ( i < args.length ) {
			tmp_args += document.getElementById(args[i]).value;
			document.getElementById(args[i]).value = '';
			if ( i != args.length - 1 ) {
				tmp_args += ',';
			}
			i++;
		}
	}

	textarea.value = textarea.value + '[' + bbcode + tmp_args + ']' + tmp_content + '[/' + bbcode + ']';
	document.getElementById(content).value = '';
}
function BBcodeVideo(id) {
	var url = document.getElementById(id).value;
	var textarea = document.post.message;
	var span = document.getElementById('inv_url');

	if ( url.indexOf('youtube') != '-1' ) {
		textarea.value = textarea.value + '[youtube]' + url + '[/youtube]';
		selectWysiwyg(this, 'video');
	}
	else if ( url.indexOf('dailymotion') != '-1') {
		textarea.value = textarea.value + '[dailymotion]' + url + '[/dailymotion]';
		selectWysiwyg(this, 'video');
	}
	else if ( url.indexOf('google') != '-1') {
		textarea.value = textarea.value + '[googlevideo]' + url + '[/googlevideo]';
		selectWysiwyg(this, 'video');
	}
	else {
		span.innerHTML = "L\'URL proporcionada es invÃ¡lida";
	}
}
function bbfontstyle(bbopen, bbclose) {
	var txtarea = document.post.message;
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (!theSelection) {
			txtarea.value += bbopen + bbclose;
			txtarea.focus();
			return;
		}
		document.selection.createRange().text = bbopen + theSelection + bbclose;
		txtarea.focus();
		return;
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, bbopen, bbclose);
		return;
	}
	else
	{
		txtarea.value += bbopen + bbclose;
		txtarea.setSelectionRange(txtarea.value.length - bbclose.length, txtarea.value.length - bbclose.length);
		txtarea.focus();
	}
	storeCaret(txtarea);
}
function bbstyle(bbnumber) {
	var txtarea = document.post.message;
	var button = document.getElementById('addbbcode'+bbnumber);
	if (bbnumber != -1) {
		var tag = document.getElementById('addbbcode'+bbnumber).tagName;
	}
	donotinsert = false;
	theSelection = false;
	bblast = 0;
	if (bbnumber == -1) { // Close all open tags & default button names
		while (bbcode[0]) {
			butnumber = arraypop(bbcode) - 1;
			txtarea.value += bbtags[butnumber + 1];
			var tag = document.getElementById('addbbcode'+butnumber).tagName;
			if ( tag == 'INPUT' ) {
				buttext = eval('document.post.addbbcode' + butnumber + '.value');
				eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
			}
			else if ( tag == 'BUTTON' && document.getElementById('addbbcode'+butnumber)){
				document.getElementById('addbbcode'+butnumber).className = 'button2';
			}
		}
		imageTag = false; // All tags are closed including image tags :D
		txtarea.focus();
		return;
	}
	if ((clientVer >= 4) && is_ie && is_win)
	{
		theSelection = document.selection.createRange().text; // Get text selection
		if (theSelection) {
			// Add tags around selection
			document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1];
			txtarea.focus();
			theSelection = '';
			return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, bbtags[bbnumber], bbtags[bbnumber+1]);
		return;
	}
	// Find last occurance of an open tag the same as the one just clicked
	for (i = 0; i < bbcode.length; i++) {
		if (bbcode[i] == bbnumber+1) {
			bblast = i;
			donotinsert = true;
		}
	}
	if (donotinsert) {		// Close all open tags up to the one just clicked & default button names
		while (bbcode[bblast]) {
			butnumber = arraypop(bbcode) - 1;
			txtarea.value += bbtags[butnumber + 1];
			if ( tag == 'INPUT' ) {
				buttext = eval('document.post.addbbcode' + butnumber + '.value');
				eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
			}
			else if (tag == 'BUTTON' && document.getElementById('addbbcode'+bbnumber)){
				button.className = 'button2';
			}
			imageTag = false;
		}
		txtarea.focus();
		return;
	} else { // Open tags
		if (imageTag && (bbnumber != 14)) {		// Close image tag before adding another
			txtarea.value += bbtags[15];
			lastValue = arraypop(bbcode) - 1;	// Remove the close image tag from the list
			document.post.addbbcode14.value = "Img";	// Return button back to normal state
			imageTag = false;
		}
		// Open tag
		txtarea.value += bbtags[bbnumber];
		if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
		arraypush(bbcode,bbnumber+1);
		if ( tag == 'INPUT' ) {
			eval('document.post.addbbcode'+bbnumber+'.value += "*"');
		}
		else if (tag == 'BUTTON' && document.getElementById('addbbcode'+bbnumber)){
			button.className = 'button2 bbcode';
		}
		txtarea.focus();
		return;
	}
	storeCaret(txtarea);
}
function FindXY(obj){
	var x=0,y=0;
	while ( obj != null /*&& obj.id != 'main-content'*/ ){
		x+=obj.offsetLeft;
		y+=obj.offsetTop;
		obj=obj.offsetParent;
	}
	return {'x':x,'y':y};
}

function selectWysiwyg (button, div) {
	var div = document.getElementById(div);
	var visible = div.style.visibility;

	if ( visible == 'hidden' ) {
		var cd = FindXY(button);
		var h = button.offsetHeight;
		var i = 0;
		while ( i < selectId.length ) {
			if ( document.getElementById(selectId[i]) ) {
				document.getElementById(selectId[i]).style.visibility = 'hidden';
			}
			i++;
		}
		div.style.visibility = 'visible';
		if ( div.id != 'sel_smilies' && div.id != 'wsel_smilies' )
		{
			div.style.width = 'auto';
		}
		else
		{
			if ( !document.getElementById('sel_smilies_content') )
			{
				var smilies_content = '<div id="sel_smilies_content" align="center">';
				for (var smilieid in smilieoptions)
				{
					smilies_content += '<button onclick="emoticonp(\'' + smilieoptions[smilieid][2] + '\');selectWysiwyg(this, \'sel_smilies\');return false;"><img alt="' + smilieoptions[smilieid][1] + '" title="' + smilieoptions[smilieid][1] + '" src="' + smilieoptions[smilieid][0] + '" /></button> ';
				}
				smilies_content += '</div>';
				div.innerHTML = smilies_content;
			}
		}

		overFlowX = cd['x'] + div.offsetWidth - document.body.offsetWidth;
		cd['x'] = overFlowX > 0 ? cd['x'] - overFlowX : cd['x'];

		div.style.left = cd['x']+'px';
		div.style.top = (cd['y']+h)+'px';
	}
	else {
		div.style.visibility = 'hidden';
	}
}
// From http://www.massless.org/mozedit/
function mozWrap(txtarea, open, close)
{
	var selLength = txtarea.textLength;
	var selStart = txtarea.selectionStart;
	var selEnd = txtarea.selectionEnd;
	if (selEnd == 1 || selEnd == 2)
	selEnd = selLength;
	var s1 = (txtarea.value).substring(0,selStart);
	var s2 = (txtarea.value).substring(selStart, selEnd)
	var s3 = (txtarea.value).substring(selEnd, selLength);
	txtarea.value = s1 + open + s2 + close + s3;
	return;
}
// Insert at Claret position. Code from
// http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130
function storeCaret(textEl) {
	if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}


// Direction de la page (ltr / rtl)
var html = document.getElementsByTagName('html');
var document_dir = 'ltr';
for(var i= 0; i < html.item(0).attributes.length; i++)
{
	var item = html.item(0).attributes[i];
	if(item.name == 'dir' && item.value == 'ltr' || item.value == 'rtl')
	{
		document_dir = item.value;
		break;
	}
}

// Position de la souris
var mouse_y = 0;
var mouse_x = 0;
function get_mouseX(evt)
{
	if (!evt)
	{
		evt = window.event;
	}

	if (evt.pageX)
	{
		return evt.pageX;
	}
	else if (evt.clientX)
	{
		var offset_temp = 0;
		if ( document.documentElement )
		{
			if ( document.documentElement.scrollLeft )
			{
				offset_temp = document.documentElement.scrollLeft;
			}
			else // En cas de changement de page avec scroll sur la précédente
			{
				offset_temp = 0;
			}
		}
		else
		{
			offset_temp = document.body.scrollLeft;
		}
		return evt.clientX + offset_temp;
	}
	else
	{
		return 0;
	}
}
function get_mouseY(evt)
{
	if (!evt)
	{
		evt = window.event;
	}

	if (evt.pageY)
	{
		return evt.pageY;
	}
	else if (evt.clientY)
	{
		var offset_temp = 0;
		if ( document.documentElement )
		{
			if ( document.documentElement.scrollTop )
			{
				offset_temp = document.documentElement.scrollTop;
			}
			else // En cas de changement de page avec scroll sur la précédente
			{
				offset_temp = 0;
			}
		}
		else
		{
			offset_temp = document.body.scrollTop;
		}
		return evt.clientY + offset_temp;
	}
	else
	{
		return 0;
	}
}
function get_mouse_pos(evt) {
	if (document.getElementById)
	{
		mouse_y = (parseInt(get_mouseY(evt))+15) + 'px';
		mouse_x = (parseInt(get_mouseX(evt))+15) + 'px';
	}
}
if (document.all) {
	document.attachEvent("onmousemove", get_mouse_pos);
}
else {
	document.addEventListener("mousemove", get_mouse_pos, true);
}

// Afficher/cacher les "div search" et "plus menu"
function showhide(vari) {
	var window_width = 0;
	if ( document.getElementById('content') )
	{
		window_width = document.getElementById('content').offsetWidth;
	}
	else
	{
		window_width = (document.body) ? document.body.clientWidth : window.innerWidth;
	}

	if ( vari != document.getElementById('plus_menu') )
	{
		// top
		vari.style.top = mouse_y;
		window_width = (document.body) ? document.body.clientWidth : window.innerWidth;
	}

	vari.style.display=(vari.style.display=="none") ? '' : 'none';
	var vari_style_width = parseInt(vari.style.width);
	vari_style_width = (!isNaN(vari_style_width)) ? vari_style_width : vari.offsetWidth;
	var element_vari = vari;
	while ( vari_style_width == 0 && element_vari.firstChild.offsetWidth )
	{
		element_vari = element_vari.firstChild;
		vari_style_width = element_vari.offsetWidth;
	}

	mouse_x = parseInt(mouse_x);
	while(vari_style_width + mouse_x >= window_width)
	{
		mouse_x -= 10;
	}
	vari.style.left = mouse_x + 'px';
}

function insert_search_menu(session_id) {
	session_input = (session_id ? '<input type="hidden" name="sid" value="'+session_id+'" />' : '');
	session_id = (session_id ? '?sid='+session_id : '');
	document.write('<div id="search_menu" style="display:none;position:absolute;z-index:1;"><form action="/search.forum" method="get"><table class="forumline" cellpadding="3" cellspacing="0" border="0"><tr><th class="thHead">Buscar</th></tr><tr><td class="row2" align="center"><input type="text" class="post" name="search_keywords" size="24" style="height:20px; margin-top:6px; margin-right:3px;" /> <input type="submit" class="button" value="Go" /></td></tr><tr><td class="row2" align="center" nowrap="nowrap"><span class="genmed">&nbsp;Resultados por:&nbsp; <input id="rposts" type="radio" name="show_results" value="posts" /><label for="rposts">&nbsp;Mensajes</label> <input id="rtopics" type="radio" name="show_results" value="topics" checked="checked" /><label for="rtopics">&nbsp;Argumentos</label>&nbsp;</td></tr><tr><td class="row2" align="center"><span class="genmed"><hr><a href="/search.forum'+session_id+'" rel="nofollow"><img src="http://illiweb.com/fa/icon_mini_search.gif" width="12" height="13" border="0" hspace="3" />&nbsp;BÃºsqueda avanzada</a><span></td></tr></table>'+session_input+'</form></div>');
}

function insert_search_menu_new(session_id) {
	session_input = (session_id ? '<input type="hidden" name="sid" value="'+session_id+'" />' : '');
	session_id = (session_id ? '?sid='+session_id : '');
	document.write('<div class="overview row3" id="search_menu" style="display:none;position:absolute;width:350px;z-index:1;"><form action="/search.forum" method="get"><p class="title-overview row2">Buscar</p><p class="center-overview"><input type="text" class="inputbox medium" name="search_keywords" />'+session_input+'<input type="submit" class="button1" value="Go" /><br />Resultados por: <label for="rposts"><input id="rposts" type="radio" name="show_results" value="posts" /> Mensajes</label> <label for="rtopics"><input id="rtopics" type="radio" name="show_results" value="topics" checked="checked" /> Argumentos</label></p><hr class="dashed" /><p class="center-overview"><a href="/search.forum'+session_id+'" rel="nofollow"><img src="http://illiweb.com/fa/icon_mini_search.gif" width="12" height="13" alt="" /> BÃºsqueda avanzada</a></p>'+session_input+'</form></div>');
}

function insert_plus_menu(search_where,session_id,add_favourite) {
	var favourite = '';
	if(add_favourite)
	{
		favourite = search_where.replace(new RegExp("f([0-9]*)(&|&amp;)t=([0-9]*)","g"), '$3');
		favourite = '<a href="/search.forum?search_id=favouritesearch&amp;add_favourite='+favourite+session_id+'">AÃ±adir a tus favoritos.</a><br>';
	}
	search_where = '&amp;search_where='+search_where;
	session_id = (session_id ? '&amp;sid='+session_id : '');
	document.write('<a href="javascript:showhide(document.getElementById(\'plus_menu\'))">Â¡MÃ¡s!</a><br><div id="plus_menu" style="display:none;position:absolute;margin-top:8px;z-index:1;"><table class="forumline" cellpadding="3" cellspacing="0" border="0" width="200"><tr><th class="thHead">Â¡MÃ¡s!</th></tr><tr><td class="row1" nowrap="nowrap"><span class="gensmall"><b><a href="/search.forum?search_id=newposts'+search_where+session_id+'">Ver mensajes desde la Ãºltima visita</a><br><a href="/search.forum?search_id=egosearch'+search_where+session_id+'">Ver tus mensajes</a><br><a href="/search.forum?search_id=unanswered'+search_where+session_id+'">Ver mensajes sin respuesta</a><br><a href="/search.forum?search_id=watchsearch'+search_where+session_id+'">Temas supervisados</a><hr>'+favourite+'<a href="/tell_friend.forum?f='+search_where+session_id+'">Enviar a un amigo</a><br><a href="'+self.location.href+'" onclick="link_bbcode();return false">Copiar la direcciÃ³n BBCode de la pÃ¡gina</a><br><a href="javascript:void(0);" onclick="window.print();return false">Imprimir esta pÃ¡gina</a></b></span></td></tr></table></div>');
}

function insert_plus_menu_new(search_where,session_id,add_favourite,watch_topic) {
	var watch = '';
	if (watch_topic)
	{
		watch = watch_topic + '<br />';
	}
	var favourite = '';
	if(add_favourite)
	{
		favourite = search_where.replace(new RegExp("f([0-9]*)(&|&amp;)t=([0-9]*)","g"), '$3');
		favourite = '<a href="/search.forum?search_id=favouritesearch&amp;add_favourite='+favourite+session_id+'">AÃ±adir a tus favoritos.</a><br>';
	}
	search_where = '&amp;search_where='+search_where;
	session_id = (session_id ? '&amp;sid='+session_id : '');
	document.write('<a href="javascript:showhide(document.getElementById(\'plus_menu\'))">Â¡MÃ¡s!</a><br /><div class="overview row3" id="plus_menu" style="display:none;position:absolute;width:400px;margin-top:8px;z-index:1;"><p class="title-overview row2"><strong>Â¡MÃ¡s!</strong></p><p class="left-overview"><strong><a href="/search.forum?search_id=newposts'+search_where+session_id+'">Ver mensajes desde la Ãºltima visita</a><br /><a href="/search.forum?search_id=egosearch'+search_where+session_id+'">Ver tus mensajes</a><br /><a href="/search.forum?search_id=unanswered'+search_where+session_id+'">Ver mensajes sin respuesta</a><br /><a href="/search.forum?search_id=watchsearch'+search_where+session_id+'">Temas supervisados</a></strong></p><hr class="dashed" /><p class="left-overview"><strong>'+watch+favourite+'<a href="/tell_friend.forum?f='+search_where+session_id+'">Enviar a un amigo</a><br /><a href="'+self.location.href+'" onclick="link_bbcode();return false">Copiar la direcciÃ³n BBCode de la pÃ¡gina</a><br /><a href="javascript:void(0);" onclick="window.print();return false">Imprimir esta pÃ¡gina</a></strong></p></div>');
}

function insert_plus_album(search_where,session_id) {
	session_id = (session_id ? '&amp;sid='+session_id : '');
	document.write('<a href="javascript:showhide(document.getElementById(\'plus_menu\'))">Â¡MÃ¡s!</a><br><div id="plus_menu" style="display:none;position:absolute;right:100px;z-index:1;"><table class="forumline" cellpadding="3" cellspacing="0" border="0"><tr><th class="thHead">Â¡MÃ¡s!</th></tr><tr><td class="row1" nowrap="nowrap"><span class="gensmall"><b><a href="/tell_friend.forum?album='+search_where+session_id+'">Enviar a un amigo</a></b></span></td></tr></table></div>');
}

function insert_plus_album_new(search_where,session_id) {
	session_id = (session_id ? '&amp;sid='+session_id : '');
	document.write('<a href="javascript:showhide(document.getElementById(\'plus_menu\'))">Â¡MÃ¡s!</a><br /><div class="overview row3" id="plus_menu" style="display:none;margin: 8px 20px 0px 0px;position:absolute;right:20px;width:200px;z-index:1;"><p class="title-overview row2">Â¡MÃ¡s!</p><p class="left-overview"><strong><a href="/tell_friend.forum?album='+search_where+session_id+'">Enviar a un amigo</a></strong></p></div>');
}

function insert_plus_pic(search_where,session_id) {
	session_id = (session_id ? '&amp;sid='+session_id : '');
	document.write('<a href="javascript:showhide(document.getElementById(\'plus_menu\'))">Â¡MÃ¡s!</a><br><div id="plus_menu" style="display:none;position:absolute;right:100px;z-index:1;"><table class="forumline" cellpadding="3" cellspacing="0" border="0"><tr><th class="thHead">Â¡MÃ¡s!</th></tr><tr><td class="row1" nowrap="nowrap"><span class="gensmall"><b><a href="/tell_friend.forum?pic='+search_where+session_id+'">Enviar a un amigo</a></b></span></td></tr></table></div>');
}

function insert_plus_pic_new(search_where,session_id) {
	session_id = (session_id ? '&amp;sid='+session_id : '');
	document.write('<a href="javascript:showhide(document.getElementById(\'plus_menu\'))">Â¡MÃ¡s!</a><br /><div class="overview row3" id="plus_menu" style="display:none;position:absolute;right:20px;margin-top:20px;z-index:1;"><p class="title-overview row2">Â¡MÃ¡s!</p><p class="left-overview"><strong><a href="/tell_friend.forum?pic='+search_where+session_id+'">Enviar a un amigo</a></strong></p></div>');
}

function link_bbcode() {
	intext = "[url="+self.location.href+"]"+window.document.title+"[/url]";
	if(document.all && !window.opera)
	{
		window.clipboardData.setData('Text', intext);
	}
	else
	{
		prompt('',intext);
	}
}

function ShowHideLayer(layer_open, layer_close) {
	if (layer_open != '') {
		expandLayer(layer_open);
	}
	if (layer_close != '') {
		expandLayer(layer_close);
	}
}

function ShowHideMenu(layer_open, layer_close, page_id, new_class) {
	if (layer_open != '') {
		expandLayer(layer_open);
	}

	if (layer_close != '') {
		expandLayer(layer_close);
	}

	if (document.getElementById(page_id).className == new_class)
	{
		document.getElementById(page_id).className = '';
	}
	else
	{
		document.getElementById(page_id).className = new_class;
	}

}

function expandLayer(name) {
	var itm = null;

	if (document.getElementById) {
		itm = document.getElementById(name);
	} else if (document.all) {
		itm = document.all[name];
	} else if (document.layers) {
		itm = document.layers[name];
	}

	if (!itm) {
		// Just don't panik, it's ok
	} else if (itm.style) {
		if (itm.style.display == "none") {
			itm.style.display = "";
		} else {
			itm.style.display = "none";
		}
	} else {
		itm.visibility = "show";
	}
}

function fa_endpage() {
	if (parent.wbo1_ferme) wbo1_ferme();
	//if (parent.slide_close) slide_close();
}

function hdr_ref(object)
{
	if (document.getElementById)
	{
		return document.getElementById(object);
	}
	else if (document.all)
	{
		return eval('document.all.' + object);
	}
	else
	{
		return false;
	}
}

function hdr_expand(object)
{
	var object = hdr_ref(object);

	if( !object.style )
	{
		return false;
	}
	else
	{
		object.style.display = '';
	}

	if (window.event)
	{
		window.event.cancelBubble = true;
	}
}

function hdr_contract(object)
{
	var object = hdr_ref(object);

	if( !object.style )
	{
		return false;
	}
	else
	{
		object.style.display = 'none';
	}

	if (window.event)
	{
		window.event.cancelBubble = true;
	}
}

function hdr_toggle(object, open_close, open_icon, close_icon)
{
	var object = hdr_ref(object);
	var icone = hdr_ref(open_close);

	if( !object.style )
	{
		return false;
	}

	if( object.style.display == 'none' )
	{
		object.style.display = '';
		icone.src = close_icon;
	}
	else
	{
		object.style.display = 'none';
		icone.src = open_icon;
	}
}

function select_switch_col(nomchamp) {
	for (i=0; i<document.post.length; i++)
	{
		if (document.post.elements[i].name && (document.post.elements[i].name).substring(0,nomchamp.length) == nomchamp && document.post.elements[i].disabled != true)
		{
			document.post.elements[i].checked = !document.post.elements[i].checked;
		}
	}
}


function disabled1(choix,nomchamp) {

	var formulaire = document.getElementById(choix);
	/*
	if ( formulaire.selectedIndex != 2 )
	{
	for (i=0; i<document.post.length; i++)
	{
	if ( (document.post.elements[i].name).substring(0,nomchamp.length) == nomchamp)
	{
	document.post.elements[i].disabled = 'disabled';
	}
	}
	}
	if ( formulaire.selectedIndex == 2 )
	{
	for (i=0; i<document.post.length; i++)
	{
	if ( (document.post.elements[i].name).substring(0,nomchamp.length) == nomchamp)
	{
	document.post.elements[i].disabled = '';
	}
	}
	}
	*/
	for (i=0; i<document.post.length; i++)
	{
		if ( document.post.elements[i].type=='checkbox' && (document.post.elements[i].name).substring(0,nomchamp.length) == nomchamp)
		{
			document.post.elements[i].disabled = ((formulaire.selectedIndex != 2)?'disabled':'');
		}
	}

}

function disabled2(choix,nomchamp) {

	var formulaire = document.getElementById(choix);
	/*
	if ( formulaire.selectedIndex != 1 )
	{
	for (i=0; i<document.post.length; i++)
	{
	if ( (document.post.elements[i].name).substring(0,nomchamp.length) == nomchamp)
	{
	document.post.elements[i].disabled = 'disabled';
	}
	}
	}
	if ( formulaire.selectedIndex == 1 )
	{
	for (i=0; i<document.post.length; i++)
	{
	if ( (document.post.elements[i].name).substring(0,nomchamp.length) == nomchamp)
	{
	document.post.elements[i].disabled = '';
	}
	}
	}
	*/
	for (i=0; i<document.post.length; i++)
	{
		if ( document.post.elements[i].type=='checkbox' && (document.post.elements[i].name).substring(0,nomchamp.length) == nomchamp)
		{
			document.post.elements[i].disabled = ((formulaire.selectedIndex != 1)?'disabled':'');
		}
	}

}

var agt = navigator.userAgent.toLowerCase();
var originalFirstChild;

function createTitle(which, string, x, y)
{
	if (typeof(originalFirstChild) == 'undefined')
	{
		originalFirstChild = document.body.firstChild;
	}

	x = parseInt(mouse_x);
	y = parseInt(mouse_y);

	element = document.createElement('div');
	element.style.position = 'absolute';
	element.style.zIndex = 1000;
	element.style.visibility = 'hidden';
	excessWidth = 0;
	if (document.all)
	{
		excessWidth = 50;
	}
	excessHeight = 20;
	element.innerHTML = '<div class="bodyline"><table cellspacing="0" cellpadding="0" border="0"><tr><td><span class="gen">' + string + '</span></td></tr></table></div>';
	renderedElement = document.body.insertBefore(element, document.body.firstChild);
	renderedWidth = renderedElement.offsetWidth;
	renderedHeight = renderedElement.offsetHeight;

	renderedElement.style.top = (y + 10) + 'px';
	renderedElement.style.left = (x + 10) + 'px';

	if (agt.indexOf('gecko') != -1 && agt.indexOf('win') != -1)
	{
		setTimeout("renderedElement.style.visibility = 'visible'", 1);
	}
	else
	{
		renderedElement.style.visibility = 'visible';
	}
}

function destroyTitle()
{
	if (document.body.firstChild != originalFirstChild)
	{
		document.body.removeChild(document.body.firstChild);
	}
}

function my_getcookie( name )
{
	cname = name + '=';
	cpos = document.cookie.indexOf( cname );

	if ( cpos != -1 )
	{
		cstart = cpos + cname.length;
		cend = document.cookie.indexOf(";", cstart);

		if (cend == -1)
		{
			cend = document.cookie.length;
		}

		return unescape( document.cookie.substring(cstart, cend) );
	}

	return null;
}

function my_setcookie( name, value, sticky )
{
	expire = "";
	domain = "";
	path = "/";

	if ( sticky )
	{
		expire = "; expires=Wed, 1 Jan 2020 00:00:00 GMT";
	}

	document.cookie = name + "=" + value + "; path=" + path + expire + domain + ';';
}

function expandAllLayer(name, open_close, layer_open_close) {
	var itm = null;

	if (document.getElementById) {
		itm = document.getElementById(name);
	} else if (document.all) {
		itm = document.all[name];
	} else if (document.layers) {
		itm = document.layers[name];
	}

	if (!itm) {
	} else if (itm.style) {
		if (itm.style.display == "none")
		{
			if( (open_close == "open" && layer_open_close=="open") || (open_close == "close" && layer_open_close=="close") )
			{
				itm.style.display = "";
			}
		}
		else
		{
			if( (open_close == "close" && layer_open_close=="open") || (open_close == "open" && layer_open_close=="close") )
			{
				itm.style.display = "none";
			}
		}
	}
	else
	{
		itm.visibility = "show";
	}

}

function check(action,formname) {

	var formnamevalue = document.forms[arguments[1]];

	field = formnamevalue.elements.length;
	switch(action)
	{	case "select":	for (i = 0; i < field; i++) {
		formnamevalue.elements[i].checked = true;
	}
	break;
	case "unselect":	for (i = 0; i < field; i++) {
		formnamevalue.elements[i].checked = false;
	}
	break;
	}
}

function popUP(mypage, myname, w, h, scroll, titlebar)
{
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no,menubar=no,status=no,toolbar=no'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4)
	{
		win.window.focus();
	}
}

function refresh_username(selected_username) {
	if ( (opener.document.forms['post'].username.value) && (opener.document.forms['post'].ismp) )
	{
		opener.document.forms['post'].username.value = opener.document.forms['post'].username.value + ';' + selected_username;
	}
	else
	{
		opener.document.forms['post'].username.value = selected_username;
	}
	opener.focus();
	window.close();
}

function insertChatBox(chatbox_id, chatbox_url) {
	document.getElementById(chatbox_id).innerHTML = '<iframe src="' + chatbox_url + '" id="frame_chatbox" scrolling="no" width="100%" height="100%" marginwidth="0" marginheight="0" border="0"></iframe>';
}
function insertChatBoxNew(chatbox_id, chatbox_url) {
	document.getElementById(chatbox_id).innerHTML = '<object data="' + chatbox_url + '" id="frame_chatbox" scrolling="yes" width="100%" height="100%" type="text/html"></object>';
}
function insertChatBoxPopup(chatbox_url, l_chatbox_join) {
	document.getElementById('chatbox_popup').innerHTML = '[ <a href="' + chatbox_url + '" target="ChatBox">' + l_chatbox_join + '</a> ]';
}


/****************************************************
* Function that show a context menu for the chatbox	*
* date : 22/12/2006									*
* author : Vincent									*
****************************************************/
function showMenu (user_id, user_name, my_user_id, my_chat_level, my_user_level, user_chat_level, user_level, event, sid) {
	/* if the context menu is already shown or the user is not connected to the chatbox */
	if (document.getElementById('chatbox_contextmenu'))
	{
		hideMenu();
		return false;
	}

	var connected = false;
	if (document.forms[0].elements["message"])
	{
		connected = true;
	}

	/* ------ get mouse info for displaying the menu -------- */
	if (document.all) {
		mouseX = window.event.clientX + document.body.scrollLeft;
		mouseY = window.event.clientY + document.body.scrollTop;
	}
	else {
		mouseX = event.clientX + window.scrollX;
		mouseY = event.clientY + window.scrollY;
	}

	//if (mouseX > 50)
	//mouseX = 50;

	/* ---------- create the div of the menu ------------- */
	var div = document.createElement('div');
	div.setAttribute('id', 'chatbox_contextmenu');
	div.style.display = 'block';
	div.style.top = mouseY+'px';
	//div.style.left = mouseX+'px';

	// Début Ajout
	var window_width = 0;
	if ( document.getElementById('content') )
	{
		window_width = document.getElementById('content').offsetWidth;
	}
	else
	{
		window_width = (document.body) ? document.body.clientWidth : window.innerWidth;
	}

	var div_style_width = 120;

	mouseX = parseInt(mouseX);
	while(div_style_width + mouseX >= window_width)
	{
		mouseX -= 10;
	}
	div.style.left = mouseX + 'px';
	// Fin Ajout

	div.style.position = 'absolute';
	//div.style.width = '10em';

	/* ------- create the title of the menu with close button --------- */
	var p = document.createElement('p');
	//p.style.textAlign = 'left';
	p.setAttribute('class', 'close');
	p.setAttribute('className', 'close');
	var title_name = ' ' + ((user_name.length > 9) ? user_name.substr(0,9)+'...' : user_name);

	var close = document.createElement('img');
	close.onclick = new Function ('hideMenu();');
	close.setAttribute('src', 'http://illiweb.com/fa/cross.png');
	close.setAttribute('alt', 'Cerrar la ventana');
	//close.setAttribute('class', 'right');

	p.appendChild(document.createTextNode(title_name));
	p.appendChild(close);

	div.appendChild(p);

	/* --------- create the see profile link ------------- */
	var p = document.createElement('p');
	p.onmouseover = new Function ('this.className="hover";');
	p.onmouseout = new Function ('this.className="";');
	var link = document.createElement('a');
	link.appendChild(document.createTextNode("Ver el perfil"));
	link.setAttribute('href', '/profile.forum?mode=viewprofile&u='+user_id+'&sid='+sid);
	link.setAttribute('target', 'profile');
	link.onclick = new Function ("hideMenu();");

	p.appendChild(link);
	div.appendChild(p);

	/* --------- create the send pm link ------------- */
	var p = document.createElement('p');
	p.onmouseover = new Function ('this.className="hover";');
	p.onmouseout = new Function ('this.className="";');
	var link = document.createElement('a');
	link.appendChild(document.createTextNode("Enviar un Mensaje Privado"));
	link.setAttribute('href', '/msg.forum?mode=post&u='+user_id+'&sid='+sid);
	link.setAttribute('target', 'profile');
	link.onclick = new Function ("hideMenu();");

	p.appendChild(link);
	div.appendChild(p);

	/* --------- create the ban user link ------------- */
	if (document.forms[0].elements["message"] && my_chat_level == 2)
	{
		user_name = user_name.replace(/\\/g, "\\\\");
		user_name = user_name.replace(/\'/g, "\\'" );

		if (user_chat_level != 2)
		{
			/* -- Kick -- */
			var p = document.createElement('p');
			p.onmouseover = new Function ('this.className="hover";');
			p.onmouseout = new Function ('this.className="";');
			var link = document.createElement('a');
			link.appendChild(document.createTextNode("Patear del chat"));
			link.setAttribute('href', 'javascript:void(0)');
			link.onclick = new Function ("return action_user('kick', '"+user_name+"', '"+sid+"');");
			p.appendChild(link);
			div.appendChild(p);

			/* -- Ban -- */
			var p = document.createElement('p');
			p.onmouseover = new Function ('this.className="hover";');
			p.onmouseout = new Function ('this.className="";');
			var link = document.createElement('a');
			link.appendChild(document.createTextNode("Banear del ChatBox"));
			link.setAttribute('href', 'javascript:void(0)');
			link.onclick = new Function ("return action_user('ban','"+user_name+"', '"+sid+"');");
		}

		p.appendChild(link);
		div.appendChild(p);

		if (my_user_level == 1 && user_chat_level == 2 && user_level != 1 )
		{
			var p = document.createElement('p');
			p.onmouseover = new Function ('this.className="hover";');
			p.onmouseout = new Function ('this.className="";');
			var link = document.createElement('a');
			link.appendChild(document.createTextNode("Retirar moderaciÃ³n"));
			link.setAttribute('href', 'javascript:void(0)');
			link.onclick = new Function ("return action_user('unmod','"+user_name+"', '"+sid+"');");

			p.appendChild(link);
			div.appendChild(p);
		}
		else if (my_user_level == 1 && user_chat_level != 2 )
		{
			var p = document.createElement('p');
			p.onmouseover = new Function ('this.className="hover";');
			p.onmouseout = new Function ('this.className="";');
			var link = document.createElement('a');
			link.appendChild(document.createTextNode("AdiciÃ³n moderador"));
			link.setAttribute('href', 'javascript:void(0)');
			link.onclick = new Function ("return action_user('mod','"+user_name+"', '"+sid+"');");

			p.appendChild(link);
			div.appendChild(p);
		}
	}

	if (connected && user_id == my_user_id)
	{
		var p = document.createElement('p');
		p.onmouseover = new Function ('this.className="hover";');
		p.onmouseout = new Function ('this.className="";');
		var link = document.createElement('a');
		link.appendChild(document.createTextNode("Ausentarse"));
		link.setAttribute('href', 'javascript:void(0)');
		link.onclick = new Function ("return action_user('away', prompt('RazÃ³n',''), '"+sid+"');");

		p.appendChild(link);
		div.appendChild(p);

		var p = document.createElement('p');
		p.onmouseover = new Function ('this.className="hover";');
		p.onmouseout = new Function ('this.className="";');
		var link = document.createElement('a');
		link.appendChild(document.createTextNode("Salir"));
		link.setAttribute('href', 'javascript:void(0)');
//		link.onclick = new Function ("return action_user('exit', prompt('RazÃ³n',''), '"+sid+"');");
		link.onclick = new Function ("hideMenu();return CB_disconnect();");

		p.appendChild(link);
		div.appendChild(p);
	}

	document.body.appendChild(div);
	return false;
}

function action_user (cmd, user_name, sid)
{
	if (user_name == null) user_name = '';
	document.forms[0].elements["message"].value = '/' + cmd + ' ' + user_name;
	submitmsg( params );
	hideMenu ();
	return false;
}


/* only delete the contextmenu from the document */
function hideMenu ()
{
	document.getElementById('chatbox_contextmenu').parentNode.removeChild(document.getElementById('chatbox_contextmenu'));
}

function js_urlencode(text)
{
	text = text.toString();

	// this escapes 128 - 255, as JS uses the unicode code points for them.
	// This causes problems with submitting text via AJAX with the UTF-8 charset.
	var matches = text.match(/[\x90-\xFF]/g);
	if (matches)
	{
		for (var matchid = 0; matchid < matches.length; matchid++)
		{
			var char_code = matches[matchid].charCodeAt(0);
			text = text.replace(matches[matchid], '%u00' + (char_code & 0xFF).toString(16).toUpperCase());
		}
	}

	return escape(text).replace(/\+/g, "%2B");
}

function ajax_refresh_chatbox(params)
{
	if (window.XMLHttpRequest)
	{
		// Mozilla, Safari, ...
		var http_request = new XMLHttpRequest();
	} else if (window.ActiveXObject)
	{
		// IE
		var http_request = new ActiveXObject("Microsoft.XMLHTTP");
	}

	http_request.onreadystatechange = function()
	{
		if (http_request.readyState == 4 && http_request.status == 200)
		{
			// destroyer
			var parsed_text = http_request.responseText;

			// only connected
			if ( parent.frames['ekran'].document.getElementById('message_rows') )
			{
				parent.frames['ekran'].document.getElementById('message_rows').innerHTML = parsed_text;
				parent.frames['ekran'].window.scrollTo(0,99999);
				ajax_refresh_chatterlist(params);
			}

			if( parsed_text.indexOf('<script>/*stop_refresh*/</script>',0) != -1 )
			{
				clearInterval(parent.frames['ekran'].Interval);
				parent.frames['ekran'].refreshing = false;

				var title_params = (params == '') ? '?page=front' : params + '&page=front';
				parent.frames['title'].location.href 	= '/chatbox/chatbox_title.forum' + title_params;
				parent.frames['sender'].location.href 	= '/chatbox/messenger_send.forum' + title_params;
			}
			else
			{
				if ( parent.frames['ekran'].refreshing == false )
				{
					parent.frames['ekran'].Interval = setInterval('parent.frames[\'ekran\'].refresh_chatbox()', 8000);
					parent.frames['ekran'].refreshing = true;
				}
			}
		}
	};

	http_request.open('GET', '/chatbox/generate_messages.forum' + params , true);
	http_request.send(null);
}

function ajax_submit_chatbox(params)
{
	var data = '&nick=' + js_urlencode(document.post.nick.value);
	data += '&sent=' + js_urlencode(document.post.sent.value);
	data += '&sbold=' + document.post.sbold.value;
	data += '&sitalic=' + document.post.sitalic.value;
	data += '&sunderline=' + document.post.sunderline.value;
	data += '&sstrike=' + document.post.sstrike.value;
	data += '&scolor=' + document.post.scolor.value;

	if( document.post.sent.value == '/banlist' )
	{
		window.open('/chatbox/chatbox_banlist.forum' + params, 'color','toolbar=no,menubar=no,personalbar=no,width=450,height=300,scrollbars=no,resizable=yes');
		return false;
	}

	if (window.XMLHttpRequest)
	{
		// Mozilla, Safari, ...
		var http_request_submit = new XMLHttpRequest();
	} else if (window.ActiveXObject)
	{
		// IE
		var http_request_submit = new ActiveXObject("Microsoft.XMLHTTP");
	}

	http_request_submit.onreadystatechange = function()
	{
		if (http_request_submit.readyState == 4 && http_request_submit.status == 200)
		{
			// destroyer
			/*var parsed_text = http_request_submit.responseText;

			parent.frames['ekran'].document.getElementById('message_rows').innerHTML = parsed_text;
			parent.frames['ekran'].window.scrollTo(0,99999);*/
			ajax_refresh_chatbox(params);
			ajax_refresh_chatterlist(params);
		}
	};

	http_request_submit.open('POST', '/chatbox/generate_messages.forum' + params, true);
	http_request_submit.setRequestHeader('Content-Type','application/x-www-form-urlencoded;');
	http_request_submit.send(data);
}

function ajax_refresh_chatterlist(params)
{
	if (window.XMLHttpRequest)
	{
		// Mozilla, Safari, ...
		var http_request_list = new XMLHttpRequest();
	} else if (window.ActiveXObject)
	{
		// IE
		var http_request_list = new ActiveXObject("Microsoft.XMLHTTP");
	}

	http_request_list.onreadystatechange = function()
	{
		if (http_request_list.readyState == 4 && http_request_list.status == 200)
		{
			// destroyer
			var parsed_text = http_request_list.responseText;

			if (parent.frames['who'].document.getElementById('chatter_rows'))
			{
				parent.frames['who'].document.getElementById('chatter_rows').innerHTML = parsed_text;
			}
		}
	};

	http_request_list.open('GET', '/chatbox/generate_chatterlist.forum' + params , true);
	http_request_list.send(null);
}

function insert_chatboxsmilie(smilie_code)
{
	opener.document.getElementById('message').value = opener.document.getElementById('message').value + smilie_code;
	opener.document.post.message.focus();
	window.close();
}


function change_display_by_icon(element,element_id,content_more,content_less,display_special)
{
	element.className=(element.className=="icon_less")?"icon_more":"icon_less";
	element.style.background ='url(\''+ ((element.className=="icon_less")?'http://illiweb.com/fa/i/tabs_less.gif':'http://illiweb.com/fa/i/tabs_more.gif') + '\') no-repeat';
	if(content_more || content_less)
	{
		element.innerHTML=(element.className=="icon_less")?content_less:content_more;
	}
	if(!display_special)
	{
		display_special = 'block';
	}
	document.getElementById(element_id).style.display = ((element.className=="icon_more")?'none':display_special);

	my_setcookie('display_sql_info', element.className);
}

function switchuploadaddress(file) {
	if (file) {
		document.getElementById('upfile').style.display='inline';
		document.getElementById('upurl').style.display='none';
	}
	else {
		document.getElementById('upfile').style.display='none';
		document.getElementById('upurl').style.display='inline';
	}
}

function do_mark(mode, type)
{
	if ( type == 2 )
	{
		if ( mode == 7 )
		{
			for (i = 0; i < form.elements["mark[]"].length; ++i)
			{
				radio_box = form.elements["mark[]"][i];
				if (radio_box.checked == true)
				{
					radio_box.checked = false;
				}
				else
				{
					radio_box.checked = true;
				}
			}
		}
		else
		{
			if ( special_mark_modes[mode] == '' )
			{
				return;
			}
			for ( i = 0; i < special_mark_modes[mode].length; ++i )
			{
				radio_box = form.elements["mark[]"][special_mark_modes[mode][i]];
				if ( radio_box.checked == true )
				{
					radio_box.checked = false;
				}
				else
				{
					radio_box.checked = true;
				}
			}
		}
	}
	else
	{
		if ( type == 1 )
		{
			var value = false;
		}
		else
		{
			var value = true;
		}

		if ( mode == 7 )
		{
			for (i = 0; i < form.elements["mark[]"].length; ++i)
			{
				form.elements["mark[]"][i].checked = value;
			}
		}
		else
		{
			if ( special_mark_modes[mode] == '' )
			{
				return;
			}
			for ( i = 0; i < special_mark_modes[mode].length; ++i )
			{
				form.elements["mark[]"][special_mark_modes[mode][i]].checked = value;
			}
		}
	}
}

function checkreport()
{
	checked = false;
	if ( form.elements["mark[]"].length )
	{
		for ( i = 0; i < form.elements["mark[]"].length; ++i )
		{
			if ( form.elements["mark[]"][i].checked == true )
			{
				checked = true;
				break;
			}
		}
	}
	else
	{
		if ( form.elements["mark[]"].checked == true )
		{
			checked = true;
		}
	}
	if ( !checked )
	{
		alert('Â¡NingÃºn reporte seleccionado!');
		return false;
	}
	if ( delete_mode )
	{
		delete_mode = false;
		if ( confirm("Â¿EstÃ¡s seguro que quieres suprimir el/los reporte(s)?") == true )
		{
			form.confirm.value = 1;
		}
		else
		{
			return false;
		}
	}
	return true;
}

function insert_smilie(smiliepath, smilieid, smilie_code)
{
	if ( parent.document.getElementById('vB_Editor_001_mode').value == 1 )
	{
		parent.vB_Editor['vB_Editor_001'].insert_text('<img src="' + smiliepath + '" smilieid="' + smilieid + '" /> ', false);
	}
	else
	{
		parent.vB_Editor['vB_Editor_001'].insert_text(smilie_code + ' ', false);
	}
}

function unban_user(user, id)
{
	opener.fetch_object('message').value = '/unban ' + user;
	opener.submitmsg();

	document.getElementById(id).style.display = 'none';
}

function MM_openBrWindow(theURL,winName,features)
{
	window.open(theURL,winName,features);
}

function checkmodcp(action) {
	field = document.modcp.elements.length;
	switch(action)
	{	case "select":	for (i = 0; i < field; i++) {
		document.modcp.elements[i].checked = true;
	}
	break;
	case "unselect":	for (i = 0; i < field; i++) {
		document.modcp.elements[i].checked = false;
	}
	break;
	}
}

function check_rotation_radiobuttons() {
	if ( document.nuffimage_form.elements["nuff_rotation.checked"] == false)
	document.nuffimage_form.elements["nuff_rotation_d"].checked = false;
}

function select_switch_search(status) {
	for (i=0; i<document.post.length; i++) {
		document.post.elements[i].checked = status;
	}
}

function verify_select() {
	selectedfields = 0;

	for (i=0; i<document.post.length; i++) {
		if (document.post.elements[i].checked == true)
		{
			selectedfields++;
		}
	}

	if (selectedfields == 0)
	{
		msg_error = "Por favor selecciona al menos un tema";
		alert(msg_error);
		return false;
	}
	else
	{
		return true;
	}
}

function select_switch_line(numchamp) {
	for (i=(numchamp-1); i<(numchamp-1)+7; i++)
	{
		if (document.post.elements[i+6].disabled != true)
		{
			document.post.elements[i+6].checked = !document.post.elements[i+6].checked;
		}
	}
}

function select_switch_privmsg(status) {
	for (i=0; i<document.privmsg_list.length; i++) {
		document.privmsg_list.elements[i].checked = status;
	}
}


/*
* This function retrieves the search query from the URL.
*/

function GetParam(name)
{
	var match = new RegExp(name + "=([^&]+)","i").exec(location.search);
	if (match==null)
	{
		match = new RegExp(name + "=(.+)","i").exec(location.search);
	}

	if (match==null)
	{
		return null;
	}

	match = match + "";
	result = match.split(",");
	return result[1];
}


/*
* This function is required. It processes the google_ads JavaScript object,
* which contains AFS ads relevant to the user's search query. The name of
* this function <i>must</i> be <b>google_afs_request_done</b>. If this
* function is not named correctly, your page will not display AFS ads.
*/

function google_afs_request_done(google_ads)
{
	/*
	* Verify that there are actually ads to display.
	*/
	var google_num_ads = google_ads.length;
	if (google_num_ads <= 0)
	{
		return;
	}

	var wideAds = "";	// wide ad unit html text
	var narrowAds = "";	// narrow ad unit html text

	if ( google_num_ads > 1 )
	{
		for( var i = 0; i < google_num_ads; i++ )
		{
			// render a narrow ad
			narrowAds+='<div style="float:left;width:' + (728/google_num_ads) + 'px;"><a style="text-decoration:none" onmouseover="javascript:window.status=\'' +
			google_ads[i].url + '\';return true;" ' +
			'onmouseout="javascript:window.status=\'\';return true;" ' +
			'href="' + google_ads[i].url + '">' +
			'<span class="ad_line1">' + google_ads[i].line1 + '</span><br />' +
			'<span class="ad_text">' + google_ads[i].line2 + '</span><br />' +
			'<span class="ad_text">' + google_ads[i].line3 + '</span><br />' +
			'<div class="ad_url">' + google_ads[i].visible_url + '</div></a></div>';
		}
	}
	else if ( google_num_ads == 1 )
	{
		var i = 0;
		// render a wide ad
		narrowAds+='<div style="text-align:center;"><a style="text-decoration:none;" onmouseover="javascript:window.status=\'' +
		google_ads[i].url + '\';return true;" ' +
		'onmouseout="javascript:window.status=\'\';return true;" ' +
		'href="' + google_ads[i].url + '">' +
		'<span class="ad_line1">' + google_ads[i].line1 + '</span><br />' +
		'<span class="ad_text">' + google_ads[i].line2 + '</span><br />' +
		'<span class="ad_text">' + google_ads[i].line3 + '</span><br />' +
		'<div class="ad_url">' + google_ads[i].visible_url + '</div></a></div>';
	}

	if ( google_num_ads > 0 )
	{
		if (narrowAds != "")
		{
			narrowAds = narrowAds + '<a style="text-decoration:none" ' +
			'href="http://services.google.com/feedback/online_hws_feedback">' +
			'<div class="ad_header" style="text-align:right">Ads by Google</div></a>';
		}
	}

	// Write HTML for wide and narrow ads to the proper <div> elements
	if ( document.getElementById("narrow_ad_unit") )
	{
		document.getElementById("narrow_ad_unit").innerHTML = narrowAds;
	}
}

// Add/remove solved to topic subject
function set_solved(input,str)
{
	if(input)
	{
		var title = input.value;
		var reg = new RegExp("\\"+str,"g");
		input.value = ( reg.test(title) ) ? title.replace(reg,'') : str + title;
	}
}

function bbstyle_table()
{
	var nb_row = document.getElementById('table_gui_lines').value;
	var nb_cols = document.getElementById('table_gui_cols').value;
	if (nb_row>0 && nb_cols>0)
	{
		var txtarea = document.post.message;

		if (nb_row>100)
		{
			nb_row = 100;
		}
		if (nb_cols>100)
		{
			nb_cols = 100;
		}

		var content = "[table border=\"1\"]\n";
		for (var i=0; i<nb_row; i++)
		{
			content += "[tr]\n";
			for (var j=0; j<nb_cols; j++)
			{
				content += "[td] [/td]";
			}
			content += "\n[/tr]";
		}
		content += "\n[/table]";

		if ((clientVer >= 4) && is_ie && is_win)
		{
			theSelection = document.selection.createRange().text; // Get text selection
			if (theSelection)
			{
				// Add tags around selection
				document.selection.createRange().text = content;
				txtarea.focus();
				theSelection = '';
				return;
			}
			else
			{
				txtarea.value += content;
			}
		}
		else
		{
			var selLength = txtarea.textLength;
			var selStart = txtarea.selectionStart;
			var selEnd = txtarea.selectionEnd;
			if (selEnd == 1 || selEnd == 2)
			selEnd = selLength;
			var s1 = (txtarea.value).substring(0,selStart);
			var s2 = (txtarea.value).substring(selStart, selEnd)
			var s3 = (txtarea.value).substring(selEnd, selLength);
			txtarea.value = s1 + content + s3;
		}
		txtarea.focus();

		document.getElementById('table_gui_lines').value = '';
		document.getElementById('table_gui_cols').value = '';
		return;
	}
}

function display_upload_servimg(button, account, id, f)
{
	var container = document.getElementById('servimg_upload_gui');

	if ( !document.getElementById('obj_servimg') )
	{
		container.innerHTML = '<p><iframe id="obj_servimg" src="http://www.servimg.com/forum_upload.php?account=' + account + '&id=' + id + '&f=' + f + '" width="540" height="230" border="0" scrolling="no"></iframe></p>';
	}

	var div = document.getElementById('servimg_upload_gui');
	var visible = div.style.visibility;

	if ( visible == 'hidden' )
	{
		var window_w = (document.body) ? document.body.clientWidth : window.innerWidth;
		var cd = FindXY(button);
		var h = button.offsetHeight;
		var i = 0;
		while ( i < selectId.length )
		{
			if ( document.getElementById(selectId[i]) ) {
				document.getElementById(selectId[i]).style.visibility = 'hidden';
			}
			i++;
		}
		var sub = ((window_w - cd['x']) < 555) ? (555 - window_w + cd['x']) : 0;
		div.style.visibility = 'visible';
		div.style.width = 'auto';
		div.style.left = (cd['x']-sub)+'px';
		div.style.top = (cd['y']+h)+'px';
	}
	else
	{
		div.style.visibility = 'hidden';
	}
}

function display_upload_imageshack(button)
{
	var container = document.getElementById('servimg_upload_gui');

	if ( !document.getElementById('obj_servimg') )
	{
		container.innerHTML = '<p><iframe src="http://imageshack.us/iframe.php?txtcolor=111111&type=blank&size=30" scrolling="no" allowtransparency="true" frameborder="0" width="280" height="70">Update your browser for ImageShack.us!</iframe></p>';
	}

	var div = document.getElementById('servimg_upload_gui');
	var visible = div.style.visibility;

	if ( visible == 'hidden' )
	{
		var window_w = (document.body) ? document.body.clientWidth : window.innerWidth;
		var cd = FindXY(button);
		var h = button.offsetHeight;
		var i = 0;
		while ( i < selectId.length )
		{
			if ( document.getElementById(selectId[i]) ) {
				document.getElementById(selectId[i]).style.visibility = 'hidden';
			}
			i++;
		}
		var sub = ((window_w - cd['x']) < 555) ? (555 - window_w + cd['x']) : 0;
		div.style.visibility = 'visible';
		div.style.width = 'auto';
		div.style.left = (cd['x']-sub)+'px';
		div.style.top = (cd['y']+h)+'px';
	}
	else
	{
		div.style.visibility = 'hidden';
	}
}

// Affichage du tooltip
var gw_window = null;
var gw_style = null;
var offsetx = 8;
var offsety = 12;
var curX = 0;
var curY = 0;
var distX = 0;
var distY = 0;
var obj_ietruebody = (document.all) ? (document.compatMode && document.compatMode!="BackCompat") ? document.documentElement : document.body : '';
function gws_show(element,div_element,ev)
{
	if(gw_window == null)
	{
		gw_window = document.createElement("div");
		gw_window.id = "gw_window";
		gw_window.style.width = "470px";
		document.body.appendChild(gw_window);
		gw_style = document.createElement("style");
		gw_style.type="text/css";
		var css_text = ".translucent{background:#161411 none repeat scroll 0%;height:auto;opacity:0.93;padding:5px;width:460px;}.skill_link{color:#0000FF;}.gwno_border{margin:0pt;padding:0pt;}table.gwborder{width:466px;}img.no_link{border:medium none;}.table_image{font-size:10pt;padding-right:10px;text-align:center;vertical-align:top;}.skill_text{vertical-align:top;}.skill_name{color:#BFB38B;float:left;font-size:15px;font-weight:700;}.skill_desc{clear:both;color:white;display:block;font-size:11px;line-height:20px;padding-top:5px;text-align:left;}.skill_camp{color:#AAD38B;font-size:9px;font-weight:bold;}.skill_pve{color:#B0B080;font-size:9px;}.expert{color:#BDC6FF;padding-left:2px;}.elite_skill{background-color:#6B6226;}.normal_skill{background-color:#161411;}.build_name{color:#BFB38B;font-size:11pt;font-weight:700;padding-bottom:5px;text-align:left;}.build_desc{color:white;font-size:11px;line-height:20px;text-align:left;}.build_lilname{font-family:verdana;font-size:10px;line-height:12px;padding:0px;}.attribute{color:white;font-size:12px;line-height:20px;padding-left:20px;}.skill_requirements{display:inline;list-style-type:none;margin:0pt;padding:0pt;}.skill_requirements li{color:white;display:inline;float:right;font-size:12px;font-weight:bold;margin-right:5px;}span.variable{color:#88FF88;font-weight:bold;}.table_image, .skill_name, .skill_desc, .skill_camp, .expert, .build_name, .build_desc, .attribute, .skill_requirements, .skill_requirements li, span.variable{font-family:verdana,Helvetica,sans-serif;}.gwborder_topleft{background-image:url('.GWBBCODE_IMG_PATH.'/img_border/topleft.gif);height:3px;width:3px;}.gwborder_top{background-image:url('.GWBBCODE_IMG_PATH.'/img_border/top.gif);height:3px;}.gwborder_topright{background-image:url('.GWBBCODE_IMG_PATH.'/img_border/topright.gif);height:3px;width:3px;}.gwborder_left{background-image:url('.GWBBCODE_IMG_PATH.'/img_border/left.gif);width:3px;}.gwborder_right{background-image:url('.GWBBCODE_IMG_PATH.'/img_border/right.gif);width:3px;}.gwborder_bottomleft{background-image:url('.GWBBCODE_IMG_PATH.'/img_border/bottomleft.gif);height:3px;width:3px;}.gwborder_bottom{background-image:url('.GWBBCODE_IMG_PATH.'/img_border/bottom.gif);height:3px;}.gwborder_bottomright{background-image:url('.GWBBCODE_IMG_PATH.'/img_border/bottomright.gif);height:3px;width:3px;}table.gwbuildbox{height:50px;}.gwbuildbox_left{height:50px;width:20px;}.gwbuildbox_right{height:50px;width:20px;}.gwbuildbox_left[class]{background-image:url('.GWBBCODE_IMG_PATH.'/img_border/buildbox_left.png);background-repeat:no-repeat;height:50px;width:20px;}.gwbuildbox_center{background-image:url('.GWBBCODE_IMG_PATH.'/img_border/buildbox_center.png);height:50px;}.gwbuildbox_right[class]{background-image:url('.GWBBCODE_IMG_PATH.'/img_border/buildbox_right.png);background-repeat:no-repeat;height:50px;width:20px;}table.gwborders{width:470px;}div#gw_window{position:absolute;z-index:10000;display:none;}";
		if(gw_style.styleSheet){
			gw_style.styleSheet.cssText = css_text;
		} else {
			gw_style.appendChild(document.createTextNode(css_text));
		}
		document.body.appendChild(gw_style);
	}
	element.onmouseout = function(){
		gw_window.style.display = "none";
	};
	gw_window.style.display = "block";
	gw_window.innerHTML = document.getElementById(div_element).innerHTML;
	curX = (document.getElementById && !document.all) ? ev.pageX : event.x + obj_ietruebody.scrollLeft;
	curY = (document.getElementById && !document.all) ? ev.pageY : event.y + obj_ietruebody.scrollTop;
	distX = document.all && !window.opera ? obj_ietruebody.clientWidth - event.clientX-offsetx : window.innerWidth - ev.clientX-offsetx-20;
	distY = document.all && !window.opera ? obj_ietruebody.clientHeight - event.clientY-offsety : window.innerHeight - ev.clientY-offsety-20;
	if (distX < gw_window.offsetWidth) {
		if (curX+offsetx-gw_window.offsetWidth < 0)
		{
			gw_window.style.left = "0px";
		}
		else
		{
			gw_window.style.left = curX-10-gw_window.offsetWidth+"px";
		}
	} else {
		gw_window.style.left = curX+offsetx+"px";
	}
	if (distY < gw_window.offsetHeight) {
		if(curY > gw_window.offsetHeight)
		{
			gw_window.style.top = curY-10-gw_window.offsetHeight+"px";
		}else{
			gw_window.style.top = curY+offsety+distY-gw_window.offsetHeight+"px";
		}
	}else{
		gw_window.style.top = curY+offsety+"px";
	}
}

// Resize functions
var elem;
var divHeight;
var mouseX;
var mouseY;

function returnNumber (str) {
	var result = '';
	for (i = 0; i < str.length; i++) {
		if ((str.charAt(i) * 1) >= 0 && (str.charAt(i) * 1) <= 9)
		result += str.charAt(i);
		else
		return result *1;
	}
	return result*1;
}

function resizeElement (event, id) {
	var el;
	var x, y;

	elem = document.getElementById(id);

	if (document.all) {
		mouseX = window.event.clientX + document.body.scrollLeft;
		mouseY = window.event.clientY + document.body.scrollTop;
	}
	else {
		mouseX = event.clientX + window.scrollX;
		mouseY = event.clientY + window.scrollY;
	}

	divHeight = elem.style.height;

	if (isNaN(divHeight)) divHeight = returnNumber(divHeight);

	if (document.all) {
		document.attachEvent("onmousemove", resize);
		document.attachEvent("onmouseup", stopResize);
		window.event.cancelBubble = true;
		window.event.returnValue = false;
	}
	else {
		document.addEventListener("mousemove", resize, true);
		document.addEventListener("mouseup", stopResize, true);
		event.preventDefault();
	}
}

function resize(event) {
	var x, y;
	var minHeight = 100;

	if (document.all) {
		x = window.event.clientX + document.body.scrollLeft;
		y = window.event.clientY + document.body.scrollTop;
	}
	else {
		x = event.clientX + window.scrollX;
		y = event.clientY + window.scrollY;
	}

	if (divHeight + y - mouseY < minHeight)
	elem.style.height = minHeight + "px";
	else
	elem.style.height = (divHeight + y - mouseY) + "px";

	if (document.all) {
		window.event.cancelBubble = true;
		window.event.returnValue = false;
	}
	else
	event.preventDefault();
}

function stopResize(event) {
	if (document.all) {
		document.detachEvent("onmousemove", resize);
		document.detachEvent("onmouseup", stopResize);
	}
	else {
		document.removeEventListener("mousemove", resize, true);
		document.removeEventListener("mouseup", stopResize, true);
	}
}

function update_dst(user_gmt, user_dst, session_id)
{
	var params = '';
	var time_diff = new Date().getTimezoneOffset() / 60;
	time_diff = time_diff * -1;

	if ( user_dst == 1 )
	{
		user_gmt++;
	}

	if ( time_diff == user_gmt + 1 || time_diff == user_gmt - 1 )
	{
		if ( time_diff == user_gmt - 1 && user_dst == 0 )
		{
			params = 'action=gmt&do=-1';
		}
		else if ( time_diff == user_gmt + 1 && user_dst == 1 )
		{
			params = 'action=gmt&do=1';
		}
		else
		{
			params = 'action=dst';
		}

		params += '&sid=' + session_id;
		ajax_exec('updatedst.forum?' + params);
	}
}

function ajax_exec(url)
{
	if ( window.XMLHttpRequest )
	{
		// Mozilla, Safari, ...
		var http_request_list = new XMLHttpRequest();
	}
	else if ( window.ActiveXObject )
	{
		// IE
		var http_request_list = new ActiveXObject("Microsoft.XMLHTTP");
	}

	http_request_list.onreadystatechange = function()
	{
		if (http_request_list.readyState == 4 && http_request_list.status == 200)
		{
			// destroyer
			var parsed_text = http_request_list.responseText;
		}
	};

	http_request_list.open('GET', url , true);
	http_request_list.send(null);
}