// ###################################### IMAGEM ######################################
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// ###################################### FAQ ######################################
/*************************************************************
*	DHTML Collapsible FAQ MOD v1.0.0
*
*	Copyright (C) 2004, Markus (http://www.phpmix.com)
*	This script is released under GPL License.
*	Feel free to use this script (or part of it) wherever you need
*	it ...but please, give credit to original author. Thank you. :-)
*	We will also appreciate any links you could give us.
*
*	Enjoy! ;-)

*************************************************************/

function _CFAQ()
	{
	this.lastOpened = '';
	return this;
	}

_CFAQ.prototype.IsDisplaySupported = function()
	{
	if( window.opera && !document.childNodes ) return false;
	if( document.getElementById || document.all ) return true;
	return false;
	}

_CFAQ.prototype.getQueryVar = function(varName)
	{
	var q = window.location.search.substring(1);
	var v = q.split('&');
	for( var i=0; i < v.length; i++ )
		{
		var p = v[i].split('=');
		if( p[0] == varName ) return p[1];
		}
	return null;
	}

_CFAQ.prototype.getObj = function(obj)
	{
	return ( document.getElementById ? document.getElementById(obj) : ( document.all ? document.all[obj] : null ) );
	}

_CFAQ.prototype.displayObj = function(obj, status)
	{
	var x = this.getObj(obj);
	if( x && x.style ) x.style.display = status;
	}

_CFAQ.prototype.display = function(faq_id, isLink)
	{
	if( this.IsDisplaySupported() )
		{
		if( !isLink )
			{
			if( this.lastOpened != '' )
				{
				this.displayObj(this.lastOpened, 'none');
				}
			if( this.lastOpened != faq_id )
				{
				this.displayObj(faq_id, '');
				this.lastOpened = faq_id;
				}
			else
				{
				this.lastOpened = '';
				}
			}
		return false;
		}
	return true;
	}

var CFAQ = new _CFAQ();

if( !CFAQ.IsDisplaySupported() )
	{
	var u_faq = window.location.href;
	u_faq += ( u_faq.indexOf('?') > 0 ? '&' : '?' ) + 'dhtml=no';
	window.location.replace(u_faq);
	}

// ###################################### MENU ######################################
function InitializePage()
	{
	LoadMenu();
	}

var menu = new Array();
menu[0] = new Object();
var unloadhelper = false;

function LoadMenu()
	{
	document.getElementById("submenu_"+activeSubmenuItem).style.color = "white";
	document.getElementById("ActiveSubmenuItemIcon_"+activeSubmenuItem).style.visibility = "visible";
	if(self.name.lastIndexOf("&") == -1)
		{
	  	self.name = "principal=1&spore_pc_mac=0&criador_criaturas=0&medonhas_fofinhas=0&spore_creatures_ds=0&spore_celular=0&imagens=0&videos=0&downloads=0&reportagens=0&sobre_site=0&login=1&ultimas_forum=1&enquete_semana=1&enquetes=0&meta=1&parceiros=1&";
		}
	FillMenuArray();
	InitializeMenu();
	}

function SaveMenu()
	{
	if(unloadhelper == false)
		{
		SaveMenuArray();
		unloadhelper = true;
		}
	}

function FillMenuArray()
	{
	while(self.name.length > 0 )
		{
		var mark1 = self.name.indexOf("=");
		var mark2 = self.name.indexOf("&");
		var menuItemName = self.name.substr(0, mark1);
	    menu[0][menuItemName] = self.name.substring(mark1 + 1, mark2);
	    self.name = self.name.substr(mark2 + 1, self.name.length);
		}
	}

function InitializeMenu()
	{
	for(menuItemName in menu[0])
		{
    	if(menu[0][menuItemName] == "0")
			{
			document.getElementById(menuItemName+"_Submenu").style.visibility = "hidden";
			document.getElementById(menuItemName+"_Submenu").style.display = "none";
			document.getElementById(menuItemName+"_Lights").style.visibility = "visible";
			document.getElementById(menuItemName+"_Extend").style.backgroundImage = "url(" + IMAGES + "/global/general/plus.gif)";
			}
	    else
			{
			document.getElementById(menuItemName+"_Submenu").style.visibility = "visible";
			document.getElementById(menuItemName+"_Submenu").style.display = "block";
			document.getElementById(menuItemName+"_Lights").style.visibility = "hidden";
			document.getElementById(menuItemName+"_Extend").style.backgroundImage = "url(" + IMAGES + "/global/general/minus.gif)";
		    }
		}
	}

function SaveMenuArray()
	{
	var stringSlices = "";
	var temp = "";
	for(menuItemName in menu[0])
		{
		stringSlices = menuItemName + "=" + menu[0][menuItemName] + "&";
	    temp = temp + stringSlices;
		}
	self.name = temp;
	}

function MenuItemAction(sourceId)

{

  if(menu[0][sourceId] == 1) {

    CloseMenuItem(sourceId);

  }

  else {

    OpenMenuItem(sourceId);

  }

}

function OpenMenuItem(sourceId)

{

  menu[0][sourceId] = 1;

  document.getElementById(sourceId+"_Submenu").style.visibility = "visible";

  document.getElementById(sourceId+"_Submenu").style.display = "block";

  document.getElementById(sourceId+"_Lights").style.visibility = "hidden";

  document.getElementById(sourceId+"_Extend").style.backgroundImage = "url(" + IMAGES + "/global/general/minus.gif)";

}

function CloseMenuItem(sourceId)

{

  menu[0][sourceId] = 0;

  document.getElementById(sourceId+"_Submenu").style.visibility = "hidden";

  document.getElementById(sourceId+"_Submenu").style.display = "none";

  document.getElementById(sourceId+"_Lights").style.visibility = "visible";

  document.getElementById(sourceId+"_Extend").style.backgroundImage = "url(" + IMAGES + "/global/general/plus.gif)";

}





function MouseOverMenuItem(source)

{

  source.firstChild.style.visibility = "visible";

}

function MouseOutMenuItem(source)

{

  source.firstChild.style.visibility = "hidden";

}

function MouseOverSubmenuItem(source)

{

  source.style.backgroundColor = "#14433F";

}

function MouseOutSubmenuItem(source)



{

  source.style.backgroundColor = "#0D2E2B";

}







// ###################################### CONTADOR ######################################

var eventdate = new Date('September 5, 2008 00:00:01');

function toSt(n)

{

s=''

if(n<10) s+='0'

return s+n.toString();

}

function countdown()

{

d=new Date();

count=Math.floor((eventdate.getTime()-d.getTime())/1000);

if(count<=0)

{

var time_event = document.getElementById('time_event');

var event_time = document.getElementById('event_time');

time_event.style.display = 'none';

event_time.style.display = '';

return;

}

secs_count = toSt(count%60);

count=Math.floor(count/60);

mins_count = toSt(count%60);

count=Math.floor(count/60);

hours_count = toSt(count%24);

count=Math.floor(count/24);

days_count = count;

document.countdown.days.value = days_count;

document.countdown.hours.value = hours_count;

document.countdown.mins.value = mins_count;

document.countdown.secs.value = secs_count;

window.setTimeout('countdown()',500);



}



function mostra(d) {

b = document.getElementById(d);

var c;

if (b.style.display == 'block')

c = 'none';

else c='block';

b.style.display = c;





var today = new Date();

today.setTime( today.getTime() );



var expires = 10000 * 1000 * 60 * 60 * 24;



var expires_date = new Date( today.getTime() + (expires) );



document.cookie = 'quee' + "=" +escape(c) +

( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" );

}



function MM_openBrWindow(theURL,winName,features) { //v2.0

  window.open(theURL,winName,features);

}





// ###################################### BANNER ######################################

function MM_preloadImages() {

 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}



function getObj(objID) {

    if(document.getElementById){

        return document.getElementById(objID);

    } else if (document.all){

        return document.all[objID];

    } else if (document.layers){

        return document.layers[objID];

    }

}



function featuretteObj(name,cards,delay)
	{
	this.name = name;
	this.cards = cards;
	this.viewed = 0;
	this.delay = delay;
	this.current = "x";
	this.active = 0;
	this.x = "";
	this.y = "";
	this.amountSlid = 0;
	this.running = false;
	this.hover = false;
	this.count = cards.length;
	this.buttons = new Array();
	this.init = function()
		{
		this.name = this.name;
		this.viewed = 0;
		this.x = getObj("cardX");
		this.y = getObj("cardY");
		this.current = "x";
		this.active = 0;
		for(var i = 0;i <= (this.count-1);i++)
			{
			this.buttons[i] = getObj("feb"+i);
			}
		this.loadCard("y",this.determineNext());
		autoslide = setInterval(this.name+".next()",(this.delay*2));
		}
	this.jump = function(key)
		{
		try { clearInterval(autoslide); }catch(err){}
		if(this.running == false)
			{
			this.x = getObj("cardX");
			this.y = getObj("cardY");
			this.running = true;
			this.preset();
			if(this.current == "x") { var slot = "y"; } else { var slot = "x"; }
			if(key >= 0 && key <= (this.count-1)) { var place = key } else { var place = 0}
			this.loadCard(slot,place);
			this.active = place;
			if(this.current == "x") { this.y.style.display = ""; } else { this.x.style.display = ""; }
			slider = setInterval(this.name+".slide()",50);
			}
		}
	this.preset = function()
		{
		if(this.current == "x")
			{
			this.x.style.top = "0px";
			this.x.style.zIndex = 5;
			this.y.style.top = "-239px";
			this.y.style.zIndex = 6;
			}
		else
			{
			this.y.style.top = "0px";
			this.y.style.zIndex = 5;
			this.x.style.top = "-239px";
			this.x.style.zIndex = 6;
			}
		this.amountSlid = 0;
		}
	this.determineNext = function()
		{
		var projectedNext = (this.active+1)
		if (projectedNext > (this.count-1))
			{
			projectedNext = 0;
			}
			return projectedNext
		}
	this.next = function()
		{
		if(this.hover == false && this.running == false)
			{
			clearInterval(autoslide);
			this.running = true;
			this.preset();
			this.active = this.determineNext();
			if(this.current == "x") { this.y.style.display = ""; } else { this.x.style.display = ""; }
			slider = setInterval(this.name+".slide()",50);
			}
		}



	this.loadCard = function(slot,place) {

		if (slot == "y") { var destination = this.y; } else { var destination = this.x; }



		destination.innerHTML = '<p><a href="'+this.cards[place][2]+'" class="titulobanner">'+this.cards[place][1]+'</a><br /><span class=conteudobanner>'+this.cards[place][3]+'</span></p>';

		destination.onclick = function () { window.location=feats.cards[place][2]; }



		if(this.cards[place][6] == true) {

			destination.style.backgroundImage = 'url(img/banner/'+this.cards[place][0]+'.jpg)';

		}

	}



	this.pause = function(state) {

		this.hover = state;

	}



	this.slide = function() {

		if(this.running == true) {

			if(this.amountSlid < (239-47)) {

			this.amountSlid = (this.amountSlid + 47);

				if(this.current == "x") {

					this.y.style.top = '-'+(239 - this.amountSlid)+'px';

				}

				else {

					this.x.style.top = '-'+(239 - this.amountSlid)+'px';

				}

			}

			else {



				clearInterval(slider);

				this.amountSlid = 0;

				if(this.current == "x") {

					this.current = "y";

					this.x.style.display = "none";

					this.preset();

					this.loadCard("x",this.determineNext());

				}

				else {

					this.current = "x";

					this.y.style.display = "none";

					this.preset();

					this.loadCard("y",this.determineNext());

				}

				for(var i = 0;i <= (this.count-1);i++){

					if(this.active == i) {

						this.buttons[i].setAttribute("class", "current");

						this.buttons[i].setAttribute("className", "current");

					}

					else {

						this.buttons[i].setAttribute("class", "");

						this.buttons[i].setAttribute("className", "");

					}

				}

				this.running = false;

				autoslide = setInterval(this.name+".next()",this.delay);

			}

		}

	}

}

function ccbox(name)
	{
	this.name = name;
	this.originalCaption = "";
	this.originalWidth = 0;
	this.originalHeight = 0;
	this.originalImage = "";
	this.originalPath = "";
	this.currentWidth = 0;
	this.currentHeight = 0;
	this.loadingImage = null;
	this.fullPath = "";
	this.adcontent = "";
	this.init = function()
		{
		this.originalCaption = "";
		this.originalPath = "";
		this.originalWidth = 0;
		this.originalHeight = 0;
		}
	this.imageSize = function(url)
		{
		var myImage = new Image();
		myImage.src = url;
		var dimensions = [myImage.width,myImage.height];
		return dimensions;
		}
	this.windowSize = function()
		{
		var dimensions = [0,0];
		if( typeof( window.innerWidth ) == 'number' ) { 

			dimensions[0] = window.innerWidth;

			dimensions[1] = window.innerHeight;

		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { 

			dimensions[0] = document.documentElement.clientWidth;

			dimensions[1] = document.documentElement.clientHeight;

		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { 

			dimensions[0] = document.body.clientWidth;

			dimensions[1] = document.body.clientHeight;

		}

		return dimensions;
		}



	this.start = function(url) {

		var debug = false;

		var width = 0;

		var height = 0;

		var image = "";

		var caption = "";

		var path = "";

		var medium = false;

		var type = "feature";

		var id = 0;

		var cb = "";

		var show = "";

		var a = 1;

		var proceed = false;



		try {



			var existing = getObj('ccbox');

			if (existing != null) { window.document.body.removeChild(existing);}



			if(url.indexOf("|") != -1) {



				var arguments = (new String(url)).split('|');

				for (i in arguments) {

					var keys = arguments[i].split('=');

					if(keys[0] == "width") { width = parseInt(keys[1]); this.originalWidth = width; }

					else if(keys[0] == "height") { height = parseInt(keys[1]); this.originalHeight = height;}

					else if(keys[0] == "image") { image = keys[1]; this.originalImage = image; }

					else if(keys[0] == "path") { path = keys[1]; this.originalPath = path; }

					else if(keys[0] == "type") { type = keys[1]; }

					else if(keys[0] == "cb") { cb = "?"+keys[1]; }

					else if(keys[0] == "show") { show = keys[1]; }

					else if(keys[0] == "a") { a = keys[1]; }

					else if(keys[0] == "id") { id = keys[1]; }

					else if(keys[0] == "caption") {

						caption = keys[1];

						caption = this.replaceAll(caption,"%20"," ");

						this.originalCaption = caption+"<br>";

					}
				}
			}
			else {
				var arguments = ((new String(url)).split('?'))[1].split('&');
				for (i in arguments) {
					var keys = arguments[i].split('=');
					if(keys[0] == "width") { width = parseInt(keys[1]); this.originalWidth = width; }
					else if(keys[0] == "height") { height = parseInt(keys[1]); this.originalHeight = height;}
					else if(keys[0] == "image") { image = keys[1]; this.originalImage = image; }
					else if(keys[0] == "path") { path = keys[1]; this.originalPath = path; }
					else if(keys[0] == "type") { type = keys[1]; }
					else if(keys[0] == "cb") { cb = "?"+keys[1]; }
					else if(keys[0] == "show") { show = keys[1]; }
					else if(keys[0] == "a") { a = keys[1]; }
					else if(keys[0] == "id") { id = keys[1]; }
					else if(keys[0] = "caption") {
						caption = keys[1];
						caption = this.replaceAll(caption,"%20"," ");
						this.originalCaption = caption+"<br>";
					}
				}
			}

			var urchinurl = "";
			this.loadingImage = new Image();
			this.loadingImage.src = realurl;
			if(width == 0 || height == 0) {
				width = this.loadingImage.width;
				height = this.loadingImage.height;
			}



			if(image == "" || width==0 || height==0 ) { return true; }



			this.fullPath = realurl;

			try{
				urchinTracker('zoombox/image/'+urchinurl);
			} catch(err){

			}
			var viewport = this.windowSize();
			var scrollport = this.pageSize();
			var xpos = ((viewport[0]/2)-(width/2)-22)+scrollport[0]
			var ypos = ((viewport[1]/2)-(height/2)-20)+scrollport[1]
			if(ypos < 10) { ypos = 10; }
			if(xpos < 10) { xpos = 10; }
			var ccBox = document.createElement('div');
			ccBox.setAttribute('id','ccbox');
			if(width+22 < 770)
				{
				ccBox.style.width = '780px';
			}else {

				ccBox.style.width = (width+22)+'px';

			}

			ccBox.style.height = height+'px';

			ccBox.style.position = 'absolute';

			ccBox.style.left = xpos+'px';

			ccBox.style.top = ypos+'px';

			ccBox.style.display = 'block';

			ccBox.style.color = '#FFF';

			ccBox.style.zIndex = '9999';



			if(show != "single"){ var actions = ''; } else { var actions = '&nbsp;'; }
			window.document.body.appendChild(ccBox)
			this.currentWidth = width;
			this.currentHeight = height;
			if(a != 0)
				{
				this.adcontent = "";
				var adframe = getObj('ccBoxAd');
				adiframe = document.createElement('iframe')
				adiframe.src = "/inc_ad_frame.cfm?hidedump=true"
				adiframe.setAttribute('frameborder','0');
				adiframe.setAttribute('id','adiframe');
				adiframe.frameBorder = 0;
				adframe.appendChild(adiframe)
			}

			ccBoxTimer = setInterval("zoombox.check()", 100);

			return false;

		} catch(e) {



		}

		return false;

	}



	this.adCallback = function(result){

		var existing = getObj('ccbox');

		if (existing != null) {
			getObj('ccBoxAd').innerHTML = result;
		}
	}

	this.check = function() {
		try {
			if(this.loadingImage.complete) {

				this.loadingImage = null;

				clearInterval(ccBoxTimer);

				getObj('ccBoxWaiting').style.display = 'none';
			}
		} catch(e) {}
	}

	this.update = function() {
		var ccBox = getObj('ccbox');
		if (ccBox != null) {
			var viewport = zoombox.windowSize();
			var scrollport = zoombox.pageSize();
			var xpos = ((viewport[0]/2)-(zoombox.originalWidth/2)-22)+scrollport[0];
			var ypos = ((viewport[1]/2)-(zoombox.originalHeight/2)-20)+scrollport[1];
			if(ypos < 10) { ypos = 10; }
			if(xpos < 10) { xpos = 10; }
			if(zoombox.originalWidth > (viewport[0]-40) && (viewport[0]-40) > 750 ) {
				var newWidth = viewport[0]-60;
				var height = (zoombox.originalHeight * (newWidth / zoombox.originalWidth));
				var width = newWidth;
				var percentageWidth = parseInt((newWidth / zoombox.originalWidth)*100);
				getObj('ccBoxCaption').innerHTML = zoombox.originalCaption +"";
			}
			else {
				var width = zoombox.originalWidth;
				var height = zoombox.originalHeight;

				if(zoombox.currentWidth != zoombox.originalWidth) {
					getObj('ccBoxCaption').innerHTML = zoombox.originalCaption;
				}
			}

			ccBox.style.left = xpos+'px';
			ccBox.style.top = ypos+'px';
			ccBox.childNodes[1].style.backgroundImage = 'url(none)';
			if(zoombox.currentWidth != width && width > 700) {
				ccBox.style.width = (width+22)+'px';
				ccBox.style.height = height+'px';
				var ccBoxImage = getObj('ccBoxImage');
				if (ccBoxImage != null) {
					ccBoxImage.width = width;
					ccBoxImage.height = height;
				}
			}

			zoombox.currentWidth = width;
			zoombox.currentHeight = height;
		}
	}

	this.zoomin = function()
		{}
	this.getname = function()
		{
		return this.name;
		}
	}

zoombox = new ccbox('zoombox');

function checkForZoom()
	{
	if (!document.getElementsByTagName){ return; }
	var anchors = document.getElementsByTagName('a');
	for (var i=0; i<anchors.length; i++)
		{
		var anchor = anchors[i];
		if (anchor.getAttribute('href') && String(anchor.getAttribute('rel')) == 'zoom')
			{
			anchor.onclick = function() {zoombox.start(this); return false;}
			}
		}
	}

featuretteCards=new Array();
	featuretteCards[4] = new Array(5,"","index.php?sporando=sobre_spore","",31,20080526,true);
	featuretteCards[3] = new Array(4,"","index.php?sporando=sobre_jogo","",31,20080527,true);
	featuretteCards[2] = new Array(3,"","http://www.sporando.com/feed.xml","",31,20080528,true);
	featuretteCards[1] = new Array(2,"","http://www.sporando.com/forum/","",163,20080529,true);
	featuretteCards[0] = new Array(1,"","http://wwww.sporando.com/promocao/","",2,20080530,true);
feats = new featuretteObj("feats",featuretteCards,6000);

//#################################### Inserir Noticias ##################################

function visualizar()
	{
	document.cadastro_noticias.action="?sporando=verifica_noticia";
	document.forms.cadastro_noticias.submit();
	}

function cadastrar()
	{
	document.cadastro_noticias.action="?sporando=inserir_noticias_upload";
	document.forms.cadastro_noticias.submit();
	}

function editar()
	{
	document.edicao_noticias.action="?sporando=editar_noticias_upload";
	document.forms.edicao_noticias.submit();
	}

function visualizar_edicao()
	{
	document.edicao_noticias.action="?sporando=verifica_edicao_noticia";
	document.forms.edicao_noticias.submit();
	}

//#################################### Inserir Vídeos ##################################

function visualizar_video()
	{
	document.cadastro_videos.action="?sporando=verifica_video";
	document.forms.cadastro_videos.submit();
	}

function cadastrar_video()
	{
	document.cadastro_videos.action="?sporando=inserir_videos_upload";
	document.forms.cadastro_videos.submit();
	}
	
function visualizar_link_video()
	{
	document.cadastro_links_videos2.action="?sporando=verifica_link_video";
	document.forms.cadastro_links_videos2.submit();
	}

function cadastrar_link_video()
	{
	document.cadastro_links_videos2.action="?sporando=inserir_videos_link_upload";
	document.forms.cadastro_links_videos2.submit();
	}
	
//#################################### Inserir FAQ ##################################

function visualizar_faq()
	{
	document.cadastro_faq.action="?sporando=verifica_faq";
	document.forms.cadastro_faq.submit();
	}

function cadastrar_faq()
	{
	document.cadastro_faq.action="?sporando=inserir_faq_upload";
	document.forms.cadastro_faq.submit();
	}

function editar_faq()
	{
	document.edicao_faq.action="?sporando=editar_faq_upload";
	document.forms.edicao_faq.submit();
	}

function visualizar_edicao_faq()
	{
	document.edicao_faq.action="?sporando=verifica_edicao_faq";
	document.forms.edicao_faq.submit();
	}
	
//#################################### Inserir Cheats ##################################

function visualizar_cheats()
	{
	document.cadastro_cheats.action="?sporando=verifica_cheats";
	document.forms.cadastro_cheats.submit();
	}

function cadastrar_cheats()
	{
	document.cadastro_cheats.action="?sporando=inserir_cheats_upload";
	document.forms.cadastro_cheats.submit();
	}

function editar_cheats()
	{
	document.edicao_cheats.action="?sporando=editar_cheats_upload";
	document.forms.edicao_cheats.submit();
	}

function visualizar_edicao_cheats()
	{
	document.edicao_cheats.action="?sporando=verifica_edicao_cheats";
	document.forms.edicao_cheats.submit();
	}