// When using both prototype and jquery, you should use this...
jQuery.noConflict();
var $j = jQuery;


// js Document
// Javascript to be exact
// haiku header go

	var prevpg,nextpg,lastpage;
	var browser = navigator.appName;
	var url = window.location.pathname;	
	var is_classic = url.indexOf('classic');
	var loc = "/steam/";
	var indx = "/index.html";
	var classic_lp = 136;
	// testing the next/previous with arrowkeys
	lastpage = lastpg;
	//lastpage = 47;
	if (is_classic >= 0) {
		loc = "/classic/";
		lastpage = classic_lp;
	}
	prevpg = (parseInt((url).split('/')[2])-1);
	nextpg = (parseInt((url).split('/')[2])+1);
	if ((url == "/index.html" || url == "/") || (url == "/classic/index.html" || url == "/classic/")){
		prevpg = lastpage;
	}
	if (nextpg == lastpage+1){
		nextpg = -2; // This is awful but I'm expecting to change it
	}
	
	if (browser == "Microsoft Internet Explorer") {
		document.onkeydown=keydownie;
	} else {
		document.onkeydown=keydown;
	}
	
	function gohome() {
			window.location = '/';
			return false;
	}
	function goprev() {
			if(loc == "/"){loc = '/steam/';}
			window.location = loc + prevpg+indx;
			return false;
	}
	function gonext() {
		if(nextpg != -2){
			window.location = loc+nextpg+indx;}
		else{
			if(loc != '/classic/')
			{loc = "/";}
			window.location = loc;
		}
			return false;
	}
		
	function keydownie(e) {
		if (!e) var e = window.event;
		if (e.keyCode) {
			keycode = e.keyCode;
			if ((keycode == 39) || (keycode == 37)) {
				window.event.keyCode = 0;
			}
		} else {
			keycode = e.which;
		}
		if (keycode == 37 && prevpg > 0) {
			return goprev();
		} else if (keycode == 39 && (nextpg <= lastpage || nextpg == -2)){
			return gonext();
		}
	}
		
	function keydown(e) {
		if (e.which) {
			keycode = e.which;
		} else {
			keycode = e.keyCode;
		}
		if (keycode == 37 && prevpg > 0) {
			return goprev();
		} else if (keycode == 39 && (nextpg <= lastpage || nextpg == -2)){
			return gonext();
		}
	}


// Google Analytics

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-17814173-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


//Disqus code
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
    var disqus_shortname = 'notenoughbbq'; // required: replace example with your forum shortname

    /* * * DON'T EDIT BELOW THIS LINE * * */
    (function () {
        var s = document.createElement('script'); s.async = true;
        s.type = 'text/javascript';
        s.src = 'http://' + disqus_shortname + '.disqus.com/count.js';
        (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
    }());

//JQuery Fader code
$j ( function() { // $(document).ready() shorthand
  setTimeout(function(){
      $j ("div.ad1in").fadeIn(1000, function () {});
  }, 2500);
  setTimeout(function(){
      $j ("div.ad2in").fadeIn(1000, function () {});
  }, 3000);
  setTimeout(function(){
      $j ("div.dreamhostad").fadeIn(1000, function () {});
  }, 5000);
});
