<!--
//use this tag to hide from javascript-less browsers. however, variables within this are less accessible than they would be outside the tags.

//--------------------------standard pages:----------------------------

function checkframeset() {
//loads website main if page is orphaned from frameset (direct page links from search engines)
//this code is activated from inside the body of some pages.
 if (location.href.match("howlingriot.com") && !top.menu) {	//if menu frame is not present
 var page = location.href.slice( location.href.lastIndexOf("/")+1 );
 //gets "page.htm" behind the last slash in the url
 top.location.replace("http://www.howlingriot.com/" +"#"+ page);
 //loads main frameset and also passes the requested page as "#page.htm" in the url, so the menu code will load the requested page into the main frame.
 //using 'replace()' instead of top.location.href redirecting avoids annoying back button loops!
 }
}

function menulink(optionname) {
//Activates menuclick() in the main menu, which highlights a menu button.
//Can be activated by pages when they load. This function makes sure the menu link belonging with that page
//is highlighted when the menu frame has loaded. not before.
//Basically, it just passes the menuclick activation, but indirectly.
 if (parent.menu && parent.menu.menuclick) { parent.menu.menuclick(optionname); }	//checks if the menu has loaded.
 //If the menu has not loaded yet, keep checking until it has:
 else {setTimeout("menulink('" +optionname+ "')", 50);}			//repeats this function.
}

function flaglanguage(language) {
document.write('<img src="images/flag' +language+ '.gif" width="15" height="10" alt="' +language+ ' language">');
document.close();	//for firefox, to stop 'loading'.
}


//--------------------------shopping pages:----------------------------
var openingshopsystem = false;
function putitem(itemname, option, amount) {
//Indirectly activates the additem() function in the shop menu to add an item to the shopping basket.
//If this is the first order, it first loads the shop menu!
//This function makes sure the order is passed to the shop menu when the shop menu has loaded. not before.
if (parent.menu.additem) {
parent.menu.additem(itemname, option, amount);	//Activate directly!
openingshopsystem = false;			//reset
} else {
//If the menu has not loaded yet, keep checking until it has:
 if (openingshopsystem == false) {
 parent.menu.location.href = "shopsystem.htm";	//Should do only once! or browser will get stuck repeating this!
 openingshopsystem = true; 
 }
 setTimeout("putitem('" +itemname+ "', '" +option+ "', " +amount+ ")", 250);	//repeats this function.
 //Note that the text options passed through the settimeout have to be in quotation marks.
}
}

function itemstats(itemname) {
if (itemspecs && itemspecs[itemname]) {		//check if can find item prices in shopprices.js file
document.write( "Price: " +displaymoney(itemspecs[itemname][0]) );
document.close();
}
}


var currency = "&euro;";

function displaymoney(price, offset) {
//returns a money value with 2 decimals, as it should.
//'price' is the money value, possibly with decimal cents, e.g. 10.95 or 10.5, or 10
//'offset' is optional and can put extra spaces between the "$" and the price. value is 10, 100, 1000, etc.
//Split up the euro's and the cents:
var wholes= Math.floor(price);				//10.95 	 = 10 euros.
var cents = Math.round(100* price) - (100* wholes);	//(1095) -(1000) = 95 cents.
if (cents == 0) {cents = "00";}				//10.0 becomes 10.00
//as javascript has annoying round-off errors with decimal numbers, we turn it to integers above, by doing it x100.
var moneyastext = "<font style='font-family:Arial'>" +currency+ " </font>";	//"$" or euro sign.
if (offset) {for (tal=offset; tal > 1; tal /= 10) {
 if (wholes < tal) {moneyastext += "&nbsp;";}
}}	//adds extra spaces for the alignment of the decimal point and $ with other prices
moneyastext += wholes + ".";
if (cents < 10 && cents != 0) {moneyastext += "0"};		//e.g. 1.05 : notice the zero!
moneyastext += cents;

return moneyastext;
}


//--------------------------webcomic pages:----------------------------
//webcomic page functions are located in the webcomic.js file


//------------------------------image window:--------------------------
//OPTIONS:
var thumbnailwidth  	= 35;	//48/80? or 40/110
var thumbnailheight 	= 100;
var thumbnailbetween	= 5;
var thumbnailtransparent= 80;

var popupwidth = 300;		//or left 30, 275 x 486
var popupheight= 486;
var fullsize = true;		//'true' or 'false'; determines whether or not images
				//will be displayed at full size or 'browsing' width (smaller).

var gallerywindow = false;			//need this to refer to the window.
function displayimage(imagename) {
//Activated when clicking a thumbnail, or by the "next" or "previous" buttons in the display window.
//The links would work with normal hrefs too, but with window.open() you can leave out the menu bars etc.
//Opens display window (or replaces url):
if(
gallerywindow = window.open("gallerywindow.htm?" +imagename+ "", "gallerywindow", "width=" +popupwidth+ ",height=" +popupheight+ ",left=4,top=106,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1")
) {return true;} else {return false;}
//returns 'false' if window open failed, because of a pop-up block. If okay, returns 'true'.
}	//end of function displayimage().



//--------------------------team page:---------------------------
function calculateAge(Bday, Bmonth, Byear) {
//Bday, Bmonth and Byear form the date of birth of the member. e.g. calculateAge(2,5,1979);
if (Bday == 0 && Bmonth == 0 && Byear == 0) {memberage = "unknown";}	//if no birthday given
else {
 today = new Date();				//get today's date
 var memberage = today.getYear() - Byear;	//the difference in years.
 if (memberage < 0) {memberage += 1900;}	//correct any errors for browsers.
 //getYear returns "2005" for internet explorer, but "105" for firefox (years since 1900).

 if (today.getMonth()+1 < Bmonth || today.getMonth()+1 == Bmonth && today.getDate() < Bday) {
 memberage -= 1;				//but, if still before this year's birthdate,
 }						//not this year's age yet, so, still 1 year younger.
 //(in code, the months go from 0 to 11, but the dates I use have values 1-12, hence the "+1")
 //extra:
 if (today.getMonth()+1 == Bmonth && today.getDate() == Bday) {memberage += "<br><i>Happy Birthday!</b>i";}
}
return memberage;				//returns the member's current age!
}


//--------------------------special effects:--------------------------
//page left margin:
function setmargin() {
//activated while loading a page. for 800x600 screen size,
//the extra margin between menu and page text is left out.
//for bigger screen resolutions, it is added to the body style here.
if (screen.width > 800) {
document.write("<style type='text/css'> body{margin-left:30px} </style>");}
 //document.write("<img name='mainMargin' src='copyright.gif' border=0 hspace=0 vspace=0 height=1 width=60>");}
}

function readcookie(optionname) {
//looks up and returns a value inside a cookie.
//e.g. if "name=yakumo;" inside the cookie; readcookie("name") will return the value "yakumo".
 var cookievalue = document.cookie.match(optionname + '=(.*?)(;|$)');
 if (cookievalue) return (unescape( cookievalue[1] ) );
 else return null;
}

function changedivtext(divname, newdivtext) { 
//changes a div's text contents for all browsers except Opera.
if (document.getElementById) {document.getElementById(divname).innerHTML = newdivtext;}
else if (document.all) {document.all[ divname ].innerHTML = newdivtext;}
} 


FadeObjects = new Object();	//keeps track of the image 'objects'. used to pass through setTimeout.
FadeTimers  = new Object();	//keeps track of the timers for each image, so it won't be overloaded.

function fadetrans(object, fadeto, fadetime){
//fades images and div's in or out.
//e.g: fadetrans('imagename', 100, 1000);, where 'imagename' is the image's name. 1000 = 1 second.
if (document.all) {		//transparency effects only work in IE anyway, so this code is IE only.
 if (object != "[object]") {object = document.all[""+object+""];}	//converts object names to objects.
 //because of this little code, you can pass objects as well as object names to this function.
 //If the image does not have a transparency effect (a "filter") on it yet, give it one:
 if (!object.filters.alpha) {object.style.filter = "alpha(opacity=100)";}
clearTimeout(FadeTimers[object.sourceIndex]);	//a safety to prevent doubletime overloading.

if (object.filters.alpha.opacity != fadeto && fadetime > 0) {
 FadeObjects[object.sourceIndex] = object;	//keeps track of which object is being faded.
 var fadeby = (fadeto - object.filters.alpha.opacity) / (fadetime/ 50); 
 //This means: transparency difference / how many times this function will repeat from now. 
 object.filters.alpha.opacity += fadeby;	//fade in or out.
 fadetime -= 50;				//decrease fading timer
 FadeTimers[object.sourceIndex] =		//keeps track of the timer for cleartimeouts.
 setTimeout("fadetrans(FadeObjects[" +object.sourceIndex+ "]," +fadeto+ "," +fadetime+ ")", 50);
 //settimeout will repeat this function as long as there is time left to fade.
} else {object.filters.alpha.opacity = fadeto;}	//round off final bit of fade at the end.
}	//for internext explorer only.
}	//end of function fadetrans().


function fixpng(thisimage) {
//fixes the png transparency for Internet Explorer.
//For this to work, width and height must be specified in the html, and image name without spaces.
//execute this as the body is loading! not at onLoad, since that would still take a few seconds, during which the not-yet-transparent logo will be visible.
if (document.all) {	//for internet explorer only, do a png image transparency trick:
thisimage.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" +thisimage.src+ "', sizingMethod='scale')";	//fixes png image transparency correctly.
thisimage.src="copyright.gif";	//hide the real image. the filter is displayed instead.
//works on divs, tables and td's too.
}
}


function hidebrokenimages() {
//Activated after the page is loaded. Hides any images that could not be loaded.
if (document.images) {
 for (var i=0;i<document.images.length;i++) {
 if (!document.images[i].complete) {hidebrokenimage(document.images[i]);}
 }
}
}

function hidebrokenimage(thisimage) {
//Activates when an image could not be loaded (at image 'onError'),
//or activated by hidebrokenimages() at body onLoad (less efficient).
//thisimage.src="copyright.gif";
thisimage.width = "0";	//works faster and more effective than replacing image.
			//(the image is also not clickable, this way)
			//set width 0, because that works better in FireFox, when the image is a link
thisimage.style.backgroundColor = "transparent";
thisimage.style.cursor = "default";
}

-->
