function randompic()
{
var img_rnd = new Array ("r1.gif", "r2.gif", "r3.gif", "r4.gif", "r5.gif");

var i = Math.floor(4*Math.random());

document.write('<img src="' + img_rnd[i] + '" width="100" height="100" alt="Random image" />');

}


function expandit(curobj){
	thisLink=document.getElementById&&!document.all?1:0?curobj.nextSibling.nextSibling.style:document.all[curobj.sourceIndex+1].style

	if (thisLink.display=="none")
		thisLink.display=""
	else
		thisLink.display="none"
}


function pageload_SingleLink() 
{ 
  //alert(document.all.length);
  for(var temp=0; temp<document.all.length; temp++)
  {
  //  alert("in for loop");
  //  alert(document.all[temp].name);
	if(document.all[temp].name == "LeftLink")
	{
//	   alert(document.all[temp].name);
//	   alert(document.all[temp+1].href);
	   if(document.all[temp+1].href == window.location.href)
        {
  //       alert("same");
        for( var i =0; i < window.document.links.length; i++) 
           { 
             if(window.document.links[i].href == window.location.href) 
             {          
               for(var i2=i; i2 > 0; i2--) 
                  { 
                   if(window.document.links[i2].href == "javascript:")
                     {
                      expandit(window.document.links[i2]); 
                      return true;
                     }
                  } 
              }
          }
	   }
     }
   } 
} 

function pageload() 
{ 
   for( var i =0; i < window.document.links.length; i++) 
   { 
     if(window.document.links[i].href == window.location.href) 
     { 
       for(var i2=i; i2 > 0; i2--) 
       { 
        if(window.document.links[i2].href == "javascript:")
          {
            expandit(window.document.links[i2]); 
            return true;
          }
      } 
    }
  } 
} 
function maintain()
{

  var x = document.getElementsByTagName("a");

  for (var i=0; i < x.length; i++)
	{

	    if(x[i].href != "javascript:")
	       	x[i].onclick = clickNav;
	}
   expandnav();
}


function expandnav()
{
var counter = 0;
var str;
var theright;
var theleft;
var tempstr;
var startstr;
var counter2 =0;

str = window.location.href;
startstr = str.indexOf("?") + 1;

if(startstr != 0)
{
   for(var i=0; i < window.document.links.length; i++)
      {
        if(window.document.links[i].href == "javascript:")
          {
             theleft = str.indexOf("=") + 1;
	         theright = str.indexOf("&");
	         if(counter == 0 || counter2 == 0)
			   {
	            tempstr2 = str.substring(startstr,theleft-1);
			   }
  	         else
				tempstr2 = str.substring(0,theleft-1);
		
		   // alert(counter);
			//alert(tempstr2);
			tempstr = str.substring(theleft, theright);
		      if(counter == tempstr2)
	            {
				 //alert("counter == tempstr2");
	             str = str.substring(theright+1, str.length);
	             expandit(window.document.links[i]);
	             counter2++;
	            }
	       	  counter++;   
           }
       }
  }     
}

function clickNav()
{
var str;
var content, currentdir;
var current;
var num,to;
var test = false;
var contenttest,teststr,teststr2;


//parse target URL for content folder and directory
str = this.href;
num = str.indexOf("//") + 2;

//if there is no fully qualified path then it must be in same location
if(num == 0)
 test=true;
str=str.substring(num,str.length);//cuts off http:// from string
num = str.lastIndexOf("/");
teststr=str.substring(0,num);
teststr=teststr.substring(teststr.indexOf("/")+1,teststr.length);

if(teststr == "content") // means it is a link to the parent directory
   {
     str = str.substring(num,str.length); //content/dirname
     str= str.substring(str.indexOf("/")+ 1, str.length);
   }
else
	{
	str= str.substring(str.indexOf("/")+1, str.lastIndexOf("/"));
	teststr=str.substring(0,str.indexOf("/"));
	if(teststr == "content") // new site in new content folder
	   {
	    str=str.substring(str.indexOf("/")+1, str.lastIndexOf("/"));
	   }
	 else // old site in level above content folder
	 {
	  str=teststr;
	 }  
	
	}

to = str;

//parse current location 
/* old code
current= window.location.href;
num = current.indexOf("//") + 2;
current=current.substring(num,current.length);
num = current.indexOf("/") + 1;
current=current.substring(num,current.lastIndexOf("/")); //content/dirname/subdirname
num = current.lastIndexOf("/");
current = current.substring(num+1,current.length); //content/dir
currentdir = current;
*/


//parse target URL for content folder and directory
current= window.location.href;
num = current.indexOf("//") + 2;

current=current.substring(num,current.length);//cuts off http:// from string
num = current.lastIndexOf("/");
teststr=current.substring(0,num);
teststr=teststr.substring(teststr.indexOf("/")+1,teststr.length);


if(teststr == "content") // means it is a link to the parent directory
   {
     current = current.substring(num,current.length); //content/dirname
     current = current.substring(current.indexOf("/")+ 1, current.length);
   }
else
  {
    current = current.substring(current.indexOf("/")+1, current.lastIndexOf("/"));
    teststr=current.substring(0,current.indexOf("/"));
    if(teststr == "content") // new site in new content folder
       {
    	     teststr2 =  current.substring(current.indexOf("/")+1, current.lastIndexOf("/"));
	    if(teststr2 == "/")         
 	      current=current.substring(current.indexOf("/") +1, current.length);
                else
	    current=current.substring(current.indexOf("/")+1, current.lastIndexOf("/"));
      }
	 else // old site in level above content folder
	 {
	  current=teststr;
	 }  
	
   }

currentdir = current;

currentdir = currentdir.toLowerCase();
to = to.toLowerCase();

//alert(currentdir);
//alert(to);

if(currentdir == to || test == true)
{
 this.href += "?";
 var counter = 0;
 
 // build the url with the elements that are expanded
 for(var i=0; i < window.document.links.length; i++)
 {
   if(window.document.links[i].href == "javascript:")
   {
    expand=document.getElementById&&!document.all?1:0?window.document.links[i].nextSibling.nextSibling.style:document.all[window.document.links[i].sourceIndex+1].style
    if(expand.display == "")
      {
       this.href += counter + "=" +"true&";   
      }
    counter++;  
   } 
 }// end of for
}
else 
{
 return true;
}

 
}

