﻿/*
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
clientLib Core Module

Author:			manfred.schneiderbauer@world-direct.at
*/
var clib_core_version = 1.393;
var clib_core_filesizeK = 17;
/*

Last Changed	2006-12-27

!!! ALL CONFIGURATION SETTINGS ARE IN clib_globalconf.js	!!!
!!! DON'T ALTER ANYTHING IN THIS CODE!						!!!

|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
*/

function d(id){return document.getElementById(id);}
if(window.cL_domain!=''){if(location.protocol.indexOf('file')==-1){if(window.cL_domain!='SAME'){document.domain=window.cL_domain;}else{var lh=location.hostname;var lhtld='';lhtld=lh.substring(lh.lastIndexOf('.'),lh.length);lh=lh.replace(lhtld,'');lh=lh.substring(lh.lastIndexOf('.')+1,lh.length);lh=lh+lhtld;window.cL_domain=lh;document.domain=lh;}}}

function getElementByClass(thetagname,theclassname){
  var allTags=document.getElementsByTagName(thetagname.toLowerCase());
  for(var i=0;i<allTags.length;i++)
    {
     if(allTags[i].className==theclassname)
      {
       var ref=allTags[i]; break;
      }
    }
  return ref;
}

function getElementsByClass(thetagname,theclassname){
  var allTags=document.getElementsByTagName(thetagname.toLowerCase());
  var takenTags=new Array(); var ac=0;
  for(var i=0;i<allTags.length;i++)
    {
     if(allTags[i].className==theclassname)
      {
       takenTags[ac]=allTags[i];
       ac++;
      }
    }
  return takenTags;
}

/*_______________________________________________________________________
PAGE INITIALIZATION FUNCTIONS
_______________________________________________________________________*/

// Return browser identity values
// Used by almost all functions in this library
function b(whichValue) {
var nu=navigator.userAgent;
var isDOM=document.getElementById ? true:false;
var isNN4=document.layers ? true:false;
var isIE4=document.all ? true:false;
var isOpr=false;
var isOpr7up=false;
var isLinux=false;
var isIE55up=false
var isIE6=false;
var isIE6up=false;
var isIE7=false;
var isIE7up=false;
var isMac=false;
var isGecko=false;
var GeckoVersion='';
var OprVersion='';
var isSafari=false;
var isKhtml=false;
if (isDOM&&isIE4) {var isIE5up=true; isIE4=false; isDOM=false;} else {var isIE5up=false;}
if ((isIE5up)&&(navigator.appVersion.indexOf('MSIE 5.0')==-1)) {isIE55up=true;}
if ((isIE55up)&&(navigator.appVersion.indexOf('MSIE 5.5')==-1)) {isIE6up=true;}
if ((isIE6up)&&(navigator.appVersion.indexOf('MSIE 6')==-1)) {isIE7up=true;}
if (isIE6up&&!isIE7up){isIE6=true;}
if (isIE7up){isIE7=true;}
if (nu.indexOf('Opera')!=-1) {isOpr=true;isDOM=false;isNN4=false;isIE4=false;isIE5up=false;isIE55up=false;isIE6=false;isIE6up=false;isIE7=false;isIE7up=false;}
if (nu.indexOf('Linux')!=-1) {isLinux=true;}
if (isOpr&&nu.indexOf('Opera 2')==-1&&nu.indexOf('Opera 3')==-1&&nu.indexOf('Opera 4')==-1&&nu.indexOf('Opera 5')==-1&&nu.indexOf('Opera 6')==-1){isOpr7up=true;}
if(isOpr&&(nu.indexOf('Opera/0')!=-1||nu.indexOf('Opera/1')!=-1||nu.indexOf('Opera/2')!=-1||nu.indexOf('Opera/3')!=-1||nu.indexOf('Opera/4')!=-1||nu.indexOf('Opera/5')!=-1||nu.indexOf('Opera/6')!=-1)){isOpr7up=false;}
if (nu.indexOf('Mac')!=-1){isMac=true;}
if (nu.indexOf('Gecko')!=-1){isGecko=true;isNN4=false;isIE4=false;isIE5up=false;isIE55up=false;isIE6=false;isIE6up=false;isIE7=false;isIE7up=false;}
if(nu.indexOf('Safari')!=-1){isSafari=true;isGecko=false;isNN4=false;isIE4=false;isIE5up=false;isIE55up=false;isIE6=false;isIE6up=false;isIE7=false;isIE7up=false;}
if(nu.indexOf('KHTML')!=-1||nu.indexOf('khtml')!=-1){isKhtml=true;isGecko=false;isNN4=false;isIE4=false;isIE5up=false;isIE55up=false;isIE6=false;isIE6up=false;isIE7=false;isIE7up=false;}
if (isGecko){GeckoVersion=nu.substring(nu.indexOf('rv:')+3,nu.indexOf('rv:')+6);}
if (isOpr){OprVersion=nu.substring(nu.indexOf('Opera')+6,nu.indexOf('Opera')+10);}
var whichValueValue=eval(whichValue);
return(whichValueValue);
}

// Detect the browser
// Used in each and every page and by almost every function
var isDOM=b('isDOM');var isNN4=b('isNN4');var isIE4=b('isIE4');var isOpr=b('isOpr');var isLinux=b('isLinux');var isIE5up=b('isIE5up');var isIE55up=b('isIE55up');var isIE6up=b('isIE6up');var isOpr7up=b('isOpr7up');var isMac=b('isMac');var isGecko=b('isGecko');var isIE6=b('isIE6');var isIE7=b('isIE7');var isIE7up=b('isIE7');var GeckoVersion=b('GeckoVersion');var OprVersion=b('OprVersion');var isSafari=b('isSafari');var isKhtml=b('isKhtml');
if(isIE5up&&!isIE55up){var undefined='undefined';} // define undefined on IE5.0

// Init the debug console
var cL_Debug=window.cL_Debug;
try{if(top.location.href.indexOf('clib_debug=1')!=-1||document.referrer.indexOf('clib_debug=1')!=-1){cL_Debug=true;}}catch(error){}
if(cL_Debug&&(!isIE5up&&!isSafari))
	{
	cL_Debug=false;
	window.cL_Debug=false;
	alert('clib Error:\n cL_Debug has been set to 1.\n However, the Debug console can only be used on Internet Explorer (Windows) or Safari (MacOS).');
	}

var invalidBrowser=false; // init
// set redir flag on unwanted browsers
if(!isIE5up&&!isIE55up&&!isOpr7up&&!isGecko&&!isSafari){invalidBrowser=true;}
if(cL_DenyOpera&&isOpr){invalidBrowser=true;}
if(cL_DenyGecko&&isGecko){invalidBrowser=true;}
if(isGecko&&cL_DenyGeckoBefore1&&Number(GeckoVersion)<1){invalidBrowser=true;}
if(cL_DenyIE&&(isIE4||isIE5up||isIE55up)){invalidBrowser=true;}
if(cL_DenyIE50&&(isIE5up||isIE55up)){invalidBrowser=true;}
if(cL_DenyIE55&&isIE55up){invalidBrowser=true;}
if(cL_DenyIEMac&&isMac&&(isIE4||isIE5up||isIE55up)){invalidBrowser=true;}
if(cL_DenySafari&&isSafari){invalidBrowser=true;}
// execute redirection
if(invalidBrowser&&location.href.indexOf(window.cL_DenyURL)==-1){location.replace(window.cL_DenyURL);}

// Debug window
if(cL_Debug&&(isIE55up||isSafari))
	{
	openDebugWindow();
	}

// Prepare the debug window
function openDebugWindow(){
debug_assignErrorConsole();
try {
	window.dW=window.open('clib/clib_core_debug.html','debug','width=640,height=320,toolbar=no,status=no,menubar=no,resizable=yes,scrollbars=yes');
	window.dW.moveTo(0,0);
	} catch (error) {
	window.setTimeout("openDebugWindow();",500);
	}
}

if(window.cL_IncludeStylesheets)
	{
	// output the inclusion link for the correct css file
	var cssIncCode="<link rel=\"stylesheet\" type=\"text/css\" href=\"";
	document.write(cssIncCode+cL_ClibCssFileName+"\">");
	document.write(cssIncCode+cL_CssFileName+"\">");
	if(!isMac)
		{
		if (isIE4||isIE5up)
		  {
		  if(!isIE7&&!isIE7up){document.write(cssIncCode+cL_IECssFileName+"\">");}
		  try{if(isIE7||isIE7up){document.write(cssIncCode+cL_IE7CssFileName+"\">");}}catch(error)
		    {
		    document.write(cssIncCode+cL_IECssFileName+"\">");
		    }
		  }
		else if (isGecko) {document.write(cssIncCode+cL_GeckoCssFileName+"\">");}
		else if (isOpr) {document.write(cssIncCode+cL_OperaCssFileName+"\">");}
		else {document.write(cssIncCode+cL_OtherCssFileName+"\">");}
		} else if (isMac) {
		if (isGecko) {document.write(cssIncCode+cL_GeckoMacCssFileName+"\">");}
		else if (isOpr) {document.write(cssIncCode+cL_OperaCssFileName+"\">");}
		else if (isSafari) {document.write(cssIncCode+cL_SafariCssFileName+"\">");}
		else if (isIEMac) {document.write(cssIncCode+cL_IEMacCssFileName+"\">");}
		else {document.write(cssIncCode+cL_OtherCssFileName+"\">");}
		}
	}

// generate a class named 'clib_link' mainly for clib-internal usage (pointer cursor)
var linkProp='';
if(isIE4||isIE5up){linkProp='hand';}else{linkProp='pointer';}
document.write('<style type="text/css">.clib_link{cursor:'+linkProp+';}.clib_s{line-height:0px;font-size:0px;visibility:hidden;}</style>\n');

// Modules inclusion
var modIncCode='';

// get local and global paths
var globalPrefix='clib/'; var localPrefix='clib/';
if(cL_globalModulePath!=''){globalPrefix=cL_globalModulePath;}
if(cL_localModulePath!=''){localPrefix=cL_localModulePath;}

var modIncCodeStart='<script language="javascript" src="###/clib_';
var modIncCodeEnd='.js"></script>';
if(!window.cL_ModulesToLoad){window.cL_ModulesToLoad='';}

// language dependant text modules inclusion for module 'fo'
if(window.cL_ModulesToLoad.indexOf('fo')!=-1||window.cL_GlobalModulesToLoad.indexOf('fo')!=-1)
	{
	//modIncCode+=modIncCodeStart.replace('###',localPrefix)+'form_config'+modIncCodeEnd;
	modIncCode+=modIncCodeStart.replace('###',globalPrefix)+'form'+modIncCodeEnd;
	var suff='';
	switch(window.cL_language)
		{
		case('en'): suff='en'; break;
		case('it'): suff='it'; break;
		default: suff='de';
		}
	modIncCode+=modIncCodeStart.replace('###',localPrefix)+'form_textelements_'+suff+modIncCodeEnd;
	}

// Module inclusions
window.modStr='fo+form,ed+edit,ba+back,ke+keys,ti+time,bb+bbar,da+date,ht+http,st+stre,lo+loff,cl+clor,cp+clip,sc+scim,sl+slid,cs+clss,pn+rpng,dw+dwin,me+menu';
var modIncArr=window.modStr.split(',');
var thisModArr=''; var thisShort=''; var thisLong='';

var mI=window.cL_ModulesToLoad+window.cL_GlobalModulesToLoad;

for (i=0;i<modIncArr.length;i++)
  {
    thisModArr=modIncArr[i].replace(',','').split('+');
    thisShort=thisModArr[0].replace('+','');
    thisLong=thisModArr[1].replace('+','');
    if(mI.indexOf(thisShort)!=-1&&thisShort!='fo')
      {
        //modIncCode+=modIncCodeStart.replace('###',localPrefix)+thisLong+'_config'+modIncCodeEnd;
        modIncCode+=modIncCodeStart.replace('###',globalPrefix)+thisLong+modIncCodeEnd;
        eval("window."+thisShort+"_isActive=true;");
      }
  }
document.write(modIncCode);

// Create an OPTION element
// selectId = id of the SELECT element where the OPTION element is to be attached to
// value = value for the element
// text = text for the element
// selected = when true, this option will be created with selected=true
function createOption(selectId,value,text,selected,classname){
var newOption=document.createElement("option");
var thisSelect=d(selectId);
// append the child before setting the attributes in order to have Opera 7 taking the attributes
thisSelect.appendChild(newOption);
// don't make usage of element.setAttribute since this doesn't yet work everywhere
newOption.value=value;
if(!isOpr)
	{
	newOption.text=text;
	}else{
	var newText=document.createTextNode(text);
	newOption.appendChild(newText);
	}
if(classname!=''&&classname!=undefined){newOption.className=classname;}
// select this new option if it is to be selected
if(selected)
	{
	if(isIE5up)
		{
		// ie can set the selected attribute here
		newOption.selected=true;
		} else {
		// for opera 7, selectedIndex must be set for this to work; moz could make use of both methods
		thisSelect.selectedIndex=thisSelect.length-1;
		}
	}
}

// Delete all OPTION alements
// selectId = id of the SELECT element where all OPTION elements are to be deleted from
function deleteOptions(selectId){
var selectElement=d(selectId);
while(selectElement.hasChildNodes())
	{
	selectElement.removeChild(selectElement.firstChild);
	}
}

// Transfer a SELECT element's selectedIndex and its value into window variables
// id = id of the SELECT element
// Will define and fill the window variables 'window.[id]_value' and 'window.[id]_selectedIndex'
// Necessary to enable storing of selections also on Opera who can't make use of select elements' selectedIndex when their display=none
function selInd2WinVar(id){
var evalStrVal="window."+id+"_value='"+d(id).options[d(id).selectedIndex].value+"'";
var evalStrInd="window."+id+"_selectedIndex='"+d(id).selectedIndex+"'";
eval(evalStrVal);
eval(evalStrInd);
}

// Scrolls to the top of the document after a defined delay time
// Used when page loads containing anchor jumps must be overridden
// delayTime = delay time value in milliseconds
function jumpToTop(delayTime,DOMPath,executeNow){
if(!executeNow||!executeNow) // see if delay time has been passed; if not, call the delayer
	{
	window.setTimeout("jumpTopToTop(0,'"+DOMPath+"',true);",delayTime);
	} else { // but if, jump to top
	eval(DOMPath).scrollTo(0,0);
	}
}

// Set a cookie
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

// Get a cookie
function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

// Measures the approximate CPU speed, writes it into a one-session cookie and returns the app. speed value in MHz
// The value is used within CPU time intensive functions to determine whether to use the time-consuming code version or a slim version of it
// Speed is measured three times per session and the average value is then set as global document variable 'CPUSpeed' and as domain-wide cookie 'CPUSpeed'; measurement precision is around +-150MHz for IE5, IE5.5, IE6 and Gecko; no measuring possible on Opera
function getCPUSpeed(){
try{
if(getCookie('CPUSpeed')==null||getCookie('CPUSpeed')=='null'||getCookie('CPUSpeed')==undefined||getCookie('CPUSpeed')=='')
	{
	var count=1000000;
	var date1=new Date();
	var start=date1.getTime();
	for (var i=1;i<=count;i++) {} // the measurement loop
	date1=new Date();
	var finish=date1.getTime();
	window.CPUSpeedSeconds=(finish-start)/1000;
	window.CPUSpeedLoopsPerMs=Math.round(count/window.CPUSpeedSeconds/1000);
	window.CPUSpeed=Math.round(window.CPUSpeedLoopsPerMs*0.341);
	setCookie('CPUSpeed',window.CPUSpeed,'','/');
	} else {
	window.CPUSpeed=getCookie('CPUSpeed');
	}
if(isMac){window.CPUSpeed=window.CPUSpeed*2;} // Multipy measurement result by 2 @ PPC
//setCookie('CPUSpeedMeasureCount','','','/'); // delete counter for debugging
return window.CPUSpeed;
} catch(error) {}
}
window.cL_CPUSpeed=getCPUSpeed();

// Debug routine private function: assign the error console to the window's error handler
function debug_assignErrorConsole(){
try
	{
	window.onerror=debug_callWriteToErrorConsole;
	} catch (error) {
	window.setTimeout("debug_assignErrorConsole();",15);
	}
}

// Debug routine private function: clear the error console (can't be called from the console window!)
function debug_clearErrorConsole(){
window.onerror='';
}

// Debug routine private function: call the error output in the console window
function debug_callWriteToErrorConsole(error_message,error_url,error_line){
dW.debug_writeToErrorConsole(error_message,error_url,error_line);
return true;
}

// Put a dot as content into all spacer DIVs (CSS classes clib_s and s)
function clib_fillSpacer(){
if(document.body){if(document.body.innerHTML){
var sDivs=document.getElementsByTagName('div');
for(var i=0;i<sDivs.length;i++)
	{
	if(sDivs[i].className=='clib_s'){sDivs[i].innerHTML='.';}
	}
}else{window.setTimeout("clib_fillSpacer();",250);}}else{window.setTimeout("clib_fillSpacer();",250);}
}
clib_fillSpacer();

// Make WBR cross-browser: replace it by a soft hypen (add a dash) on IE, Saf, Op
function clib_hyphenize(){
if(document.body){if(document.body.innerHTML){
try{
var wbrColl=document.getElementsByTagName('wbr');
var bufferHTML='';
var invalidWbr=0;
if(wbrColl.length>0)
	{
	for(var i=0; i<wbrColl.length; i++)
		{
		if((isIE5up||isOpr||isSafari)&&(wbrColl[i].parentNode.tagName.toLowerCase()!='body'))
			{
			bufferHTML=wbrColl[i].parentNode.innerHTML;
			while(bufferHTML.toLowerCase().indexOf('<wbr')!=-1)
				{
				bufferHTML=bufferHTML.replace('<wbr>','&shy;');
				bufferHTML=bufferHTML.replace('<WBR>','&shy;');
				bufferHTML=bufferHTML.replace(unescape('%3CWBR/%3E'),'&shy;');
				}
			wbrColl[i].parentNode.innerHTML=bufferHTML;
			} else {
			invalidWbr++;
			}
		}
	}
}catch(error){}
}else{window.setTimeout("clib_hyphenize();",250);}}else{window.setTimeout("clib_hyphenize();",250);}
}
clib_hyphenize();

// remove default margins and paddings from BODY
if(window.cL_BodyPreparation){document.write('<style>body{padding:0 0 0 0;margin:0 0 0 0;}</style>');}

// Run functions as soon as the BODY and it's innerHTML are available for scripting; replaces slower ONLOAD calls
function clib_onload(funcCall){
if(window.clib_onloadHasDelayed==undefined||!window.clib_onloadHasDelayed){window.clib_onloadHasDelayed=0;}
if(document.body) // if body exists... (if not, do a delay)
  {
  if(document.body.innerHTML) // if HTML exists inside it... (if not, do a delay)
   {
   var ihLength=Number(document.body.innerHTML.length); // ...store its amount
   if(window.ihOldLength){var ihOldLength=Number(window.ihOldLength);}else{var ihOldLength=0;}
   if(ihLength>ihOldLength) // if amount of HTML is increasing...
    {
    // ...do a delay
    window.ihOldLength=ihLength;
    window.setTimeout("clib_onload('"+funcCall+"');",25);
    }else{ // if not, the DOM contents are created
    if(window.clib_onloadHasDelayed==0) // if the rendering delay has not yet been processed...
      {
      window.clib_onloadHasDelayed=1;
      window.setTimeout("clib_onload('"+funcCall+"');",1000); // ...do a delay
      }else{ // else, finally execute the function call
      eval(funcCall);
      }
    }
   }else{
   window.setTimeout("clib_onload('"+funcCall+"');",25);
   }
  }else{
  window.setTimeout("clib_onload('"+funcCall+"');",25);
  }
}

// automatically activate embedded objects on IE6 and up
function clib_activateEmbeddedObjects(){
var buffer=''; var allObjs=document.getElementsByTagName('object');
for(var i=0;i<allObjs.length;i++)
  {
   buffer=allObjs[i].outerHTML;
   allObjs[i].outerHTML=buffer;
  }
}
if(isIE6||isIE6up){clib_onload("clib_activateEmbeddedObjects()");}

