var objWin;
var timerID;

function fitimg() {
  myImage = objWin.document.getElementById('myImage');

  if (myImage.complete==undefined || myImage.complete) {  
    clearInterval(timerID); 
 
    w=myImage.width;
    h=myImage.height; 
 
    ua=navigator.userAgent;
   
    if(ua.indexOf("Firefox",0)>=0) {
      objWin.innerWidth=w;
      objWin.innerHeight=h;
    } else if(ua.indexOf("MSIE",0)>=0) {
      objWin.resizeTo(w,h);
      objWin.resizeBy(w-objWin.document.body.clientWidth,
              h-objWin.document.body.clientHeight-16);
    } 

    objWin.document.close();
  }
}

function popup(url){
  
 if ( objWin ) {
      objWin.close();
 }

  objWin=window.open("","myWindow","width=1024,height=747");

  objWin.document.open();
  objWin.document.write("<html><head><title>Access Map<\/title><\/head>");
  objWin.document.write("<body style='margin:0px;padding:0px;background-color:#eee'>");
  objWin.document.write("<img src='"+url+"' id='myImage'>");
  objWin.document.write("<\/body><\/html>");

  timerID=setInterval('fitimg()', 500);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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_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_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];}
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

/* 

	Sitemap Styler v0.1
	written by Alen Grakalic, provided by Css Globe (cssglobe.com)
	visit http://cssglobe.com/lab/sitemap_styler/
	
*/

this.sitemapstyler = function(){
	var sitemap = document.getElementById("sitemap")
	if(sitemap){
		
		this.listItem = function(li){
			if(li.getElementsByTagName("ul").length > 0){
				var ul = li.getElementsByTagName("ul")[0];
				ul.style.display = "none";
				var span = document.createElement("span");
				span.className = "collapsed";
				span.onclick = function(){
					ul.style.display = (ul.style.display == "none") ? "block" : "none";
					this.className = (ul.style.display == "none") ? "collapsed" : "expanded";
				};
				li.appendChild(span);
			};
		};
		
		var items = sitemap.getElementsByTagName("li");
		for(var i=0;i<items.length;i++){
			listItem(items[i]);
		};
		
	};	
};


