/* MENU ENGINE */


var subMenus=new Array(); // Create submenu array

function makeMenuArray() { 
	for (var i=0; i<document.getElementsByTagName('*').length; i++) { // Search all tags in document
		if (document.getElementsByTagName('*')[i].id && document.getElementsByTagName('*')[i].id.indexOf("subMenu") != -1) { // If tag has ID and ID has string "subMenu"
        	subMenus.push(document.getElementsByTagName('*')[i].id + ''); // Add that ID value to submenu array
		} // END IF
	} // END FOR
    // alert(subMenus[0]);
}

function menuClose() { // Close all submenus
	// alert(subMenus.length);
	if (subMenus.length > 2) {
		for (var i = 0; i < subMenus.length; i++) {
    		document.getElementById(subMenus[i]).style.display = "none";
		}
    } else { // Open Webhosting menu, Close Contact menu
		document.getElementById(subMenus[0]).style.display = "block";
        document.getElementById(subMenus[1]).style.display = "none";
    }
}

function menuOpen() { // Open all submenus
	for (var i = 0; i < subMenus.length; i++) {
    	document.getElementById(subMenus[i]).style.display = "block";
	}
}


function breadCrumb() { // Open submenu for current page
	loc = (document.URL.indexOf('localhost') !=-1) ? "http://localhost/ironspider4/" : "http://www.ironspider.ca/";
	linksArray = document.getElementsByTagName('A');
    for (var i=0; i<linksArray.length; i++) { // Loop through all links
    	if (document.URL == linksArray[i].href && linksArray[i].parentNode.id.indexOf('subMenu') !=-1) { 
        	// If link found on page matching page URL and parent element of match has subMenu** ID
        	linkMatch = linksArray[i]; // Set link as variable
            currSectID = linksArray[i].parentNode.id; // Get ID of parent DIV (submenu)
            document.getElementById(currSectID).style.display = "block"; // Open submenu
            linkMatch.style.background = "url('" + loc + "pics/design_menu_sprites.gif') no-repeat 0px -228px";
            linkMatch.style.color = "#FFCB73";
        }
    }
}


/* Opens/closes submenus by clicking on Menu Headings */
function openSubMenu(linkID) {
	if (document.getElementById(linkID).style.display == "none") {
	document.getElementById(linkID).style.display = "block";
	} else {
	document.getElementById(linkID).style.display = "none";
	}
}

function pageLoad() { // Set up page
	makeMenuArray();
    menuClose();
    breadCrumb();
}

function openWindow(page,name,specs) {
	window.open(page,name,specs);
}

function selectCode(happy) {
	document.getElementById(happy).select();
}

/* MORE INFORMATION PLEASE */

function showDetails(littlegiant) {
	document.getElementById(littlegiant).className = "OpenDetails";
}

function hideDetails(littlegiant) {
	document.getElementById(littlegiant).className = "ClosedDetails";
}

/* DIV SWAP */

function change2New(bozo) {
	document.getElementById(bozo).className = "ParentDiv02";
}

function change2Orig(bozo) {
	document.getElementById(bozo).className = "ParentDiv01";
}



