

function breakout_of_frame()
{
	// see http://www.thesitewizard.com/archive/framebreak.shtml
	// for an explanation of this script and how to use it on your
	// own website
	if (top.location != location) {
		top.location.href = document.location.href ;
	}
}

function isWhiteSpace(s)
{
	if(s==null)
		return false;
	return (s==' ' || s=="\n" || s=="\r");
}

function trim(s)
{
	if(s==null)
		return null;
	
	while(s.length>0 && isWhiteSpace(s[0]))
		s = s.substring(1, s.length);
	while(s.length>0 && isWhiteSpace(s[s.length-1]))
		s = s.substring(0, s.length-1);
		
	return s;
}

// alert('\x3c \x3e');

function removeXMLComments(s)
{
	if(s==null)
		return null;
	
	while(true)
	{
		var i1 = s.indexOf('\x3c!--');
		if(i1<0)
			break;
		var new_s = s.substring(0,i1);
		var i2 = s.indexOf('--\x3e', i2);
		if(i2>=0)
			new_s += s.substring(i2+3);
		s = new_s;
	}
		
	return s;
}


function hide_empty_elements(element_name)
{
	var notes  = document.getElementsByName(element_name);
	
	if(null==notes)
		return;
	if(notes.length<1)
		return;

	var i;
	for(i=0;i<notes.length;i++)
	{
		note = notes[i];
		
		var children = note.getElementsByTagName ('div');
		if(children==null || children.length<1)
		  continue;
		
		var body_count = 0;
		for(j=0;j<children.length;j++)
		{
			child = children[j];
			var name = child.getAttribute('name');
			if(name==null)
				;
			else if(name=='title')
				;
			else if(name=='body')
			{
				var contents = child.innerHTML;
				
				
				contents = removeXMLComments(contents);
				contents = trim(contents);
				
				if(contents.length>0)
					body_count++;
			}
			else
			{
			//	alert('name('+(i+1)+'): '+name);			
			}
		}
		
		if(body_count<1)
			note.style.display='none';
		else
			note.style.display='block';
	}
}

function hide_empty_notes()
{
	hide_empty_elements("notes");
	hide_empty_elements("regrets");
	hide_empty_elements("keywords");
}

function myOnLoad()
{
breakout_of_frame();
hide_empty_notes();
}



