
/*<version="1.2">*/

// 
//
//

function FHM_GetFrame(root, name)
{
	if(!name) name = "main";

	
	if(root.frames.length == 0) return null;

	var frame = null
	var e;
	var errors = false;

	frame = root.frames[name];
		
	return frame;
}



// 
//
//

function FHM_GetHead( root )
{
	var coll = root.childNodes;
	if(!coll) return null;

	var i;
	var size = coll.length;
	for(i=0; i<size; i++) {

		var el = coll[i];

		if( el.tagName == "HEAD" ) return el

	}

	return null;
}




// 
//
//

function FHM_GetRelFile( doc, test )
{
	var root = doc.documentElement;
	var head = FHM_GetHead(root);
	if(!head) return null;

	var i;
	var size = head.childNodes.length;
	for(i=0; i<size; i++) {

		var el = head.childNodes[i];

		if( el.tagName != "LINK" ) continue;

		var rel = el.rel;
		rel = rel.toLowerCase();

		if( rel == test ) return el.href;

	}

	return null;
}



// 
//
//

function FHM_NextFile()
{
	var frame = FHM_GetFrame( window.top, "main" );
	if(!frame) frame = window.top;

	var href = FHM_GetRelFile( frame.document, "next" );

	if(!href) {

		return;
	}

	frame.location.href = href;
}



//
//
//

function FHM_PrevFile()
{
	var frame = FHM_GetFrame( window.top, "main" );
	if(!frame) frame = window.top;

	var href = FHM_GetRelFile( frame.document, "prev" );

	if(!href) {

		return;
	}

	frame.location.href = href;
}



//
//
//

function FHM_PDFFile()
{
	var frame = FHM_GetFrame( window.top, "main" );
	if(!frame) frame = window.top;

	var href = FHM_GetRelFile( frame.document, "pdf" );

	if(!href) {

		alert( "No PFD version is available for this topic" );
		return;
	}

	frame.location.href = href;
}

