﻿window.onload=initAll;

function initAll()
{
	LocalInfinitAll();
	var allLinks = document.getElementsByTagName("a");
	for (var i=0; i<allLinks.length; i++)
	{
		if (allLinks[i].className.indexOf("menuLink") > -1)
			{
			allLinks[i].onclick = function() {return false;}
			allLinks[i].onmouseover = toggleMenu;
			}
	}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//Menu Functions
function toggleMenu() {
	var startMenu = this.href.lastIndexOf("/")+1;
	var stopMenu = this.href.lastIndexOf(".");
	var thisMenuName = this.href.substring(startMenu,stopMenu);

	document.getElementById(thisMenuName).style.display = "block";
	

	this.parentNode.className = thisMenuName;
	this.parentNode.onmouseout = toggleDivOff;
	this.parentNode.onmouseover = toggleDivOn;	
}

function toggleDivOn() {
	document.getElementById(this.className).style.display = "block";
	
}

function toggleDivOff() {
	document.getElementById(this.className).style.display = "none";
}
// Code for the 'make link' function ////////////////////////////
function makeLink(){
	var url = "http://www.brampton-cambs-pc.gov.uk/";
	var title = "Brampton PC";
	if(document.all){
		window.external.AddFavorite(url,title)
	}
}

function bookmark_over(){
	document.getElementById('book_us').src ="../images/icon_bookmark_green.png";
}
function bookmark_out(){
	document.getElementById('book_us').src ="../images/icon_bookmark.png";
}
function home_over(){
	document.getElementById('home_us').src ="../images/icon_home_green.png";
}
function home_out(){
	document.getElementById('home_us').src ="../images/icon_home.png";
}

////////////////////////////////////////////////////////////////////////////////////
function LocalInfinitAll() {
	var allLocalInfLinks = document.getElementsByTagName("a");
			
	for (var i=0; i<allLocalInfLinks.length; i++) 
	{
		if (allLocalInfLinks[i].className.indexOf("LocalInfLink") > -1)
		{
				allLocalInfLinks[i].onclick = toggleLocalInfMenu;
		}
}
}
		
function toggleLocalInfMenu() {
	var startLocalInfMenu = this.href.lastIndexOf("/")+1;
	var stopLocalInfMenu = this.href.lastIndexOf(".");
	var thisLocalInfMenuName = this.href.substring(startLocalInfMenu,stopLocalInfMenu);
		
	var thisLocalInfMenu = document.getElementById(thisLocalInfMenuName).style;
	thisLocalInfMenu.display = (thisLocalInfMenu.display == "block") ? "none" : "block";
		
	return false;
}

