// GoNintendo JavaScript Document

	function showHide(id, display)
	{
		thediv = $("#"+id)[0];
		
		// Opera check for Topstories
		if(id == "topstorydropdown" && window.opera) {
			$("#topstorydropdown")[0].style.marginTop = "0px";
		}

		if (display === undefined || display == null)
		{
			if (thediv.style.display == 'none')
				thediv.style.display = 'block';
			else
				thediv.style.display = 'none';
		}
		else
			thediv.style.display = display;
	}
	
	function hideAll(id)
	{
		// Hide all but id
		/*
		if (id != 'podcastbox')
			$('#podcastbox')[0].style.display = 'none';
		if (id != 'communitybox')
			$('#communitybox')[0].style.display = 'none';
		if (id != 'contactbox')
			$('#contactbox')[0].style.display = 'none';
		*/
		if (id != 'topstorydropdown' && $('#topstorydropdown')[0] != null)
			$('#topstorydropdown')[0].style.display = 'none';
	}
	
	function commentReply(user, id)
	{
		if (id === undefined)
			$("#comment")[0].value = $("#comment")[0].value + '[re]@'+user+'[/re] \n\n';
		else
			$("#comment")[0].value = $("#comment")[0].value + '[fre id='+id+']'+user+'[/fre] \n\n';
			
		var t=$("#comment")[0];
		len=t.value.length;
		if(t.setSelectionRange){
			t.setSelectionRange(len,len)
			t.focus()
		}else if(t.createTextRange){
			var rn=t.createTextRange();
			rn.moveStart('character',len)
			rn.select()
		}
		
	}
	
	function swapStoryList(t, id)
	{
		$("#story_list_title")[0].innerHTML = t;
		$("#storylist0")[0].style.display = 'none';
		$("#storylist1")[0].style.display = 'none';
		$("#storylist2")[0].style.display = 'none';
		$("#storylist3")[0].style.display = 'none';
		$("#storylist4")[0].style.display = 'none';
		
		$("#storylist"+id)[0].style.display = 'block';
	}
	
/* NOTE: the following code was extracted from the UFO source and extensively reworked/simplified 
		Unobtrusive Flash Objects (UFO) v3.20 <http://www.bobbyvandersluis.com/ufo/>
        Copyright 2005, 2006 Bobby van der Sluis
        This software is licensed under the CC-GNU LGPL <http://creativecommons.org/licenses/LGPL/2.1/>
*/

function createCSS(selector, declaration) {
        // test for IE
        var ua = navigator.userAgent.toLowerCase();
        var isIE = (/msie/.test(ua)) && !(/opera/.test(ua)) && (/win/.test(ua));

        // create the style node for all browsers
        var style_node = document.createElement("style");
        style_node.setAttribute("type", "text/css");
        style_node.setAttribute("media", "screen");

        // append a rule for good browsers
        if (!isIE) style_node.appendChild(document.createTextNode(selector + " {" + declaration + "}"));

        // append the style node
        document.getElementsByTagName("head")[0].appendChild(style_node);

        // use alternative methods for IE
        if (isIE && document.styleSheets && document.styleSheets.length > 0) {
                var last_style_node = document.styleSheets[document.styleSheets.length - 1];
                if (typeof(last_style_node.addRule) == "object") last_style_node.addRule(selector, declaration);
        }
}

function fadeDiv(id)
	{
		$("#"+id).fadeOut('slow');
	}
	
function fadeInDiv(id)
	{
		$("#"+id).fadeOut('slow');
	}

if ( window.addEventListener ) {
  var state = 0, konami = [38,38,40,40,37,39,37,39,66,65];
  window.addEventListener("keydown", function(e) {
    if ( e.keyCode == konami[state] ) state++;
    else state = 0;
    if ( state == 10 )
      window.location = "http://www.google.com";
  }, true);
}

