// Harwich Town Brewery JavaScript

function domail(user, domain) { window.location = "mailto:" + user + "@" + domain; }

// **************** S H O W  /  H I D E  ****************
function show(theid){
	if (document.getElementById) {
		var switch_id = document.getElementById(theid);
		if (switch_id) { switch_id.className = 'show'; }
    }
}
function hide(theid){
	if (document.getElementById) {
		var switch_id = document.getElementById(theid);
		if (switch_id) { switch_id.className = 'hide'; }
	}
}

// OUR BEERS
function showBeerDetail (thebeer) {
	hideBeerDetails (); // hide all detail & show all small
	hide (thebeer+'-sml'); // hide the clicked small one
	show (thebeer+'-big'); // show the big version instead
}

function hideBeerDetails () {
	hide ('lighthousebitter-big');
	hide ('leadinglights-big');
	hide ('phoenix-big');
	hide ('hapennymild-big');
	hide ('parkestonporter-big');
	hide ('bathsidebatterybitter-big');
	hide ('redoubtstout-big');
	hide ('misleadinglights-big');
	hide ('ganges-big');
	hide ('epa100-big');
	hide ('baybitter-big');
	hide ('bayblonde-big');
	
	show ('lighthousebitter-sml');
	show ('leadinglights-sml');
	show ('phoenix-sml');
	show ('hapennymild-sml');
	show ('parkestonporter-sml');
	show ('bathsidebatterybitter-sml');
	show ('redoubtstout-sml');
	show ('misleadinglights-sml');
	show ('ganges-sml');
	show ('epa100-sml');
	show ('baybitter-sml');
	show ('bayblonde-sml');
}




// HOMEPAGE LABEL SWAPPING...
var bottleID = 0; // initialise
var labelID = 3; // first label to be swapped in
var swapTime = 2500;  // swap interval in milliseconds

labelsarray = new Array();
labelsarray[1] = ["label-bathsidebatterybitter.png","Bathside Battery Bitter"];  // ["file name", "<alt> text"]
labelsarray[2] = ["label-phoenix.png","Phoenix APA"];
labelsarray[3] = ["label-ganges.png","Ganges"];
labelsarray[4] = ["label-epa100.png","EPA 100"];
labelsarray[5] = ["label-parkestonporter.png","Parkeston Porter"];
labelsarray[6] = ["label-redoubtstout.png","Redoubt Stout"];
labelsarray[7] = ["label-leadinglights.png","Leading Lights"];
labelsarray[8] = ["label-lighthousebitter.png","Lighthouse Bitter"];
labelsarray[9] = ["label-hapennymild.png","Ha'penny Mild"];
labelsarray[10] = ["label-baybitter.png","Bay Bitter"];
labelsarray[11] = ["label-bayblonde.png","Bay Blonde"];
labelsarray[12] = ["label-misleadinglights.png","Misleading Lights"];
labelsarray[13] = ["label-imperialredoubt.png","Imperial Redoubt Stout"];
labelsarray[14] = ["label-sintniklaas.png","Sint Niklaas"];

function waitForSwap () { setTimeout("swapBottles()",swapTime); }

function swapBottles () {
	// target next bottle...
	bottleID += 1;
	if (bottleID == 4) { bottleID = 1; }
	theContainer = "bottle" + bottleID;
	// set next label graphic...
	labelID += 1;
	if (labelID > (labelsarray.length-1)) { labelID = 1; }
	// do the swap...
	document.getElementById(theContainer).innerHTML = "<img src=\"images/"+ labelsarray[labelID][0] +"\" width=\"131\" height=\"140\" alt=\""+ labelsarray[labelID][1] +"\" />";
	// loop...
	waitForSwap ();
}


// ABOUT US random pint
pintlist = new Array();
pintlist[1] = ["pint-of-Harwich-Town-Brewing-Co-ganges.png","Harwich Town Brewing Co - Ganges"];
pintlist[2] = ["pint-of-Harwich-Town-Brewing-Co-bay-bitter.png","Harwich Town Brewing Co - Bay Bitter"];
pintlist[3] = ["pint-of-Harwich-Town-Brewing-Co-leading-lights.png","Harwich Town Brewing Co - Leading Lights"];
pintlist[4] = ["pint-of-Harwich-Town-Brewing-Co-imperial-redoubt-stout.png","Harwich Town Brewing Co - Imperial Redoubt Stout"];
pintlist[5] = ["pint-of-Harwich-Town-Brewing-Co-lighthouse-bitter.png","Harwich Town Brewing Co - Lighthouse Bitter"];
pintlist[6] = ["pint-of-Harwich-Town-Brewing-Co-hapenny-mild.png","Harwich Town Brewing Co - Ha'penny Mild"];
pintlist[7] = ["pint-of-Harwich-Town-Brewing-Co-parkestone-porter.png","Harwich Town Brewing Co - Parkestone Porter"];
pintlist[8] = ["pint-of-Harwich-Town-Brewing-Co-phoenix.png","Harwich Town Brewing Co - Phoenix"];
				  
function pintplease () {
	randomNum = Math.floor (Math.random() * (pintlist.length-1)) + 1; // select a random number between 1 and length of pintlist array (ignoring the 0 at start of array)
	picvar = pintlist[randomNum][0];
	altvar = pintlist[randomNum][1];
	document.write('<img src="images/' + picvar + '" alt="' + altvar + '" class="pint" />')
	//alert(randomNum);
}


