﻿var SVCategoryList=[];

function SVCategory(id,title) 
{
    this.id = id; 
    this.title = title;
    this.places = new Array();
}
function AquireCategory(id, title)
{
        
    var svCategory = SVCategoryList[id];
            
    if (svCategory==null)
    {
        svCategory = new SVCategory(id, title);
        SVCategoryList[id] = svCategory;
    }
    
    return svCategory;
}
function toggleVisibility(id)
{
	var element = document.getElementById(id);
	
	if (element.style.visibility == "visible") 
	{
        element.style.visibility = "hidden";
		element.style.display = "none"; 

		return false;
	} 
	else 
	{
		element.style.visibility = "visible";
		element.style.display = "block";

		return true;
	}
}
function checkVisibility(id)
{
	var element = document.getElementById(id);
	
	return element.style.visibility == "visible";
}

function setCategory(id)
{
    var element = document.getElementById(id);

	element.style.visibility = "hidden";
	element.style.display = "none"; 
}

function toggleCategory(id)
{
    var visible = toggleVisibility(id);
    
    var categoryBulbId = id + "_Bulb";
    
    var svCategory = SVCategoryList[id];
    
    var categoryOn = false;
    var bulbUrl = "http://sharrowvale.co.uk/Images/Bulbs/bulb_MenuOff.gif";
    
    if (visible)
    {
        // change icon
        bulbUrl = "http://sharrowvale.co.uk/Images/Bulbs/bulb_MenuOn.gif";
        categoryOn = true;
    }
    
    document.getElementById(categoryBulbId).src = bulbUrl;
         
    return svCategory;
}

function hoverCategory(id, over)
{
    var visible = checkVisibility(id);
    
    var categoryBulbId = id + "_Bulb";
    
    var svCategory = SVCategoryList[id];
    
 
    
    var bulbUrl = "http://sharrowvale.co.uk/Images/Bulbs/bulb_MenuOnMouseOverMenu.gif";
    
    if (!over)
    {
        if (visible)
        {
            bulbUrl = "http://sharrowvale.co.uk/Images/Bulbs/bulb_MenuOn.gif";
        }
        else
        {
            bulbUrl = "http://sharrowvale.co.uk/Images/Bulbs/bulb_MenuOff.gif";
        }
    }
    
    document.getElementById(categoryBulbId).src = bulbUrl;
        
    return svCategory;

}


function svglobal_resize() {
    var footer1 = document.getElementById("footer1");
    var footer2 = document.getElementById("footer2");
    var footer3 = document.getElementById("footer3");
    
    var fh1 = footer1.offsetHeight;
    var fh2 = footer2.offsetHeight;
    var fh3 = footer3.offsetHeight;
    
    var fh = fh1;
    if (fh<fh2) fh = fh2;
    if (fh<fh3) fh = fh3;
    
    footer1.style.height = fh+ "px";
    footer2.style.height = fh+ "px";
    footer3.style.height = fh+ "px";


    var htmlheight = document.body.parentNode.scrollheight;  
    var windowheight = window.innerheight;
    var screenHeight = window.screen.height; // ff and ie7 screen

    var main = document.getElementById("main");
    var top = document.getElementById("top");
    var bottom = document.getElementById("bottom");
    var menu = document.getElementById("menu");

    
    var h = (document.body.offsetHeight-top.offsetHeight-bottom.offsetHeight-48);
    
    if (h<250) h = 250;
    
    main.style.height = h+ "px";
    menu.style.height = h+ "px";
    

}

function svglobal_load() {
    svglobal_resize();
}

if (window.addEventListener) {
	window.addEventListener("load",svglobal_load,false);
} else if (window.attachEvent) {
	window.attachEvent("onload",svglobal_load);
} else {
	window.onload = function() {svglobal_load();}
}

if (window.addEventListener) {
	window.addEventListener("resize",svglobal_resize,false);
} else if (window.attachEvent) {
	window.attachEvent("onresize",svglobal_resize);
} else {
	window.onresize = function() {svglobal_resize();}
}

