//<![CDATA[
<!--
/**
* (c) copyright 2004 - m2studio AG | e-learning solutions
*
* Version 17.03.2004
* Author  m2studio AG <stefan.mees@m2studio.de>
*/

/**
*
* @param    string    url
* @param    string    parameter to get 
* @return   string    returns the value of param or null if param not given
*/
function getUrlParam(u,p) {
  var i, j, r = true;
  u = new String(u);
  i= u.toLowerCase().indexOf(p.toLowerCase()+'=');
  
  if ( i===-1 ) {
    r = undefined;
  }

  i = i + p.length + 1;
  j = u.indexOf('&',i);

  if ( j === -1 ) j = u.length;
  
  if ( i === j ) {
    r = undefined;
  }
  return ( r === true ) ? u.substring(i,j) : r;  
}
/**
*
*/
function getUri(u) {
  var p;
  u = new String(u);
  p = u.lastIndexOf("/");
  return u.substr(0,++p);
}
/**
*
*/
function getPage(u) {
  var p;
  u = new String(u);
  p = u.lastIndexOf("/");
  return u.substr(++p, u.length).split('.')[0];
}

/**
* method to run flash objects in new explorer versions
* because of - object tags in html page are no
* longer supported....
*
* @version  1.0     17.10.2003
* @author Stefan Mees <stefan.mees@m2studio.de>
* @param  String    src => location of the swf
* @param  String    name => name or unique id
* @param  String    paras => parameter (delimiter of elements ":", delemiter of key - value "#")
*                   i.e. 'width#101:height#35:version#5,0,0,0:flashvars#?b=6&a=5'
*                   if no version is given - Version 6 is used
* @param  String    addParas => optional parameter (delimiter of elements ":", delemiter of key - value "=")
*                   i.e. 'quality=high:swLiveConnect=true'
*
*/
function runEmbedFlash( src, name, paras, addParas ) {
  var a = parseParameters( paras,[':','#'] ), str = new String(), i;  
  if(addParas) {
    var b = parseParameters( addParas,[':','='] );
  }
  str += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
  str += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + ( ( a['version'] !== undefined ) ? a['version'] : '6,0,0,0') + '"';
  str += ' width="' + a['width'] + '" height="' + a['height'] + '" id="' + name + '" name="' + name + '">';
  str += '<param name="movie" value="' + src + ( ( a['flashvars'] !== undefined ) ? a['flashvars'] : '') + '"/>';
  str += '<param name="flashvars" value="' + ( ( a['flashvars'] !== undefined ) ? a['flashvars'] : '') + '"/>';
  if( b !== undefined ) {
    for( i in b ) {
      str += '<param name="'+ i +'" value="' + b[i] + '"/>';
    }
  }
  str += '<' + 'embed src="' + src + ( ( a['flashvars'] !== undefined ) ? a['flashvars'] : '') + '" ';
  str += 'flashvars="' + ( ( a['flashvars'] !== undefined ) ? a['flashvars'] : '') + '" ';
  str += 'width="' + a['width'] + '" height="' +  a['height'] + '" name="' + name + '" ';
  str += 'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"';
  if( b !== undefined ) {
    for( i in b ) {
      str += ' ' + i +'="' + b[i] + '"';
    }
  } 
  str +='></embed>';
  str +='<noembed><p>You need the Macromedia FlashPlugin to display this content.</p><p>Get the latest version from: <a href="http://www.macromedia.com/go/getflashplayer" target="_blank">Macromedia</a></p></noembed>';
  str +='</object>'+"\n";
  document.write( str );
}

function openNewWindow(src,name,paras,addParas)
{
  aParameters = new Array();
  aParameters = parseParameters(paras,new Array(",","="));
  if(addParas){
    if(addParas.match(/position:middle/)){
      paras = paras.concat( ",left="+parseInt(env.screenWidth/2-aParameters['width']/2)+","+"top="+parseInt(env.screenHeight/2-aParameters['height']/2));
    }
  }   
  __newWins[__winNum] = open(src,name,paras);
  setTimeout("__newWins["+(__winNum++)+"].focus()",100);
}
/**
* 
*
*/
function parseParameters(paras,aSplitChar) {
  var a, aParameters = [], aSplit;
  aParas = paras.split(aSplitChar[0]);
  for( a = 0 ; a < aParas.length; a++ ){
    aSplit = aParas[a].split(aSplitChar[1]);
    aParameters[aSplit[0]] = aSplit[1];
  }
  return aParameters;
}
__newWins = [];
__winNum  = 0;
/**
* 
*
*/
function makeZeros(l, s) {
   s = new String(s);
   for(var i = s.length; i < l; i++) {
     s = "0" + s;
   }
   return s;
}
/**
* 
*
*/
function setCookie (name, value, hours, path, domain, secure) {
  if(hours) { 
    if ( (typeof(hours) == 'string') && Date.parse(hours) ) { // already a Date string
      var numHours = hours;
    } else if (typeof(hours) == 'number') { // calculate Date from number of hours
      var numHours = (new Date((new Date()).getTime() + hours*3600000)).toGMTString();
    }
  }
  document.cookie = name + '=' + escape(value) + ((numHours)?(';expires=' + numHours):'') + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:'') + ((secure && (secure == true))?'; secure':''); // Set the cookie, adding any parameters that were specified.
} // setCookie
/**
* 
*
*/
function readCookie(name) {
    if(document.cookie == '') { // there's no cookie, so go no further
      return false; 
    } else { // there is a cookie
      var fc, lc, c = document.cookie;
      fc = c.indexOf(name); // find the start of 'name'
      if( (fc != -1) ) { // if you found the cookie
        fc += name.length + 1; // skip 'name' and '='
        lc = c.indexOf(';', fc); // Find the end of the value string (i.e. the next ';').       
        if(lc == -1) { lc = c.length; }     
      return unescape(c.substring(fc, lc));     
    } else { // If there was no cookie of that name, return false.    
      return false;     
    }
  } 
} // readCookie
/**
* 
*
*/
function killCookie(name, path, domain) {
  var t = readCookie(name); // We need the value to kill the cookie
  if(t) {
      document.cookie = name + '=' + t + '; expires=Fri, 13-Apr-1970 00:00:00 GMT' + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:''); // set an already-expired cookie
  }
} // killCookie   

function swapImgRestore() {
  var i, x, a=document.sr;
	for( i=0; a && i < a.length && (x=a[i]) && x.oSrc; i++ ) {
		x.src=x.oSrc;
	}
}
function swapImage() {
  var i, j = 0, x, a = swapImage.arguments;
	document.sr = [];
	for( i = 0; i < (a.length-2); i += 3 ) {
		if ( (x=resolveReference(a[i]) ) ) {
			document.sr[j++] = x; 
			if( !x.oSrc )  {
				x.oSrc=x.src; 
			}
			x.src=a[i+2];
		}
	}
}
/**
* 
*
*/
function makeLayer(name,x,y,width,height)
{
    if (is.ns4)
    {
        return new Layer(100);
    }

    if (is.ie4)
    {
        var code = '<span id="'+name+'" style="position:absolute; left:0px; top:0px; width:100px;"></div>';
        window.insertAdjacentHTML("beforeEnd", code);
        //lyr = parentElement.children[parentElement.children.length-1]
    }

    if (is.dom)
    {
        //var parentName;
        //var windowName;
//FIXXME handle this properly for name like 'div1.div2.div3' which is actually a bit stupid but hey ...
        nameSplitted = name.split(".");
        if( nameSplitted.length>1 )
        {
            parentName = nameSplitted[0];
            windowName = nameSplitted[1];
            parentLayer = resolveReference(parentName);
        }
        else
        {
            windowName = name;
            parentLayer = document.getElementsByTagName("body")[0]
        }

        lyr = document.createElement("SPAN");
        parentLayer.appendChild(lyr);
        lyr.name = windowName;
        lyr.id = windowName;
        lyr.style.position = "absolute";
        if( width )     lyr.style.width   = width;
        if( height )    lyr.style.height  = height;
        lyr.style.left    = x ? x : "10";
        lyr.style.top     = y ? y : "10";

        return windowName;

    /* neeeeeded 4 DOM
        try
        {
        document.body.appendChild(lyr);
        }
        catch(e)
        {
        alert("ERROR func.js: couldn't create SPAN "+name);
        }
    */
    }
} // end of function

/**
*
*   fills filler in the div name
*
*   @para   string  can be like this menu5.pageNumber means a div in a div
*                   the NS needs both divs to reference
*                   the inner div, the IE just uses pageNumber
*                   NS uses document.menu5.document.pageNumber
*/
function fillInnerHTML(name,filler)
{
    if(is.ie4 || is.dom)
    {
        // is just a hack of Mozilla, because there is no innerHTML in DOM
        resolveReference(name).innerHTML = filler;
    }
    if(is.ns4)	// resolve the referencing
    {
        doc = resolveReference(name);
        doc.document.write(filler);
        doc.document.close();
    }
}
/**
* 
*
*/
function getInnerHTML(name)
{
    if(is.ie4 || is.dom)
    {
        return resolveReference(name).innerHTML;
    }
    if(is.ns4)
    {
        return "";  // there is no implementation of getInnerHTML for NS4
        //doc = resolveReference(name);
        // ???????
    }
}

/**
* 
*
*/
function clip(name,cLeft,cTop,cRight,cBottom)
{
    if(is.ie4 || is.dom)
    {
        //document.all[name].style.clip='rect('+cTop+' '+cRight+' '+cBottom+' '+cLeft+')';
        resolveReference(name).style.clip='rect('+cTop+' '+cRight+' '+cBottom+' '+cLeft+')';
    }
    if(is.ns4)
    {
        doc = resolveReference(name);
        doc.clip.top = cTop;
        doc.clip.right = cRight;
        doc.clip.bottom = cBottom;
        doc.clip.left =  cLeft;
    }
}

/**
* 
*
*/
function setY(name,posTop) {setTop(name,posTop)}
function setTop(name,posTop)
{
	if(is.ie4 || is.dom)
  {
		resolveReference(name).style.top=posTop;
    return; // this is ONLY because in IE 4+ is.dom is also true, but it doesnt work all the way yet
  }
	if(is.ns4)
		resolveReference(name).top=posTop;
}


/**
* 
*
*/
function setX(name,posLeft) {setLeft(name,posLeft)}
function setLeft(name,posLeft)
{
    if (is.ie4 || is.dom) {
        resolveReference(name).style.left=posLeft;
        return; // this is ONLY because in IE 4+ is.dom is also true, but it doesnt work all the way yet
    }
    if (is.ns4) {
        resolveReference(name).left=posLeft;
    }
}

/**
* 
*
*/
function setZ(name,zIndex)
{
	if(is.ie4 || is.dom)
  {
		resolveReference(name).style.zIndex=zIndex;
    return; // this is ONLY because in IE 4+ is.dom is also true, but it doesnt work all the way yet
  }
	if(is.ns4)
		resolveReference(name).zIndex=zIndex;
}


/**
* 
*
*/
function setPos(name,posLeft,posTop)
{
  setLeft(name,posLeft);
  setTop(name,posTop);
}

/**
* 
*
*/
function setHeight(name,sizeHeight)
{
	if(is.ie4 || is.dom)
  {
		resolveReference(name).style.height=sizeHeight;
    return; // this is ONLY because in IE 4+ is.dom is also true, but it doesnt work all the way yet
  }
	if(is.ns4)
		resolveReference(name).height=sizeHeight;
}

/**
* 
*
*/
function setWidth(name,sizeWidth)
{
	if(is.ie4 || is.dom)
  {
		resolveReference(name).style.width=sizeWidth;
    return; // this is ONLY because in IE 4+ is.dom is also true, but it doesnt work all the way yet
  }
	if(is.ns4)
		resolveReference(name).width=sizeWidth;
}

/**
* 
*
*/
function getHeight(name)
{
    if(is.ie4)
        return resolveReference(name).offsetHeight;
    if(is.ns4)
        return resolveReference(name).document.height;
    if(is.dom)
        // ????????  can only be read if it was set before, either by setHeight or in the layer-style
        //return parseInt(resolveReference(name).style.height  ?  resolveReference(name).style.height : 277);
        return parseInt(resolveReference(name).style.height  ?  resolveReference(name).style.height : resolveReference(name).offsetHeight );
}


/**
* 
*
*/
function getClipHeight(name)
{
    if(is.ie4 || is.dom)
    {
        // get the clip parameters in an array clip is like that: top right bottom left
        // aClips = document.all[name].style.clip.split(" ");
        aClips = resolveReference(name).style.clip.split(" ");
        // replace the characters to get a number because aClips[0] is "rect(0"
        aClips[0] = aClips[0].replace(/[^0-9]+/,"");
        // status = "0="+aClips[0]+"   2="+aClips[2];
        return parseInt(parseInt(aClips[2])-parseInt(aClips[0]));   // height = bottom - top
    }
    if(is.ns4)
        return resolveReference(name).clip.height;
}

/**
* 
*
*/
function getWidth(name)
{
    if (is.ie) {
        return resolveReference(name).offsetWidth;
    }
    if (is.ns4) {
        return resolveReference(name).clip.width; // !!!! this is the clipping width, but not the actual width...
    }
        // NS doesnt have an property document.width, but therefore i cant use this
        // to read the width while i am changing the clipping width.... shit (i.e. loadingBar)
//		return resolveReference(name).document.width;
    if (is.dom) {
    // ????????  can only be read if it was set before, either by setWidth or in the layer-style
        _width = parseInt(resolveReference(name).style.width);
        if (!_width) {
            _width = parseInt(resolveReference(name).offsetWidth);
        }
        return _width?_width:0; // lets not return NaN, since that is not really useful
    }
    return 0;
}

/**
*
*
*/
function getX(name) {return getLeft(name)}
function getLeft(name)
{
		var ret = false;
    if (userAgent.dom) {
	      ret = parseInt(resolveReference(name).style.left);
        // if the element is not positioned absolute the IE returns undefined, which is OK				
				if(isNaN(ret)) {
            ret = parseInt(resolveReference(name).offsetLeft);					
				}
    } else {
        if (userAgent.ie && userAgent.version<5) {
            ret = resolveReference(name).offsetLeft;
        }
        if (userAgent.ns4) {
            ret = resolveReference(name).left;
        }
    }

    if (isNaN(ret)) {
        ret = getXOfStatic(name);
    }

    return ret;
}

/**
* 
*
*/
function getY(name) {return getTop(name);}
function getTop(name)
{
		var ret = false;
    if (is.ie4) {
        ret = resolveReference(name).offsetTop;
    }
    if (is.ns4) {
        ret = resolveReference(name).top;
    }
    if (is.dom) {
        ret = parseInt(resolveReference(name).style.top);
    }
    if (isNaN(ret)) {
        ret = getYOfStatic(name);
    }
    return ret;
}

/**
* 
*
*/
function getZ(name)
{
	if(is.ie4 || is.dom)
  {
	 // this is ONLY because in IE 4+ is.dom is also true, but it doesnt work all the way yet		
		return parseFloat(resolveReference(name).style.zIndex);

  }
	if(is.ns4)
		return parseFloat(resolveReference(name).zIndex);
}


/**
*   we try to get the static position, which
*   is for not absolute positioned elements, like normal HTML elements, without divs around them, etc.
*/
function getXOfStatic(name)
{
    element = resolveReference(name);
    ret = element.offsetLeft;
    do {
//alert(element+" "+element.offsetParent);    
        element = element.offsetParent;
        ret += element.offsetLeft;
    } while(element.tagName.toLowerCase()!="body");

    return ret;
}

/**
*   we try to get the static position, which
*   is for not absolute positioned elements, like normal HTML elements, without divs around them, etc.
*/
function getYOfStatic(name)
{
    element = resolveReference(name);
    ret = element.offsetTop;
    do {
        element = element.offsetParent;
        ret += element.offsetTop;
    } while(element.tagName.toLowerCase()!="body");

    return ret;
}

/**
* 
*
*/
function setVisibility(el, bDisplay) {
	if(bDisplay === true) {
		show(el);
	} else {
		hide(el);
	}
}

/**
* 
*
*/
function show(name)
{
    if(is.ie4) {
        resolveReference(name).style.visibility="visible";
        return; // this is ONLY because in IE 4+ is.dom is also true, but it doesnt work all the way yet
    }

    if (is.ns4) {
        resolveReference(name).visibility="visible";
    }

    if(is.dom) {
        resolveReference(name).style.display = "inline"; 
        resolveReference(name).style.visibility = "visible";
    }
    

    
}

/**
* 
*
*/
function hide(name)
{
    if(is.ie4 || is.op) { // it seems to be relevant for op5 i dont know for other operas!
        resolveReference(name).style.visibility="hidden";
        return; // this is ONLY because in IE 4+ is.dom is also true, but it doesnt work all the way yet
    }

    if(is.ns4) {
        resolveReference(name).visibility="hidden";
    }
    if(is.dom) {// works also for IE 5.x, but only with display:none
        resolveReference(name).style.visibility = "hidden";
    }

    
}

/**
* 
*
*/
function isHidden(name)
{
    if(is.ie4 || is.op || is.dom) {
        return resolveReference(name).style.visibility=="hidden";
    }

    if(is.ns4) {
        return resolveReference(name).visibility=="hidden";
    }
}

/**
* 
*
*/
function isLayer(which)
{
    if(is.dom && !is.ie4) // !!! actually it works in IE 4 too, but somehow not always
    {                     // maybe because of nested layers ?????
        if(resolveReference(which))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    // !!!!!!!! extend which, if it is like "layer1.layer2"
    if(resolveReference(which))
        return true;
    return false;
}

/**
* 
*
*/
function setBgColor(which,color)
{
	if(is.ie4)
        resolveReference(which).style.backgroundColor = color;
	if(is.ns4)
		resolveReference(which).bgColor = color;
}



/**
* 
*
*/
function setClass( which , className )
{
    element = resolveReference(which);
    if( is.ie )
    {
        element.className = className;
    }
    else
    {
        element.setAttribute("class",className);
    }
}

function setCursor(obj, cursor) {
	if( is.dom && !is.ie5)	 {
		obj.style.cursor = cursor;
	} else {
		obj.cursor = cursor;
	}
}
/**
* 
*
*/
function getScrollOffsetX()
{   
    return window.pageXOffset;
}

/**
* 
*
*/
function getScrollOffsetY()
{
    return window.pageYOffset;
}

/**
* 
*
*/
function resolveReference(name)
{
    var a;

    if (typeof name !="string" && parseInt(name)!= name) {
        return name;
    }

    aRefs = name.split(".");
    if (is.dom) {
        // if something like this "win.subwin.sub1win" is passed to this function, it returns "sub1win"
        // what happens if windows in different levels are called the same, like win.win, which win is used?
        // or is that forbidden in DOM?

        // check if the element with this id is given, if not, try the name :-)
        if (doc = document.getElementById(aRefs[aRefs.length-1])) {
            return doc;
        } else {
            if (doc=document.getElementsByName(aRefs[aRefs.length-1])[0]) {
                return doc;
            } else {
                return false;
            }
        }
    }
    if(is.ie4) {
        return eval(document.all[aRefs[aRefs.length-1]]);
    }
    if(is.ns4) { // resolve the referencing
        refString = 'document["'+aRefs[0]+'"]';	// not to have the period before the first document
        for (a=1 ; a < aRefs.length ; a++) {
            refString += '.document["'+aRefs[a]+'"]';
        }
        return eval(refString);
    }
}


// -->
//]]>

