function alignBoxes() {
        var firstTextHeight = document.getElementById("firstText").offsetHeight;
        var firstImageHeight = document.getElementById("firstImage").offsetHeight;


        if(firstTextHeight > firstImageHeight) {
            document.getElementById("firstImage").style.height = firstTextHeight;
        } else {
            document.getElementById("firstText").style.height = firstImageHeight;
        }

        var secondImageHeight = document.getElementById("secondImage").offsetHeight;
        var secondTextHeight = document.getElementById("secondText").offsetHeight;


        if(secondTextHeight > secondImageHeight) {
            document.getElementById("secondImage").style.height = secondTextHeight;
        } else {
            document.getElementById("secondText").style.height = secondImageHeight;
        }

        //Sort margin of pictures
        //If the text is bigger, make pic bigger, else make text bigger

        //var firstMargin = (document.getElementById("firstText").offsetHeight - 200) / 2;
        //document.getElementById("firstImageI").style.marginTop = firstMargin + "px;";

        //var secondMargin = (document.getElementById("secondText").offsetHeight - 300) / 2;
        //document.getElementById("secondImageI").style.marginTop = secondMargin + "px;";
 }



 function mouseOver(id) {
        document.getElementById('update1').style.background = "url(http://www.warwickirishdancing.co.uk/greenback.png)";
        document.getElementById('update2').style.background = "url(http://www.warwickirishdancing.co.uk/greenback.png)";
        document.getElementById('update3').style.background = "url(http://www.warwickirishdancing.co.uk/greenback.png)";
        document.getElementById(id).style.background = "url(http://www.warwickirishdancing.co.uk/orangeback.png)";
        document.getElementById('update1T').style.display = "none";
        document.getElementById('update2T').style.display = "none";
        document.getElementById('update3T').style.display = "none";
        document.getElementById(id + 'T').style.display = "block";

    }

    function mouseOut(id) {
        //var newpage = document.getElementById(id);
        //newpage.style.background = "url(http://www.warwickirishdancing.co.uk/greenback.png)";
        document.getElementById(id).style.background = "url(http://www.warwickirishdancing.co.uk/orangeback.png)";
    }

    function changePic() {
       setInterval("picChange()", 8000);
    }

    function picChange() {
        //alert(document.getElementById("update1").style.background);
        if(document.getElementById("update1").style.background == "transparent url(http://www.warwickirishdancing.co.uk/orangeback.png) repeat scroll 0% 0%") {
            document.getElementById("update1").style.background = "url(http://www.warwickirishdancing.co.uk/greenback.png)";
            document.getElementById("update2").style.background = "url(http://www.warwickirishdancing.co.uk/orangeback.png)";
            document.getElementById("update1T").style.display = "none";
            document.getElementById("update2T").style.display = "block";
        } else if(document.getElementById("update2").style.background == "transparent url(http://www.warwickirishdancing.co.uk/orangeback.png) repeat scroll 0% 0%"){
            document.getElementById("update2").style.background = "url(http://www.warwickirishdancing.co.uk/greenback.png)";
            document.getElementById("update3").style.background = "url(http://www.warwickirishdancing.co.uk/orangeback.png)";
            document.getElementById("update2T").style.display = "none";
            document.getElementById("update3T").style.display = "block";
        } else {
            document.getElementById("update3").style.background = "url(http://www.warwickirishdancing.co.uk/greenback.png)";
            document.getElementById("update1").style.background = "url(http://www.warwickirishdancing.co.uk/orangeback.png)";
            document.getElementById("update3T").style.display = "none";
            document.getElementById("update1T").style.display = "block";
        }
    }


    function showContents(id) {
        if(document.getElementById(id).style.display == "block") {
            document.getElementById(id).style.display = "none";
        } else {
            document.getElementById('firstText').style.height = "auto";
            document.getElementById(id).style.display = "block";
        }
        align();
    }

    function align() {
        var firstTextHeight = document.getElementById("firstText").offsetHeight;
        document.getElementById("firstImage").style.height = firstTextHeight;
    }


    function nextImage() {
        //Lets find out which image is currently visible
        //Total number of images
        var noImages = document.getElementById("images").getElementsByTagName("img");
        noImages = noImages.length;
        //Correct up to here!
        for(var i=1; i<=noImages; i++) {
            if(document.getElementById(i).style.display == "block") {
                //We have found the one that is block
                //Work out if it is the last one
                if(i == noImages) {
                    //Then we need to go to the first!
                    document.getElementById(i).style.display = "none";
                    document.getElementById("1").style.display = "block";
                    break;
                } else {
                    //We are not at the end
                    document.getElementById(i).style.display = "none";
                    document.getElementById(i+1).style.display = "block";
                    break;
                }
            }
        }
    }

    function prevImage() {
        //Lets find out which image is currently visible
        //Total number of images
        var noImages = document.getElementById("images").getElementsByTagName("img");
        noImages = noImages.length;
        //Correct up to here!
        for(var i=1; i<=noImages; i++) {
            if(document.getElementById(i).style.display == "block") {
                //We have found the one that is block
                //Work out if it is the last one
                if(i == 1) {
                    //Then we need to go to the first!
                    document.getElementById(i).style.display = "none";
                    document.getElementById(noImages).style.display = "block";
                    break;
                } else {
                    //We are not at the end
                    document.getElementById(i).style.display = "none";
                    document.getElementById(i-1).style.display = "block";
                    break;
                }
            }
        }
    }


    function fade(current, next) {

        cOpacity = document.getElementById(current).xOpacity;
        nIndex = next;
        nOpacity = document.getElementById(next).xOpacity;

        cOpacity-=.05;
        nOpacity+=.05;

        document.getElementById(next).style.display = "block";
        document.getElementById(current).xOpacity = cOpacity;
        document.getElementById(next).xOpacity = nOpacity;

        setOpacity(document.getElementById(current));
        setOpacity(document.getElementById(next));

        if(cOpacity<=0) {
            document.getElementById(current).style.display = "none";
            current = nIndex;
        } else {
            setTimeout(fade(current, next),50);
        }
    }

	function setOpacity(obj) {
		if(obj.xOpacity>.99) {
			obj.xOpacity = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
	}