/////////////////////////////////////////////////////////////////////////////
// JavaScript :		Utility
//
// file :			utility_v10_dbg.js
//
// browsers :		Internet Explorer 4.x & Netscape Communicator 4.x
//
// content:
// these functions are used in all other optiker-scripts and provide basic
// utilities needed by all other optiker-scripts.
//
// copyright 1999 die optiker - jacob & partner gbr - www.die-optiker.com
// author: alexander jacob - jacob@die-optiker.com 
//
// this script may not be used on any web pages web-pages without permission
// of the author or the company die optiker
/////////////////////////////////////////////////////////////////////////////
	
/////////////////////////////////////////////////////////////////////////////
// Functions:
// 	utScanDoc(document, tagName, recourse, function)
// 	utGetExt(image-filename, extension)
// 	utGetStrVal(str, key, sep)
// 	nothing()
/////////////////////////////////////////////////////////////////////////////	

/////////////////////////////////////////////////////////////////////////////	
// global browser variables
/////////////////////////////////////////////////////////////////////////////
var isNS = (navigator.appName.indexOf("Netscape") >= 0 &&
               parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
var isIE = (document.all) ? 1 : 0;

/////////////////////////////////////////////////////////////////////////////	
// visibility attributes
/////////////////////////////////////////////////////////////////////////////
var Show, Hide;
if (isNS) { Show = "show"; Hide = "hide"; }
if (isIE) { Show = "visible"; Hide = "hidden"; }

/////////////////////////////////////////////////////////////////////////////	
// other variables
/////////////////////////////////////////////////////////////////////////////
var utNavBarHeight = 200;
	
/////////////////////////////////////////////////////////////////////////////	
// utScanDoc(document, tagName, recourse, function)
//
// scans all tags in document and calls function with the found tag
// as parameter. if tagName is null function is called for each element.
// otherwise function is called only if the tag matches.
// if recurse is true iframes are scanned recoursive.
/////////////////////////////////////////////////////////////////////////////
function utScanDoc(d,t,r,f)
{
	var i;
	
	if (isIE)
		{	
			// scan documents tags
			for (i=0; i<d.all.length; ++i)
				if (d.all[i].tagName == t || t == null) eval(f+"(d.all[i]);");
			// are there IFRAMEs ?
			if (r) for (i=0; i<d.frames.length; ++i)
					utScanDoc(d.frames[i].document,t,r,f);
		}
	if (isNS)
		{
			for (i=0; i<d.layers.length; ++i)
				{
					if (d.layers[i].tagName == t || t == null)
													eval(f+"(d.layers[i]);");
					if (r) for (var j=0; j<d.layers[i].document.layers.length; ++j)
						{
							if (d.layers[i].document.layers[j].tagName == t || t == null)
									eval(f+"(d.layers[i].document.layers[j]);");
							utScanDoc(d.layers[i].document.layers[j].document,t,r,f);
						}
				}
		}
}

/////////////////////////////////////////////////////////////////////////////	
// utGetExt(image-filename, extension)
//
// adds the extension to the image-filename and returns result
// i.e. utGetExt("test.gif", "_a") returns "test_a.gif"
/////////////////////////////////////////////////////////////////////////////
function utGetExt(n,e)
{
	var p = n.lastIndexOf(".");
	return (n.substr(0,p) + e + n.substr(p,4));
}

/////////////////////////////////////////////////////////////////////////////	
// ut_GetStrVal(str, key, sep)
//
// gets a tokens value from a string with seperators
/////////////////////////////////////////////////////////////////////////////
function utGetStrVal(s, k, p)
{
	if ( !s || !k || !p) return null;
	var t = s.split(p);
	for (var i=0; i<t.length; ++i) 	if (t[i] == k && i<t.length-1) return t[i+1];
	return null;		
}

/////////////////////////////////////////////////////////////////////////////
// nothing
/////////////////////////////////////////////////////////////////////////////
function nothing(){}

