//  Copyright (C) 2005-2006  Xenno Group group.xennobb.com.
//  Visit XennoBB at www.xennobb.com.
//
//  XennoBB is free software; you can redistribute it and/or modify it
//  under the terms of the GNU General Public License as published
//  by the Free Software Foundation; either version 2 of the License,
//  or (at your option) any later version.
//
//  XennoBB is distributed in the hope that it will be useful, but
//  WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//  MA 02110-1301 USA
var var_cookieid = "";var var_cookie_domain = "";var var_cookie_path   = "/";function my_getcookie(name){cname = var_cookieid + 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";}if (var_cookie_domain != ""){domain = '; domain=' + var_cookie_domain;}if (var_cookie_path != ""){path = var_cookie_path;}document.cookie = var_cookieid + name + "=" + value + "; path=" + path + expire + domain + ';';}function my_getbyid(id){itm = null;if (document.getElementById){itm = document.getElementById(id);}else if (document.all){itm = document.all[id];}else if (document.layers){itm = document.layers[id];}return itm;}function my_hide_div(itm){if (!itm) return;itm.style.display = "none";}function my_show_div(itm){if (!itm) return;itm.style.display = "";}function togglecategory(fid, add){saved = new Array();clean = new Array();if (tmp = my_getcookie('collapseprefs')){saved = tmp.split(",");}for(i = 0 ; i < saved.length; i++){if (saved[i] != fid && saved[i] != ""){clean[clean.length] = saved[i];}}if (add){clean[ clean.length ] = fid;my_show_div(my_getbyid('ido'+fid));my_hide_div(my_getbyid('idx'+fid));}else{my_show_div(my_getbyid( 'idx'+fid));my_hide_div(my_getbyid( 'ido'+fid));}my_setcookie('collapseprefs', clean.join(','), 1);}
var ie  = document.all  ? 1 : 0;
var ns4 = document.layers ? 1 : 0;
function SelectCbox(cb)
{
	if (ie)
	{
		while (cb.tagName != "TR")
		{
			cb = cb.parentElement;
		}
	}
	else
	{
		while (cb.tagName != "TD")
		{
			cb = cb.parentNode;
		}
	}
	cb.className = 'tcmod_sel';
}
function cca(cb)
{
	if (cb.checked)
	{
		SelectCbox(cb);
	}
	else
	{
		DeselectCbox(cb);
	}
}
function DeselectCbox(cb)
{
	if (ie)
	{
		while (cb.tagName != "TR")
		{
			cb = cb.parentElement;
		}
	}
	else
	{
		while (cb.tagName != "TD")
		{
			cb = cb.parentNode;
		}
	}
	cb.className = 'tcmod';
}
function InboxCheckAll(cb)
{
	var fmobj = document.multiselect;
	for (var i=0;i<fmobj.elements.length;i++)
	{
		var e = fmobj.elements[i];
		if ((e.name != 'allbox') && (e.type=='checkbox') && (!e.disabled))
		{
			e.checked = fmobj.allbox.checked;
			if (fmobj.allbox.checked)
			{
				SelectCbox(e);
			}
			else
			{
				DeselectCbox(e);
			}
		}
	}
}
function mail_to(s){var n = 0;var r = "";for (var i = 0; i < s.length; i++){n = s.charCodeAt(i);if (n>= 8364) n = 128;r += String.fromCharCode(n-(2));}location.href = "mailto:"+r;}
function OpenWindow(url,w,h)
{
	window.open(url,"Admin Control Panel","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width="+w+", height="+h);
}
function Expand_QP(e, v)
{
	rows_val = parseFloat(document.getElementById(e).getAttribute('rows'));
	if (rows_val < v) { rows_val = rows_val + 5 }
	document.getElementById(e).setAttribute('rows', rows_val);
}
function Collapse_QP(e, v)
{
	rows_val = parseFloat(document.getElementById(e).getAttribute('rows'));
	if (rows_val > v) { rows_val = rows_val - 5 } 
	document.getElementById(e).setAttribute('rows', rows_val);
}
var prefsLoaded = false;
var defaultFontSize = 76;
var currentFontSize = defaultFontSize;
var currentStyle = "Fixed";
function revertStyles()
{
	currentFontSize = defaultFontSize;
	changeFontSize(0);
}
function switchFluid()
{
	if(currentStyle == "Fluid")
	{
		setWidth("Fixed");
	}
}
function switchFixed()
{
	if(currentStyle == "Fixed")
	{
		setWidth("Fluid");
	}
}
function setWidth(width)
{
	d=new Date();
	flash=Math.round(Math.random()*d.getTime());
	if(width != "Fixed")
	{
		document.body.className = 'bodyfluid';
		currentStyle = "Fluid";
	}
	else
	{
		document.body.className = '';
		currentStyle = "Fixed";
	}
}
function changeFontSize(sizeDifference)
{
	currentFontSize = parseInt(currentFontSize) + parseInt(sizeDifference * 5);
	if(currentFontSize > 100)
	{
		currentFontSize = 100;
	}
	else if(currentFontSize < 60)
	{
		currentFontSize = 60;
	}
	setFontSize(currentFontSize);
};
function setFontSize(fontSize)
{
	var stObj = (document.getElementById) ? document.getElementById('main_body') : document.all('main_body');
	document.body.style.fontSize = fontSize + '%';
};
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
};
function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
};
window.onload = setWidthFont;
function setWidthFont()
{
	if(!prefsLoaded)
	{
		cookie = readCookie("fontSize");
		currentFontSize = cookie ? cookie : defaultFontSize;
		setFontSize(currentFontSize);
		cookie = readCookie("pageWidth");
		currentStyle = cookie ? cookie : "Fixed";
		setWidth(currentStyle);
		prefsLoaded = true;
	}
}
window.onunload = saveSettings;
function saveSettings()
{
	createCookie("fontSize", currentFontSize, 365);
	createCookie("pageWidth", currentStyle, 365);
}