//init
var server='frontend.php';
var autopub=1;
function showsite() {
	$('dopreload').style.display='none';
	$('showsite').style.display='block';
	updateimgs();
	pub_update(0);
}
function pub_next() {
	autopub=0;
	num_pub++;
	var args = 'action=pub&see=' + num_pub;
	var do_ajax = new Ajax.Request(server, {method: 'get', parameters: args, onComplete: handle_pub_update});
}
function pub_previous() {
	autopub=0;
	num_pub--;
	var args = 'action=pub&see=' + num_pub;
	var do_ajax = new Ajax.Request(server, {method: 'get', parameters: args, onComplete: handle_pub_update});
}
function pub_update(num) {
	var args = 'action=pub&num=' + num;
	var do_ajax = new Ajax.Request(server, {method: 'get', parameters: args, onComplete: handle_pub_update});
}
function handle_pub_update(request) {
	var devolvido=request.responseText;
	if (devolvido=="erro") {
		$('pub_spotlight').style.backgroundImage = "url(images/pub_spotlight.gif)";
		$('pub_spotlight_text').innerHTML="<div align='center'>There is no image to display.</div>";
	}
	else {
		var temp=devolvido.split("|");
		$('pub_spotlight').style.backgroundImage = "url(" + temp[1] + ")";
		$('pub_spotlight_text').innerHTML="<a href='" + temp[2] + "'><img src='images/pub_spotlight.gif' alt='' width='317' height='120' title='" + temp[3] +"' usemap='#spotlight'></a>";
		num_pub=temp[0];
		if (autopub==1) setTimeout("pub_update(" + num_pub + ")",pub_delay);
	}
}
//menu
function clearmenu() {
	$('menu').innerHTML='&nbsp;';
}
function team() {
	$('menu').innerHTML='<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td width="15" height="27">&nbsp;</td><td width="80"><a href="?c=news&s=team"><img src="images/menu_sub_news.gif" alt="" width="27" height="9"></a></td><td width="95"><a href="?c=team"><img src="images/menu_sub_squads.gif" alt="" width="39" height="9"></a></td><td width="95"><a href="?c=awards"><img src="images/menu_sub_awards.gif" alt="" width="39" height="9"></a></td><td width="95"><a href="?c=about&s=contact"><img src="images/menu_sub_contact.gif" alt="" width="45" height="9"></a></td><td><a href="?c=about"><img src="images/menu_sub_about.gif" alt="" width="33" height="9"></a></td><td width="15">&nbsp;</td></tr></table>';
}
function scene() {
	$('menu').innerHTML='<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td width="15" height="27">&nbsp;</td><td width="80"><a href="?c=news&s=scene"><img src="images/menu_sub_news.gif" alt="" width="27" height="9"></a></td><td width="105"><a href="?c=news&s=coverage"><img src="images/menu_sub_coverage.gif" alt="" width="51" height="9"></a></td><td><a href="?c=news&s=article"><img src="images/menu_sub_articles.gif" alt="" width="49" height="9"></a></td></tr></table>';
}
function mediam() {
	$('menu').innerHTML='  <table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td width="15" height="27">&nbsp;</td><td width="110"><a href="?c=galleries"><img src="images/menu_sub_galleries.gif" alt="" width="55" height="9"></a></td><td width="95"><a href="?c=files&s=5"><img src="images/menu_sub_videos.gif" alt="" width="37" height="9"></a></td><td width="90"><a href="?c=files&s=4"><img src="images/menu_sub_demos.gif" alt="" width="33" height="9"></a></td><td><a href="?c=files&s=8"><img src="images/menu_sub_replays.gif" alt="" width="45" height="9"></a></td></tr></table>';
}
//misc
function addtext(text,id) {
	$(id).value+=text;
	$(id).focus();
}
function valid_message(field) {
	if (!$F(field)) {
		common_error(field,'Enter the desired message before submiting.');
		return false;
	}
	return true;
}
function valid_dologin() {
	if (!$F('userlogin')||!$F('userpass')) {
		common_error('userpass','Enter the username/password before login.');
		return false;
	}
}
function common_error(field,message) {
	alert(message);
	$(field).focus();
}
function checkEnter() {
	if (event.keyCode == 13) {
		event.cancelBubble = true;
		event.returnValue = false;
		self.document.login.submit();
	}
}
function results(group) {
	temp=self.document.getElementById("group" + group);
	if (temp.style.display=="none") { temp.style.display="block"; self.document.getElementById("menos" + group).style.display="block"; self.document.getElementById("mais" + group).style.display="none"; }
	else { temp.style.display="none"; self.document.getElementById("menos" + group).style.display="none"; self.document.getElementById("mais"  + group).style.display="block"; }
}
