var Rune = new Array();
var RSRuneCookieName = "RSRuneCookie";
var NewWindow = "";

Rune[0] = "units/01.html";
Rune[1] = "units/02.html";
Rune[2] = "units/03.html";
Rune[3] = "units/04.html";
Rune[4] = "units/05.html";
Rune[5] = "units/06.html";
Rune[6] = "units/07.html";
Rune[7] = "units/08.html";
Rune[8] = "units/09.html";
Rune[9] = "units/10.html";
Rune[10] = "units/11.html";
Rune[11] = "units/12.html";
Rune[12] = "units/13.html";
Rune[13] = "units/14.html";
Rune[14] = "units/15.html";
Rune[15] = "units/16.html";
Rune[16] = "units/17.html";
Rune[17] = "units/18.html";
Rune[18] = "units/19.html";
Rune[19] = "units/20.html";
Rune[20] = "units/21.html";
Rune[21] = "units/22.html";
Rune[22] = "units/23.html";
Rune[23] = "units/24.html";
Rune[24] = "units/25.html";

// Stop edit //

var TabChar = String.fromCharCode(9);
var CurrentCookie = '';
function GetRuneCookie() {
  var cookiecontent = '';
  if(document.cookie.length > 0) {
  	 var cookiename = RSRuneCookieName + '=';
  	 var cookiebegin = document.cookie.indexOf(cookiename);
  	 var cookieend = 0;
  	 if(cookiebegin > -1) {
     	cookiebegin  += cookiename.length;
     	cookieend = document.cookie.indexOf(";",cookiebegin);
     	if(cookieend < cookiebegin) { cookieend = document.cookie.length; }
     	cookiecontent = document.cookie.substring(cookiebegin,cookieend);
    }
  }
  return cookiecontent;
}

function PutRuneCookie(value) {
  if(CurrentCookie.length > 0) { value = CurrentCookie + TabChar + value; }
  value = escape(value);
  document.cookie = RSRuneCookieName + "=" + value;
}

function SamRead() { 
  CurrentCookie = GetRuneCookie();
  CurrentCookie = unescape(CurrentCookie);
  if(CurrentCookie == '.') { CurrentCookie = ''; }
  var RuneVisitedList = CurrentCookie.split(TabChar);
  if(RuneVisitedList.length >= Rune.length) {
   	document.cookie = RSRuneCookieName + "=.";
   	CurrentCookie = '';
   	RuneVisitedList = Array();
  }
  for(var i = 0; i < RuneVisitedList.length; i++) { Rune[RuneVisitedList[i]] = ''; }
  var RuneL = new Array();
  for(var i = 0; i < Rune.length; i++) {
   	if(Rune[i].length > 0) { RuneL.push('' + i + TabChar + Rune[i]); }
  }
  var RuneDestinationNumber = 0;
  if(RuneL.length > 1) { RuneDestinationNumber = Math.ceil((Math.random() * RuneL.length) - 1); }
  var RuneNumberPlace = new Array();
  RuneNumberPlace = RuneL[RuneDestinationNumber].split(TabChar);
  PutRuneCookie(RuneNumberPlace[0]);
  NewWindow = NewWindow.toLowerCase();
  if(NewWindow.substr(0,1) == "y") { window.open(RuneNumberPlace[1]); }
  else { document.location = RuneNumberPlace[1]; }
}
