// JavaScript Document

RibbonStack = new Array;
F = new Array;
MenuSectionText = new Array;
MenuChoiceText = new Array;
MenuLinks = new Array;
MenuWidth = new Array;
ThisMenuLinks = new Array;
var ThisSectionNumber = 0;
var I = 0;

MenuSectionText[I] = "home";
MenuChoiceText[I] = "";
MenuLinks[I] = "..";
MenuWidth[I] = "";
I++;

MenuSectionText[I] = "news";
MenuChoiceText[I] = "";
MenuLinks[I] = "news/index.html";
MenuWidth[I] = "";
I++;

MenuSectionText[I] = "about";
MenuChoiceText[I] = "about;faqs;qafs;how to;articles";
MenuLinks[I] = "about/index.html;about/faq.html;about/qaf.html;about/howto.html;about/articles.html";
MenuWidth[I] = "370";
I++;

MenuSectionText[I] = "books";
MenuChoiceText[I] = "books";
MenuLinks[I] = "books/index.html";
MenuWidth[I] = "";
I++;

MenuSectionText[I] = "events";
MenuChoiceText[I] = "events";
MenuLinks[I] = "events/index.html";
MenuWidth[I] = "";
I++;

MenuSectionText[I] = "gallery";
MenuChoiceText[I] = "gallery";
MenuLinks[I] = "gallery/index.html";
MenuWidth[I] = "";
I++;

MenuSectionText[I] = "message board";
MenuChoiceText[I] = "message board";
MenuLinks[I] = "message/index.html";
MenuWidth[I] = "";
I++;


var dirs=window.location.href.split('/');


function CreatePageHeading(ThisSection,ThisChoice) {
// Randomise the image ribbon	
var J = 0;
var IND = 0;
X = new Array();
if  (F.length < 1)
    {J = 15;}
while (J < 15)
      {IND = Math.floor(Math.random()*F.length);
	   if  (X[IND] != "1")
		   {RibbonStack[J] = F[IND];
			J++;
			X[IND] = "1";}}
			

// Outermost area that contains all other content ... sets the width (810 for content plus 2 for border)
document.write('<div class="X3AOutermostDiv">');	

// Ribbon area for small book covers ... 15 books at 54 pixels each equals total width of 810 pixels
document.write('<div class="X3ARibbonArea">');
for (var i = 0; i < 15; i++)
    {document.write('<img src="/v3controls/ribbonimages/covers/' + RibbonStack[i] + '.jpg" width="54" height="81" style="border-bottom:1px solid #999999;">');}
document.write('</div>');

// Menu Area
document.write('<div class="X3AMenuArea">');
for (var i = 0; i < MenuSectionText.length; i++)
    {if  (i > 0) {document.write('<img src="/v3controls/menuspacer.jpg" style="margin:0px 7px 0px 7px;">');}
	ThisMenuLinks = MenuLinks[i].split(';');
	if   (ThisSection == MenuSectionText[i])
	     {ThisSectionNumber = i;
		  document.write('<a class="X3AMenuLinkThis" href="/v3site/' + ThisMenuLinks[0] + '">'+ MenuSectionText[i] + '</a>');}
	else {document.write('<a class="X3AMenuLink" href="/v3site/' + ThisMenuLinks[0] + '">'+ MenuSectionText[i] + '</a>');}
	}
document.write('</div>');

// Sub Menu Area
ThisMenuLinks = MenuLinks[ThisSectionNumber].split(';');
ThisMenuChoiceText = MenuChoiceText[ThisSectionNumber].split(';');
if  (ThisMenuLinks.length > 1)
    {document.write('<div class="X3ASubMenuArea" style="width:' + MenuWidth[ThisSectionNumber] + 'px;">');
     for (var i = 0; i < ThisMenuLinks.length; i++)
         {if  (i > 0) {document.write('<img src="/v3controls/submenuspacer.jpg" style="margin:0px 7px 0px 7px;">');}
          if   (ThisChoice == ThisMenuChoiceText[i])
          	   {document.write('<a class="X3ASubMenuLinkThis" href="/v3site/' + ThisMenuLinks[i] + '">'+ ThisMenuChoiceText[i] + '</a>');}
          else {document.write('<a class="X3ASubMenuLink" href="/v3site/' + ThisMenuLinks[i] + '">'+ ThisMenuChoiceText[i] + '</a>');}
 	     }
    document.write('</div>');}
 
// End of function ... note that X3AContentArea and X3AOutermostDiv are still open
}

function RuneCastStart() {
     document.write('<div style="width:200px;margin:0px 0px 0px 0px;background-color:#000000;padding:10px 5px 2px 5px;" id="runeplace" onClick="Recast();">');	
     document.write('<div style="height:110px;"></div>')
     document.write('<p style="font-size:12px;color:#FFFFFF;">&nbsp;</p><p style="font-size:12px;color:#808000;">... casting ...</p>');
     document.write('</div>');
	 Recast(5);
	 }



function CreatePageFooter() {
// First we close off X3AContentArea and X3AOutermostDiv 
document.write('</div>');	
document.write('</div>');	
// TO BE REVISED
// Level 5 is simply a page footer 
document.write('<div class="ST-Level5Div"></div>');	
// This is just a filler to ensure the page exceeds the height of the screen, forcing a right side scroll bar on every page
document.write('<div style="height:200px;">&nbsp;</div>');	
}

function RuneCast(counter) {
CAST = new Array();	
RUNE = new Array();	
N=new Array;
R=new Array;
U=new Array;
R[0] = 'Fehu'; N[0] = '01';
R[1] = 'Uruz'; N[1] = '02';
R[2] = 'Thorn'; N[2] = '03';
R[3] = 'Os'; N[3] = '04';
R[4] = 'Rad'; N[4] = '05';
R[5] = 'Ken'; N[5] = '06';
R[6] = 'Gyfu'; N[6] = '07';
R[7] = 'Wyn'; N[7] = '08';
R[8] = 'Hagall'; N[8] = '09';
R[9] = 'Nyd'; N[9] = '10';
R[10] = 'Ice'; N[10] = '11';
R[11] = 'Ger'; N[11] = '12';
R[12] = 'Ehwaz'; N[12] = '13';
R[13] = 'Eoh'; N[13] = '14';
R[14] = 'Peord'; N[14] = '15';
R[15] = 'Sigel'; N[15] = '16';
R[16] = 'Tyr'; N[16] = '17';
R[17] = 'Beorc'; N[17] = '18';
R[18] = 'Eh'; N[18] = '19';
R[19] = 'Man'; N[19] = '20';
R[20] = 'Laguz'; N[20] = '21';
R[21] = 'Ing'; N[21] = '22';
R[22] = 'Daeg'; N[22] = '23';
R[23] = 'Ethel'; N[23] = '24';
var K = 0;
while (K < counter)
      {J = Math.ceil(24*Math.random()) -1;
	   if  (U[J] != 1)
	       {CAST[K] = '<img src="../runemarks/runemarks_runes/runemarks_runes_' + N[J] + '_' + R[J] + 'X.jpg" alt="' + R[J] + '" title="' + R[J] + '">';
	        RUNE[K] = R[J];
			K++;
			U[J]=1;}}
return CAST;			
}

function Recast() {
var X = RuneCast(5);
document.getElementById('runeplace').innerHTML = '<div style="height:110px;"></div><p style="font-size:12px;color:#FFFFFF;">&nbsp;</p><p style="font-size:12px;color:#FFFF00;">... casting ...</p>';
setTimeout("ReCastShow(0);",800);
setTimeout("ReCastShow(1);",1600);
setTimeout("ReCastShow(2);",2400);
setTimeout("ReCastShow(3);",3200);
setTimeout("ReCastShow(4);",4000);
}

function ReCastShow(K) {
if (K == 0) {document.getElementById('runeplace').innerHTML = '<div style="height:110px;">' + CAST[0] + '</div><p style="font-size:12px;color:#FFFFFF;">' + RUNE[0] + '</p><p style="font-size:12px;color:#FFFF00;">... casting ...</p>'}
if (K == 1) {document.getElementById('runeplace').innerHTML = '<div style="height:110px;">' + CAST[0]+CAST[1] + '</div><p style="font-size:12px;color:#FFFFFF;">' + RUNE[0] + ', ' + RUNE[1] + '</p><p style="font-size:12px;color:#FFFF00;">... casting ...</p>'}
if (K == 2) {document.getElementById('runeplace').innerHTML = '<div style="height:110px;">' + CAST[0]+CAST[1]+CAST[2] + '</div><p style="font-size:12px;color:#FFFFFF;">' + RUNE[0] + ', ' + RUNE[1] + ', ' + RUNE[2] + '</p><p style="font-size:12px;color:#FFFF00;">... casting ...</p>'}
if (K == 3) {document.getElementById('runeplace').innerHTML = '<div style="height:110px;">' + CAST[0]+CAST[1]+CAST[2]+CAST[3] + '</div><p style="font-size:12px;color:#FFFFFF;">' + RUNE[0] + ', ' + RUNE[1] + ', ' + RUNE[2] + ', ' + RUNE[3] + '</p><p style="font-size:12px;color:#FFFF00;">... casting ...</p>'}
if (K == 4) {document.getElementById('runeplace').innerHTML = '<div style="height:110px;">' + CAST[0]+CAST[1]+CAST[2]+CAST[3]+CAST[4] + '</div><p style="font-size:12px;color:#FFFFFF;">' + RUNE[0] + ', ' + RUNE[1] + ', ' + RUNE[2] + ', ' + RUNE[3] + ', ' + RUNE[4] + '</p><p style="font-size:12px;color:#FFFF00;">click to recast the runes</p>'}
}

function DTG(y,m0,d) {
Today = new Date();
Target = new Date(y, m0, d);
Diff = Math.abs(Target.getTime() - Today.getTime());
Days = Math.ceil(Diff/(1000*60*60*24));
document.write ('<p style="font-family:Verdana, Arial, Helvetica, sans-serif;margin:10px auto 10px auto;border:2px solid #800080;font-size:26px;text-align:center;width:140px;padding:10px;"><i>Runelight</i><br><span style="font-size:80px;font-weight:bold;color:#800000;">');
document.write (Days);
if  (Days == 1) {DD = "Day";} else {DD = "Days";}
document.write ('</span><br><span style="font-size:20px;">' + DD + ' To Go!</span></p>');
}

function DTG1(y,m0,d) {
Today = new Date();
Target = new Date(y, m0, d);
Diff = Math.abs(Target.getTime() - Today.getTime());
Days = Math.ceil(Diff/(1000*60*60*24));
document.write ('<div style="font-family:Verdana, Arial, Helvetica, sans-serif;margin:0px 0px 0px auto;border:2px solid #800080;text-align:center;width:120px;padding:5px;">');
document.write ('<p style="font-size:20px;padding:0px;margin:8px auto 0px auto;"><i>Runelight</i>');
document.write ('<p style="font-size:80px;font-weight:bold;color:#800000;padding:0px;margin:2px auto 6px auto;">');
document.write (Days);
if  (Days == 1) {DD = "Day";} else {DD = "Days";}
document.write ('</p>');
document.write ('<p style="font-size:16px;color:#000000;font-weight:normal;padding:0px;margin:0px auto 5px auto;">' + DD + ' To Go!</p>');
document.write ('</div>');
}

function DTG2(y,m0,d) {
Today = new Date();
Target = new Date(y, m0, d);
Diff = Math.abs(Target.getTime() - Today.getTime());
Days = Math.ceil(Diff/(1000*60*60*24));
document.write ('<b>' + Days);
if  (Days == 1) {DD = " day to go!";} else {DD = " days to go!";}
document.write (DD + '</b>');
}

function DTG3(y,m0,d) {
Today = new Date();
Target = new Date(y, m0, d);
Diff = Math.abs(Target.getTime() - Today.getTime());
Days = Math.ceil(Diff/(1000*60*60*24));
document.write ('<div style="font-family:Verdana, Arial, Helvetica, sans-serif;margin:0px 0px 0px 0px;border:2px solid #800080;text-align:center;width:100px;padding:5px;background-color:#EEEEEE;">');
document.write ('<p style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:18px;color:#000000;padding:0px;margin:5px auto 0px auto;"><i>Runelight</i>');
document.write ('<p style="font-size:56px;font-weight:bold;color:#800000;padding:0px;margin:1px auto 3px auto;">');
document.write (Days);
if  (Days == 1) {DD = "Day";} else {DD = "Days";}
document.write ('</p>');
document.write ('<p style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;color:#000000;font-weight:normal;padding:0px;margin:0px auto 3px auto;">' + DD + ' To Go!</p>');
document.write ('</div>');
}

function DTG4() {
document.write ('<div style="font-family:Verdana, Arial, Helvetica, sans-serif;margin:0px 0px 50px 0px;border:2px solid #800080;text-align:center;width:150px;padding:15px;background-color:#EEEEEE;">');
document.write ('<p style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:20px;color:#000000;padding:0px;margin:5px auto 0px auto;"><i>Runelight</i>');
document.write ('<p style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:20px;color:#800000;font-weight:normal;padding:0px;margin:20px auto 10px auto;">Published<br>Today!</p>');
document.write ('</div>');
}

	


