// JavaScript Document
function homeHeights(){

	var leftContent = document.getElementById("leftContent");
	var rightContent = document.getElementById("rightContent");
	var bottomLeft = document.getElementById("bottomLeft");
	var bottomRight = document.getElementById("bottomRight");
	var bottomMiddle = document.getElementById("bottomMiddle");
	
	var h = Math.max(leftContent.offsetHeight, rightContent.offsetHeight);
	
	if (leftContent.offsetHeight <= h){
		leftContent.style.height = (h -20)+'px';
	} else{
		rightContent.style.height = (h-20)+'px';	
	}
	
	h = Math.max(bottomLeft.offsetHeight, bottomMiddle.offsetHeight);
	h = Math.max(h, bottomRight.offsetHeight);
	
	if(bottomLeft.offsetHeight <=h){
		bottomLeft.style.height = h+'px';	
	}
	if(bottomRight.offsetHeight <=h){
		bottomRight.style.height = h+'px';	
	}
	if(bottomMiddle.offsetHeight <=h){
		bottomMiddle.style.height = h+'px';	
	}
}

function randomBanner(){
	
	pageName = document.URL.replace(/^.*?\/.*?\/.*?\//, "").toLowerCase();
	
	if(pageName == "events/index.html" || pageName == "events/"){
		document.write("<img src='/images/grouse.jpg' alt='The Crieff Highland Gathering' />");
		return;
	}
	
	pageName = document.URL.substring(document.URL.lastIndexOf("/")+1).toLowerCase();
	
	if(pageName == "caber.html"){
		document.write("<img src='/images/banner6.jpg' alt='The Crieff Highland Gathering' />");
	}else if(pageName == "dancing.html"){
		document.write("<img src='/images/banner5.jpg' alt='The Crieff Highland Gathering' />");
	}else if(pageName == "tugowar.html"){
		document.write("<img src='/images/banner3.jpg' alt='The Crieff Highland Gathering' />");
	}else if(pageName == "piping.html"){
		document.write("<img src='/images/banner8.jpg' alt='The Crieff Highland Gathering' />");
	}else if(pageName == "track.html"){
		document.write("<img src='/images/banner7.jpg' alt='The Crieff Highland Gathering' />");
	}else if(pageName == "hammer.html"){
		document.write("<img src='/images/grouse.jpg' alt='The Crieff Highland Gathering' />");
	}else{
	
		var no = 0;
		while(no<1){
			var no = Math.round(7*Math.random());
		}
		document.write("<img src='/images/banner"+no+".jpg' alt='The Crieff Highland Gathering' />");	
	}
}