function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->

// Nav menu
$(document).ready(function(){
	$("#navMenu ul ul").hide()
	.parent().find("a:first").click(function(event){
		var x = $("#navMenu ul ul:visible");
		var myul = $(this).parent().find("ul");
		x.not( myul ).slideUp("slow").parent().find("img:first").attr("src","/images/collapsed.gif");
		
		myul.slideToggle("slow");
		//$("#navMenu ul ul:visible").parent().find("img:first").attr("src","/images/expanded.gif");
		//$("#navMenu ul ul:hidden").parent().find("img:first").attr("src","/images/collapsed.gif");
	//	update_images();
		return false;
	})
	.end().find("img:first").attr("src","/images/collapsed.gif");

	// Email -----
	$("span.contact").each(function(){
	var to_replace = " [no time] ";
	$(this).html($(this).html().replace(to_replace, "@"));
	});
	
	$(function(){
		$("a.contact").each(function(){
		var to_replace = " [no time] ";
		$(this).html($(this).html().replace(to_replace, "@"));
		$(this).attr("href",$(this).attr("href").replace(to_replace, "@"));
		});
	});
	// -------
	// Nav Menu set location	
   var path = location.pathname.substring(1);
   
   if ( path != "" )
   {
   		path = "/" + path;
		$('#navMenu a[@href$="' + path + '"]').attr("class","selected").parent().parent().slideDown("slow");
	}
});
function frameBreak()
{
  if (top.location != location) {
    top.location.href = document.location.href ;
  }
};

var addBookmarkObj = {
  linkText:'Bookmark This Page',
  addTextLink:function(parId){
    var a=addBookmarkObj.makeLink(parId);
    if(!a) return;
    a.appendChild(document.createTextNode(addBookmarkObj.linkText));
  },
  addImageLink:function(parId,imgPath){
    if(!imgPath || addBookMarkIsEmpty(imgPath)) return;
    var a=addBookmarkObj.makeLink(parId);
    if(!a) return;
    var img = document.createElement('img');
    img.title = img.alt = addBookmarkObj.linkText;
    img.src = imgPath;
    a.appendChild(img);
  },
  makeLink:function(parId) {
    if(!document.getElementById || !document.createTextNode) return null;
    parId=((typeof(parId)=='string')&&!addBookMarkIsEmpty(parId))
      ?parId:'addBookmarkContainer';
    var cont=document.getElementById(parId);
    if(!cont) return null;
    var a=document.createElement('a');
    a.href=location.href;
    if(window.opera) {
      a.rel='sidebar'; // this makes it work in Opera 7+
    } else {
      // this doesn't work in Opera 7+ if the link has an onclick handler,
      // so we only add it if the browser isn't Opera.
      a.onclick=function() {
        addBookmarkObj.exec(this.href,this.title);
        return false;
      }
    }
    a.title=document.title;
    return cont.appendChild(a);
  },
  exec:function(url, title) {
    // user agent sniffing is bad in general, but this is one of the times 
    // when it's really necessary
    var ua=navigator.userAgent.toLowerCase();
    var isKonq=(ua.indexOf('konqueror')!=-1);
    var isSafari=(ua.indexOf('webkit')!=-1);
    var isMac=(ua.indexOf('mac')!=-1);
    var buttonStr=isMac?'Command/Cmd':'CTRL';

    if(window.external && (!document.createTextNode ||
      (typeof(window.external.AddFavorite)=='unknown'))) {
        // IE4/Win generates an error when you
        // execute "typeof(window.external.AddFavorite)"
        // In IE7 the page must be from a web server, not directly from a local 
        // file system, otherwise, you will get a permission denied error.
        window.external.AddFavorite(url, title); // IE/Win
    } else if(isKonq) {
      alert('You need to press CTRL + B to bookmark our site.');
    } else if(window.opera) {
      void(0); // do nothing here (Opera 7+)
    } else if(window.home || isSafari) { // Firefox, Netscape, Safari, iCab
      alert('You need to press '+buttonStr+' + D to bookmark our site.');
    } else if(!window.print || isMac) { // IE5/Mac and Safari 1.0
      alert('You need to press Command/Cmd + D to bookmark our site.');    
    } else {
      alert('In order to bookmark this site you need to do so manually '+
        'through your browser.');
    }
  }
}

function addBookMarkIsEmpty(s){return ((s=='')||/^\s*$/.test(s));}

function dss_addEvent(el,etype,fn) {
  if(el.addEventListener && (!window.opera || opera.version) &&
  (etype!='load')) {
    el.addEventListener(etype,fn,false);
  } else if(el.attachEvent) {
    el.attachEvent('on'+etype,fn);
  } else {
    if(typeof(fn) != "function") return;
    if(typeof(window.earlyNS4)=='undefined') {
      // to prevent this function from crashing Netscape versions before 4.02
      window.earlyNS4=((navigator.appName.toLowerCase()=='netscape')&&
      (parseFloat(navigator.appVersion)<4.02)&&document.layers);
    }
    if((typeof(el['on'+etype])=="function")&&!window.earlyNS4) {
      var tempFunc = el['on'+etype];
      el['on'+etype]=function(e){
        var a=tempFunc(e),b=fn(e);
        a=(typeof(a)=='undefined')?true:a;
        b=(typeof(b)=='undefined')?true:b;
        return (a&&b);
      }
    } else {
      el['on'+etype]=fn;
    }
  }
}

$(document).ready(function(){addBookmarkObj.addTextLink});
// For bookmarking <p id="addBookmarkContainer"></p>

document.write('<script type="text/javascript" src="/jscript/trhover.jquery.js"></script>');
document.write('<script type="text/javascript" src="/jscript/jquery.ifixpng.js"></script>');
document.write('<script type="text/javascript" src="/jscript/swfobject.js"></script>');
$(document).ready(function(){
	$('img[@src$=.png]').ifixpng(); 
	frameBreak(); 
});
