fetch_object('active_nav_time').style.marginLeft = parseInt(fetch_object('active_nav_user').offsetWidth - 3) + 'px';

respace_header_elems = function()
{
	fetch_object('active_nav_time').style.marginLeft = parseInt(fetch_object('active_nav_user').offsetWidth - 3) + 'px';
	fetch_object('header_login_row').style.marginLeft = (parseInt(fetch_object('active_nav_user').offsetWidth - 3) + 162) + 'px';
}

make_header_login = function(is_ff,cdn_url)
{
	ldiv = fetch_object('header_login_row');
	ldiv = apply_style_properties(ldiv, {
		'background'	: 'url('+cdn_url+'images/misc/nav_login_row.gif) no-repeat',
		'marginLeft'	: '161px',
		'overflow'	: 'hidden',
		'marginTop'	: '-22px',
		'height'	: '21px',
		'zIndex'	: '4',
		'width'		: '497px',
		'position'	: 'absolute'
	});

	lform = document.createElement('form');
	lform.action = 'login.php?do=login';
	lform.method = 'POST';

	lform.appendChild(make_header_input('hidden', 'vb_login_md5password', ''));
	lform.appendChild(make_header_input('hidden', 'vb_login_md5password_utf', ''));
	lform.appendChild(make_header_input('hidden', 'do', 'login'));

	nldiv = document.createElement('div');
	nldiv.className = 'nav_login';

	buser = document.createElement('b');
	buser.appendChild(document.createTextNode('Username:'));

	buser = apply_style_properties(buser, {
		'fontWeight'	: 'normal',
		'position'	: 'relative',
		'top'		: ((is_ff) ? '1' : '-3') + 'px'
	});

	bpass = document.createElement('b');
	bpass.appendChild(document.createTextNode('Password:'));

	bpass = apply_style_properties(bpass, {
		'fontWeight'	: 'normal',
		'position'	: 'relative',
		'top'		: ((is_ff) ? '1' : '-3') + 'px'
	});

	nldiv.appendChild(buser);
	nldiv.appendChild(make_header_input('text', 'vb_login_username', '', {
		'id'		: 'ff_header_login_username',
		'className'	: 'button',
		'size'		: '10'
	},{
		'height'	: ((is_ff) ? '15' : '14') + 'px',
		'background'	: '#E0E2F0',
		'border'	: '1px solid #809AB7',
		'fontSize'	: '11px',
		'marginTop'	: '-4px',
		'verticalAlign'	: 'top',
		'marginRight'	: '5px',
		'width'		: '85px'
	}));
	nldiv.appendChild(bpass);
	nldiv.appendChild(make_header_input('password', 'vb_login_password', '', {
		'className'	: 'button',
		'size'		: '10'
	},{
		'height'	: ((is_ff) ? '15' : '14') + 'px',
		'background'	: '#E0E2F0',
		'border'	: '1px solid #809AB7',
		'fontSize'	: '11px',
		'marginTop'	: '-4px',
		'verticalAlign'	: 'top',
		'marginRight'	: '5px',
		'width'		: '85px'
	}));
	nldiv.appendChild(make_header_input('submit', '', 'Login', {
		'className'	: 'button'
	},{
		'fontSize'	: '11px',
		'marginTop'	: ((is_ff) ? '-4' : '-4') + 'px',
		'marginRight'	: '0px'
	}));
	nldiv.appendChild(make_header_input('checkbox', 'cookieuser', '1', {
		'className'	: 'button',
		'id'		: 'vb_login_rem'
	},{
		'marginTop'	: ((is_ff) ? '-4' : '-4') + 'px',
		'marginLeft'	: '11px',
		'paddingTop'	: ((is_ff) ? '4' : '0') + 'px'
	}));

	brem = document.createElement('b');
	brem.appendChild(document.createTextNode('Remember'));

	brem = apply_style_properties(brem, {
		'fontWeight'	: 'normal',
		'position'	: 'relative',
		'top'		: ((is_ff) ? '1' : '-3') + 'px'
	});
	nldiv.appendChild(brem);

	lform.appendChild(nldiv);
	ldiv.appendChild(lform);

	fetch_object('header_login_row').style.marginLeft = (parseInt(fetch_object('active_nav_user').offsetWidth - 3) + 162) + 'px';
	fetch_object('vb_login_rem').checked = true;
}

apply_style_properties = function(obj, style)
{
	for (property in style)
	{
		eval('obj.style.' + property + ' = "' + style[property] + '";');
	}

	return obj;
}

make_header_input = function(type, name, value, other, style)
{
	input = document.createElement('input');	
	input.type = type;
	input.name = name;
	input.value = value;

	if (other != 'undefined')
	{
		for (property in other)
		{
			eval('input.' + property + ' = "' + other[property] + '";');
		}
	}

	if (style != 'undefined')
	{
		input = apply_style_properties(input, style);
	}

	return input;
}

make_header_search = function(searchval, is_ff, searchtype)
{
	search = document.createElement('div');
	search.id = 'header_search_container';

	sform = document.createElement('form');
	sform.id = 'ff_header_sform';
	sform.action = 'forum.php?' + SESSIONURL;
	sform.method = 'post';
	sform.onsubmit = function(){ return header_fast_search(this); }

	sform.appendChild(make_header_input('hidden', 'do', 'fastsearch', {
		'id'	: 'header_do_act'
	}));
	sform.appendChild(make_header_input('hidden', 'showposts', '1'));
	sform.appendChild(make_header_input('hidden', 'sortby', 'lastpost'));
	sform.appendChild(make_header_input('hidden', 'order', 'descdending'));

	var userAgent = navigator.userAgent.toLowerCase();
	var is_opera  = ((userAgent.indexOf('opera') != -1) || (typeof(window.opera) != 'undefined'));
	var is_saf    = ((userAgent.indexOf('applewebkit') != -1) || (navigator.vendor == 'Apple Computer, Inc.'));
	var is_webtv  = (userAgent.indexOf('webtv') != -1);
	var is_ie     = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));

	nav = document.createElement('div');
	nav.id = 'active_nav_search';
	nav.className = 'nav_search_off ff_nav_search';

	nav.appendChild(make_header_input('text', 'query', searchval, {
		'size'		: 6,
		'className'	: 'button',
		'id'		: 'ff_header_sformq'
	},{
		'background'	: '#E0E2F0',
		'border'	: '1px solid #809AB7',
		'width'		: ((is_ff) ? '58' : '68') + 'px',
		'fontSize'	: '11px',
		'position'	: is_ie ? 'absolute' : '',
		'marginLeft'	: is_ie ? '-87px' : '',
		'marginTop'	: '-3px',
		'height'	: '14px',
		'paddingTop'	: '2px'
	}));

	select = document.createElement('select');
	select.id = 'header_search_type';
	select.name = 'searchtype';
	select.className = 'button';

	select = apply_style_properties(select, {
		'background'	: '#E0E2F0',
		'position'	: is_ie ? 'absolute' : '',
		'marginLeft'	: is_ie ? '-12px' : '4px',
		'marginTop'	: '-3px',
		'fontSize'	: '11px'
	});

	opta = new Option('Site', 'site');
	optb = new Option('Forums', 'forum');

	nav.appendChild(select);

	nav.appendChild(make_header_input('submit', '', 'Go', {
		'className'	: 'button'
	},{
		'position'	: is_ie ? 'absolute' : '',
		'marginLeft'	: is_ie ? '59px' : '4px',
		'marginTop'	: '-4px',
		'fontSize'	: '11px'
	}));

	sform.appendChild(nav);
	search.appendChild(sform);

	fetch_object('header_search').appendChild(search);

	fetch_object('header_search_type').options[0] = opta;
	fetch_object('header_search_type').options[1] = optb;

	if (searchtype == 'forum')
	{
		fetch_object('header_search_type').options[1].selected = true;
	}

	fetch_object('ff_header_sformq').onclick = function() {if (this.value == 'Search') { this.value = ''; }};

	fetch_object('active_nav_search').style.marginLeft = (parseInt(fetch_object('active_nav_time').style.marginLeft) + parseInt(fetch_object('active_nav_time').offsetWidth - 3)) + 'px';

	//alert('respawcing container');

	//fetch_object('header_search_container').style.position = 'absolute';
	//fetch_object('header_search_container').style.marginLeft = (parseInt(fetch_object('active_nav_time').style.marginLeft) + parseInt(fetch_object('active_nav_time').offsetWidth - 3)) + 'px';

	setTimeout("respace_header_elems()", 4000); // a just in-case
}

detail_loader = new Array();
function log_out(){}

show_login = function()
{
loginrow = fetch_object('header_login_row');
curheight = parseInt(loginrow.style.marginTop);

if (curheight == 0)
{
hide_login();
return false;
};

curheight += 22;

loginrow.style.marginTop = curheight + 'px';

if (is_ie && !is_ie7 && fetch_object('header_search_type').style.visibility != 'hidden')
{
fetch_object('header_search_type').style.visibility = 'hidden';
};

if (curheight < 0)
{
setTimeout("show_login();", 5);
}
else
{
try
{
fetch_object('ff_header_login_username').focus();
}
catch(e){}
};

return false;
}

hide_login = function()
{
loginrow = fetch_object('header_login_row');
curheight = parseInt(loginrow.style.marginTop);
curheight -= 22;

loginrow.style.marginTop = curheight + 'px';

if (curheight > -22)
{
setTimeout("hide_login();", 5);
}
else
{
if (is_ie && !is_ie7)
{
fetch_object('header_search_type').style.visibility = '';
}
}
}

header_fast_search = function(form)
{
searchtype = fetch_object('header_search_type').options[fetch_object('header_search_type').options.selectedIndex].value

if (searchtype == 'site')
{
form.action = 'sitesearch.php?' + SESSIONURL;
form.method = 'GET';
}
else
{
form.action = 'search.php?' + SESSIONURL;
fetch_object('header_do_act').value = 'process';
};

return true;
}

_header_nav = function(ndefault, ngroup, ntype)
{
this.navdefault = 'active_nav_' + ndefault;
this.navtype = ntype;

this.init = function()
{
for (var n = 0; n < ngroup.length; n++)
{
is_default = 'active_nav_' + ngroup[n] == this.navdefault;

if (is_default && ngroup[n] == 'time')
{
fetch_object('active_nav_time').getElementsByTagName('a')[0].className = 'ff_nav_time_link_on';
}

class_extra = fetch_object('active_nav_' + ngroup[n]).className.split(' ')[1];
fetch_object('active_nav_' + ngroup[n]).className = is_default ? 'nav_' + this.navtype + '_on' : 'nav_' + this.navtype + '_off';
fetch_object('active_nav_' + ngroup[n]).className = fetch_object('active_nav_' + ngroup[n]).className + ((class_extra) ? ' ' + class_extra : '');
fetch_object('active_nav_' + ngroup[n]).style.zIndex = is_default ? 3 : 1;
}
};

this.flicker = function(element)
{
if (element == this.navdefault)
{
return false;
}

if (fetch_object(element).className == 'nav_' + this.navtype + '_on')
{
fetch_object(element).className = 'nav_' + this.navtype + '_off';
fetch_object(element).style.zIndex = 1;
}
else
{
fetch_object(element).className = 'nav_' + this.navtype + '_on';
fetch_object(element).style.zIndex = 2;
}
};
}