// JavaScript Document

// Hey Brian? Dropdown
var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

function jsddm_open() {
	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');
	}
function jsddm_close() {
	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');
	}
function jsddm_timer() {
	closetimer = window.setTimeout(jsddm_close, timeout);
	}
function jsddm_canceltimer() {	
	if(closetimer) 	{
		window.clearTimeout(closetimer);
		closetimer = null;
		}
	}
$(document).ready(function() {
	$('#jsddm > li').bind('mouseover', jsddm_open);
	$('#jsddm > li').bind('mouseout',  jsddm_timer);
	});

document.onclick = jsddm_close;


// Contact me


// Force out of frame
if (top.location != self.location) {
    top.location.replace(self.location)
	}


// Jump navigation
function jumpPage(newLoc) {
	newPage = newLoc.options[newLoc.selectedIndex].value
	
	if (newPage != "") {
		window.location.href = newPage
		}
	}


// Portfolio left nav folder
document.WM = new Object();
document.WM.menu = new Object();
document.WM.menu.dropdown = new Array();

function WM_initializeToolbar(){
    var i;
    if (document.all){
	for(i = 0; i < document.all('container').all.length; i++){
	    if ((document.all('container').all[i].className == 'header') ||
(document.all('container').all[i].className == 'links')){
		document.WM.menu.dropdown[document.WM.menu.dropdown.length]
= document.all('container').all[i];
	    }
	}
    } else if (document.getElementsByTagName && document.getElementById){
	var contained =
document.getElementById('container').getElementsByTagName('div');
	for(i = 0; i < contained.length; i++){
	    if ((contained[i].getAttribute('class') == 'header') ||
(contained[i].getAttribute('class') == 'links')){
		document.WM.menu.dropdown[document.WM.menu.dropdown.length]
= contained[i];
	    }
	}
    }
}

function WM_collapse(item){
    if(document.WM.menu.dropdown.length){
	if (document.WM.menu.dropdown[item + 1].style.display == 'none'){
	    document.WM.menu.dropdown[item + 1].style.display = '';
	    if(document.WM.menu.dropdown[item].id == 'webmonkey'){
		document.images[document.WM.menu.dropdown[item].id +
'Img'].src = 'http://www.heybrian.com/lib/images/portfolio/main/folder_open.png';
	    } else {
		document.images[document.WM.menu.dropdown[item].id +
'Img'].src = 'http://www.heybrian.com/lib/images/portfolio/main/folder_open.png';
	    }
	} else {
	    document.WM.menu.dropdown[item + 1].style.display = 'none';
	    if(document.WM.menu.dropdown[item].id == 'webmonkey'){
		document.images[document.WM.menu.dropdown[item].id +
'Img'].src = 'http://www.heybrian.com/lib/images/portfolio/main/folder_closed.png';
	    } else {
		document.images[document.WM.menu.dropdown[item].id +
'Img'].src = 'http://www.heybrian.com/lib/images/portfolio/main/folder_closed.png';
	    }
	}
    }
}

function WM_imageSwap(daImage, daSrc){
  var objStr,obj;
  /*
    WM_imageSwap()
    Changes the source of an image.
    Source: Webmonkey Code Library
    (http://www.hotwired.com/webmonkey/javascript/code_library/)

    Author: Shvatz
    Author Email: shvatz@wired.com
    */

  // Check to make sure that images are supported in the DOM.
  if(document.images){
    // Check to see whether you are using a name, number, or object
    if (typeof(daImage) == 'string') {
      // This whole objStr nonesense is here solely to gain compatability
      // with ie3 for the mac.
      objStr = 'document.' + daImage;
      obj = eval(objStr);
      obj.src = daSrc;
    } else if ((typeof(daImage) == 'object') && daImage && daImage.src) {
      daImage.src = daSrc;
    }
  }
}

// Rollover
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

