function showsub(id){
	
	if ( document.getElementById("menutab").style.display == 'none' ) {
		$('#menutab').fadeIn(150);
		$('#submenu').fadeIn(150);
	}
	
	$('#woopyland').hide(0);
	$('#members_area').hide(0);
	$('#community').hide(0);
	$('#home').hide(0);
	
	if ( document.getElementById(id).style.display == 'none' ) {
		$('#'+id).show(0);
	}
	
}

function clearTimer(){
	
	if (typeof(menutimer) != "undefined")
	{
		
		clearTimeout(menutimer);
		
	}
	
}

function changemenu(id){
	
	if ( id == 'none' )
	{
		
		menutimer = setTimeout(function(){
			$('#woopyland').hide(0);
			$('#members_area').hide(0);
			$('#community').hide(0);
			$('#home').hide(0);
			$('#menutab').fadeOut(150);
			$('#submenu').fadeOut(150);
		}, 200);
		
	}
	else
	{	
		
		if ( document.getElementById(id).style.display == 'none' )
		{
			
			$('#woopyland').hide(0);
			$('#members_area').hide(0);
			$('#community').hide(0);
			$('#home').hide(0);
			
			showsub(id);
			
		}
	
	}
	
}

function spoilerFunction(key){
	if ( document.getElementById(key).style.display == 'none' ) {
		$('#'+key).show();
		document.getElementById(key+'-button').value = 'Make it go away!';
	}
	else {
		$('#'+key).hide();
		document.getElementById(key+'-button').value = 'Can I see it again?';
	}
}

function showstep(step){
	$('#step'+step).fadeIn(800);
}

function switchpage(pageIn,pageOut){
	$('#page'+pageOut).fadeIn(800);
	$('#page'+pageIn).delay(1000).fadeIn(800);
}

function red()
{
	$j('.step' + step).removeClass('color_green');
	$j('.step' + step).addClass('color_red');
}

function green()
{
	$j('.step' + step).addClass('color_green');
	$j('.step' + step).removeClass('color_red');
}

function switchvisible(titlediv){
	article=titlediv.parentNode.getElementsByTagName('div')[1];
	if(article.style.display=='none')
	{
		article.style.display='block';
	}
	else
	{
		article.style.display='none';
	}
}

function changePicture(elementID,newSrc){
	if (document.getElementById(elementID).src != mewSrc)
	{
		$('#'+elementID).delay(800).fadeOut(800, function(){
			document.getElementById(elementID).src = newSrc;
		});
		$('#'+elementID).fadeIn(800);
	}
}

function updateWithFade(elementID,newHTML){
	document.getElementById(elementID).innerHTML = newHTML;
	$('#'+elementID).delay(100).fadeIn(800);
}

function openGame(game)
{
	//url.href='#';
	GameWindow=window.open("../play/game/" + game,"Game","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=580,height=470");
}

function updateGame()
{
	if(document.getElementById("update").checked)
	{
		document.getElementById("category").disabled=true;
		document.getElementById("condsort").disabled=true;
		document.getElementById("condition").disabled=true;
		document.getElementById("city").disabled=true;
		document.getElementById("available").disabled=true;
		document.getElementById("desc").disabled=true;
	}
	else
	{
		document.getElementById("category").disabled=false;
		document.getElementById("condsort").disabled=false;
		document.getElementById("condition").disabled=false;
		document.getElementById("city").disabled=false;
		document.getElementById("available").disabled=false;
		document.getElementById("desc").disabled=false;
	}
}

function arrayIndexOf(o,arr)
{
	for(i=0;i<arr.length;i++)
	{ alert(arr[i]);
		if(arr[i]==o) return i;
	}
	return 0;
}

function arrayIndexOfOptions(o,arr)
{
	for(i=0;i<arr.length;i++)
	{
		if(arr[i].text==o) return i;
	}
	return 0;
}
