// Copyright (c) 2001 by WarpGear Software
//
// make framed windows always come up framed (not as top page)

var t = new String(top.document.title);
if (t.indexOf("Favorez") == -1)
{
	var root = getRoot(window.location);
	if ((root.indexOf("file:") == -1) && (root.indexOf("warpgear") == -1)) // disable if working on a local (windows) machine
	{
		top.window.location.replace( root + "/index.php?f=" + escape(stripRoot(window.location)) + "&referrer=" + escape( top.document.referrer ));
	}
}

function stripRoot(url)
{
	var rs = new String(url);
	var done = false;
	var slash = 0;
	while ((slash = rs.indexOf('/')) != -1 && !done)
	{
		done = (slash != 0 && rs.charAt(slash-1) != ':' && rs.charAt(slash+1) != '/');
		rs = rs.substring(slash+1); 		
	}
  var pos = rs.indexOf('index.php?f=');
  if (pos==0) rs = rs.substring(12);
	return rs;
}

function getRoot(url)
{
	var rs = new String(url);
	var subpath = stripRoot(url);
	return rs.substring(0, rs.length - subpath.length - 1); // returns root without ending slash
}


