// JavaScript Document



/* expander for the blogger comments */

function togglecomments (postid) { 

   var whichpost = document.getElementById(postid); 
   
   if (whichpost.className=="commentshown") { 
      whichpost.className="commenthidden"; 
   } 
   else { 
      whichpost.className="commentshown"; 
   } 
}




/* expander for the sidebar items */

function initMenus() {
	if (!document.getElementsByTagName) return;
	
	var aMenus = document.getElementsByTagName("LI");
	for (var i = 0; i < aMenus.length; i++) {
		var mclass = aMenus[i].className;
		if (mclass.indexOf("treenode") > -1) {
			var submenu = aMenus[i].childNodes;
			for (var j = 0; j < submenu.length; j++) {
				if (submenu[j].tagName == "A") {
					
					submenu[j].onclick = function() {
						var node = this.nextSibling;
											
						while (1) {
							if (node != null) {
								if (node.tagName == "UL") {
									var d = (node.style.display == "none")
									node.style.display = (d) ? "block" : "none";
									this.className = (d) ? "treeopen" : "treeclosed";
									return false;
								}
								node = node.nextSibling;
							} else {
								return false;
							}
						}
						return false;
					}
					
					submenu[j].className = (mclass.indexOf("open") > -1) ? "treeopen" : "treeclosed";
				}
				
				if (submenu[j].tagName == "UL")
					submenu[j].style.display = (mclass.indexOf("open") > -1) ? "block" : "none";
			}
		}
	}
}

/* window.onload = initMenus; */




/* this thing loads up (what ever that means) both the sidebar expander
   and parts of the pager because they need to be for some reason */

window.onload=function(){
initMenus();
looper ();
}





/* pager for the portfolio images */

function showPic(link,id) {
    try{ //let's just do it!
        document.getElementById(id).src = link.href;
    }catch(e){}
    return false; 
}

function selectLink(link) {
    var ac = arguments.callee; //the selectLink function it's self
    if (ac.selectedLink){ //if this function has a selectedLink property
        ac.selectedLink.className = 'norm';
    }
    link.className = 'selected';
    ac.selectedLink = link;
    return false;
}

function looper () {
     //get all the links in the photo-pager div and loop through them, setting up their onclicks
    var links = document.getElementById('photo-pager').getElementsByTagName('a');
    for (var i = 0; i < links.length; i++) {
        links[i].onclick = function () {
            showPic(this,'placeholder');
            return selectLink(this);
        };
    }
    selectLink.selectedLink = links[0]; //set the initial selectedLink property of the selectLink function
};

/* window.onload = function () {
     //get all the links in the photo-pager div and loop through them, setting up their onclicks
    var links = document.getElementById('photo-pager').getElementsByTagName('a');
    for (var i = 0; i < links.length; i++) {
        links[i].onclick = function () {
            showPic(this,'placeholder');
            return selectLink(this);
        };
    }
    selectLink.selectedLink = links[0]; //set the initial selectedLink property of the selectLink function
}; */