I'm trying to combine these two scripts to acomplish a combined effect.
None of my variables are duplicates so that's not the problem. I've
been able to identify the line that breaks the first script - however I
don't know how to fix it. Both scripts work great separately. When I
comment out the 1 line in the 2nd script the 1st script works. And when
I leave the comment out the second one works but not the first. Please
HELP!
// 1st script ///
if (document.getElementById && document.getElementsByTagName &&
document.createTextNode) {
document.write('<link rel="stylesheet" type="text/css"
href="portfolio_hide_links.css" />');
window.onload = initToggleCategories;
}
function initToggleCategories() {
document.getElementById('contentPool').style.displ ay = 'none';
var as = document.getElementById('toggle').getElementsByTag Name('a');
for (var i = 0; i < as.length; i++) {
as[i].onclick = function() {
toggle(this);
return false;
}
}
// Activate the first tab by default
toggle(as[0]);
}
function toggle(l) {
// Try to get a reference to an element with the id 'current' (a
previously active tab header)
var oldCurrent = document.getElementById('current');
// If this element exists, remove its ID attribute
if (oldCurrent) oldCurrent.removeAttribute('id');
// Add the ID attribute with value 'current' to the newly active tab
header (LI element)
l.parentNode.setAttribute('id', 'current');
var oldCloneUL = document.getElementById('cloneUL');
if (oldCloneUL) document.body.removeChild(oldCloneUL);
var cloneUL = document.createElement('ul');
cloneUL.setAttribute('id', 'cloneUL');
document.body.appendChild(cloneUL);
var lis =
document.getElementById('contentPool').getElements ByTagName('li');
var cat_class = l.getAttribute('href').match(/#(\w.+)/)[1];
// Create helper array for sorting elements on alphabetical order
var tmpSort = new Array();
for (var c = 0; c < lis.length; c++) {
if (lis[c].className.indexOf(cat_class) != -1) {
var clone = lis[c].cloneNode(true);
// Get value of the link element
var aValue = clone.firstChild.firstChild.nodeValue;
// Add this value to the helper Array; Note that we cannot use
Array.push(), because older browsers like IE5 don't support it
tmpSort[c] = aValue;
// Sort the helper Array on alphabetical order
tmpSort.sort();
// Check what the new position of the element should be
for (var j = 0; j < tmpSort.length; j++) {
if (tmpSort[j] == aValue) {
// If the new LI element should be appended at a new position,
append it
if (typeof cloneUL.childNodes[j] == 'undefined')
cloneUL.appendChild(clone);
// Otherwise insert the new LI element at alphabetical order
else cloneUL.insertBefore(clone, cloneUL.childNodes[j]);
}
}
}
}
}
// 2nd script ///
if (document.getElementById && document.getElementsByTagName &&
document.createTextNode) {
document.write('<link rel="stylesheet" type="text/css"
href="showhide.css" />');
window.onload = initShowHide;
}
function initShowHide() {
hide();
var SkillList = document.getElementById('SkillList');
var as = SkillList.getElementsByTagName('a');
for (var b = 0; b < as.length; b++) {
as[b].onmouseover = function() {show(this); return false; }
as[b].onfocus = function() {show(this); return false; }
}
}
function show(s) {
hide();
var id = s.href.match(/#(\w.+)/)[1];
document.getElementById(id).style.display = 'block';
}
function hide() {
var Skills =
document.getElementById('Skills').getElementsByTag Name('div');
//////// THIS LINE BELOW IS WHAT BREAKS SCRIPT #1
for (var i = 0; i < Skills.length; i++) {
//////// THIS LINE ABOVE IS WHAT BREAKS SCRIPT #1
Skills[i].style.display = 'none';
}
}