var custMenu = false;
var restart = false;
var topLevel = false;

if (framesWarning == true && window != top) {
   if(top.custMenu == true)
   framesWarning = false;
}	
		
var IFrameObj; // our IFrame object
var IFrameDoc;
var framDiv;
var run = 0;
var newDivs = 0;
var s1 = 0;
var s2 = 0;
	   
		function loadi()
		{

 if (top.IFrameObj.contentDocument) {
    // For NS6
    top.IFrameDoc = top.IFrameObj.contentDocument; 

  } else if (top.IFrameObj.contentWindow) {
    // For IE5.5 and IE6
    top.IFrameDoc = top.IFrameObj.contentWindow.document;

  } else if (top.IFrameObj.document) {

    // For IE5
    top.IFrameDoc = top.IFrameObj.document;
  } 

				
				var pass = true;
			var ni = top.IFrameDoc.getElementById('subcategoriesBox');

if(ni == null)
{
ni = top.IFrameDoc.getElementById('galleriesBox');
s2 = s2+1;
pass = false;
}

if(ni == null)
return;

			
			for(i = 0; i < ni.childNodes.length; i++)
			{
				var nc = ni.childNodes[i];
					if(nc == null)
						continue;
							
					if(nc.className == "boxBottom")
					{
				
						ni = nc;
						break;
					}
			}
if(!topLevel)
{
			
if(framDiv.childNodes[2].className == "albumTitle")
{
if(framDiv.childNodes[2].childNodes[0].innerHTML.length > 15)
  framDiv.style.height="3.5em";
else 
   framDiv.style.height="1.7em";
}
topLevel = false;
}
//else
  // framDiv.style.height="auto";

			framDiv.innerHTML += ni.innerHTML;
			//alert(framDiv.innerHTML);
			top.level1parse(document.getElementById('categoriesBox'), s1, false, s2, pass);		
		}
		
function callToServer(URL, fun) {
  if (!document.createElement) {return true};
  
  if (!IFrameObj && document.createElement) {
    // create the IFrame and assign a reference to the
    // object to our global variable IFrameObj.
    // this will only happen the first time 
    // callToServer() is called
   try {
      var tempIFrame=document.createElement('iframe');
      tempIFrame.setAttribute('id','RSIFrame');
      tempIFrame.style.border='0px';
      tempIFrame.style.width='0px';
      tempIFrame.style.height='0px';
      tempIFrame.onload=top.loadi;
      IFrameObj = document.body.appendChild(tempIFrame);
      
      if (document.frames) {
        // this is for IE5 Mac, because it will only
        // allow access to the document object
        // of the IFrame if we access it through
        // the document.frames array
        IFrameObj = document.frames['RSIFrame'];
      }
    } catch(exception) {
      // This is for IE5 PC, which does not allow dynamic creation
      // and manipulation of an iframe object. Instead, we'll fake
      // it up by creating our own objects.
      iframeHTML='\<iframe id="RSIFrame" style="';
      iframeHTML+='border:0px;';
      iframeHTML+='width:0px;';
      iframeHTML+='height:0px;';
      iframeHTML+='" onload="top.loadi()"><\/iframe>';
      document.body.innerHTML+=iframeHTML;
      IFrameObj = new Object();
      IFrameObj.document = new Object();
      IFrameObj.document.location = new Object();
      IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
      IFrameObj.document.location.replace = function(location) {
        this.iframe.src = location;
      }
    }
  }
  
  if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
    // we have to give NS6 a fraction of a second
    // to recognize the new IFrame
    setTimeout('callToServer()',10);
    return false;
  }
  
if (top.IFrameObj.contentDocument) {
    // For NS6
    top.IFrameDoc = top.IFrameObj.contentDocument; 

  } else if (top.IFrameObj.contentWindow) {
    // For IE5.5 and IE6
    top.IFrameDoc = top.IFrameObj.contentWindow.document;

  } else if (top.IFrameObj.document) {

    // For IE5
    top.IFrameDoc = top.IFrameObj.document;
  } 
else
return true;

  framDiv = fun;
  top.IFrameDoc.location.replace(URL);
  return false;
}

	       
	       function level1parse(ni, start1, passthru1, start2, passthru2)
	       {
	       	var i = start1;

	       	for(i; i < ni.childNodes.length; i++)
	       	{
	       		var nc = ni.childNodes[i];
	       		if(nc == null)
	       			continue;
	       		else if(nc.className == "boxBottom")
	       		{
	       			var j = start2;
	       			for(j; j < nc.childNodes.length; j++)
	       			{
	       				var nk = nc.childNodes[j];
	       				
	       				if(nk == null)
	       					continue;
//alert(nk.className + " " + nk.innerHTML);
	       				if(nk.innerHTML == null)
	       					continue;
	
	
	       				if(nk.className == "miniBox")
	       				{
	       					if(!passthru2)
	       					{
	       	/*					var newDiv = document.createElement('div');
	       						
	       newDiv.className="mlvl1";					
	       						nk.appendChild(newDiv);*/
	       						s1 = i;
	       						s2 = j;
var l = nk.getElementsByTagName("a")[0];
if(l == null)
continue;
						topLevel = false;
	       				top.callToServer(l.href, nk);
	       						return;
	       					}
	       					else
	       					{
	       						s1 = i;
	       						s2 = j+1;
	       						
	       						level2parse(framDiv, 0, 0);
passthru2 = false;
return;
	       					}
	       				}
	       			}
	       		}
	       	}
	       }
	       
	       function level2parse(ni, start1, start2)
	       {

/*var divHeight = 0;
if(framDiv.offsetHeight)
   divHeight = framDiv.offsetHeight;
else if(framDiv.style.pixelHeight)
   divHeight = framDiv.style.pixelHeight;

if(divHeight < 50)
   divHeight = 50;
			
framDiv.style.height="5px";
*/

	       	var i = start1;
	       	for(i; i < ni.childNodes.length; i++)
	       	{
	       		var nc = ni.childNodes[i];
	       		
	       		if(nc == null)
	       			continue;
	       		if(nc.innerHTML == null)
	       			continue;

	       		var j = 1;
	       		for(j; j < ni.childNodes[i].childNodes.length; j++)
	       		{
	       			var nk = ni.childNodes[i].childNodes[j];
	       			
	       			if(nk == null)
	       				continue;
	       			if(nk.innerHTML == null)
	       				continue;
var newDiv = document.createElement('div');
	       						
	newDiv.className="mlvl2";       					
	       						nk.appendChild(newDiv);


	       			var l = nk.getElementsByTagName("a")[0];

					callToServer(l.href, nc);
restart = true;
return;

	       		}
	       	}
	       }
	       

function mainCheck()
{
   if(document.location.href == 'http://eapstudios.smugmug.com/' ||
      document.location.href == 'http://eapstudios.smugmug.com')
   {
if(!window.smugmugUserHomepage)
{
      custMenu = true;
addCSS();
      level1parse(document.getElementById('categoriesBox'), 0, false, 0, false);
   } 
}
}

function addCSS()
{
css = '<link href="http://css.smugmug.com/include/css/theme_4207-20070717144005.css" type="text/css" rel="stylesheet" />';

document.getElementById('bodyWrapper').innerHTML = css + document.getElementById('bodyWrapper').innerHTML;

}