

/* IMAGES - ROLLOVER && HYPERLINKS - CLASSES */
var hlinks;

function initImagesAndHyperlinks() {
	// check wether <img class="roll" ../>
	var images=document.getElementsByTagName("img");
	
	for(var i=0;i < images.length;i++) {
		if(/roll/.test(images[i].className)) {
			images[i].parentNode.onmouseover=function(){roll(this);};
			images[i].parentNode.onmouseout=function(){roll(this);};
			images[i].parentNode.onfocus=function(){roll(this);};
			images[i].parentNode.onblur=function(){roll(this);};
		}
	}
	
	// check wether <a class="tab" ..>
	hlinks = document.getElementsByTagName("a");
	for (var i=0;i < hlinks.length;i++) {
		if (/\btab\b/.test(hlinks[i].className)) {
			hlinks[i].onclick=function(){switchCssClass(this);};
		}
	}
}

function roll(obj) {	// obj == hyperlink
	var isNode,src,fType,newSrc,nowNode;

	for (var i=0;i < obj.childNodes.length;i++) {
		nowNode = obj.childNodes[i];
		
		if(nowNode.nodeType==1 && /img/i.test(nowNode.nodeName)) {
			isNode=i;
			break;
		}
	}

	// check img.src
	src = obj.childNodes[isNode].src;
	fType = src.substring(src.lastIndexOf("."), src.length);
	
	if(/_over/.test(src)) {
		newSrc = src.replace("_over","");
		
	} else {
		if (!/_pressed/.test(src)) {
			newSrc = src.replace(fType, "_over" + fType);
		} else {
			return false;
		}
	}

	obj.childNodes[isNode].src=newSrc;
}


function pressed(name, onoff)
{
  var src, theImage, newSrc, fType;
  
  theImage = document[name];
  src = theImage.src;
  fType = src.substring(src.lastIndexOf("."), src.length);
  if(onoff && !/_pressed/.test(src))
  {
    newSrc = src.replace(fType, "_pressed" + fType);
    theImage.src = newSrc;
  }
  else if(!onoff && /_pressed/.test(src))
  {
    newSrc = src.replace("_pressed", "");
    theImage.src = newSrc;
  }
}


function switchCssClass(obj) { // obj == hyperlink
	if (hlinks != null && hlinks != undefined) {
		for (var i=0;i < hlinks.length;i++) {
			if (hlinks[i] != obj) {
				hlinks[i].className = "tab";
			} else {
				hlinks[i].className = "tabActive";
			}
		}
	}
	// forward to hyperlink
	return true;
}

/* SCROLLFUNCTIONS FOR INTERACTIVE CONTENT */

var interval = null;
var stylesObj = null;
var offSetH;

function clipWert(obj,wert){
	var clip_feld= "" + obj.clip;
	clip_feld = clip_feld.replace(/,/g,"");
	clip_feld=clip_feld.split("rect(")[1].split(")")[0].split("px");
      
	if (wert=="o") return Number(clip_feld[0]);
	if (wert=="r") return Number(clip_feld[1]);
	if (wert=="u") return Number(clip_feld[2]);
	if (wert=="l") return Number(clip_feld[3]);
	  
	return false;
}
	
function clipRelativ(obj,o,r,u,l){
	n_o=clipWert(obj,"o")+o;
	n_r=clipWert(obj,"r")+r;
	n_u=clipWert(obj,"u")+u;
	n_l=clipWert(obj,"l")+l;
	obj.clip="rect("+n_o+"px "+n_r+"px "+n_u+"px "+n_l+"px)";
	
}
	
function clipAbsolut(obj,o,r,u,l){
	obj.clip="rect("+o+"px "+r+"px "+u+"px "+l+"px)";
}

function scrollPage(stylesObjName, direction, offSetHeight, isForInteractive) {

	if(document.getElementById( stylesObjName )){
		stylesObj = document.getElementById( stylesObjName ).style;
	}
	else if(document.all && document.all[stylesObjName]){
		stylesObj = document.all[stylesObjName].style;
	}
	
	if( isForInteractive == 'true' ){
		offSetH = Math.round((offSetHeight-295)/2.3);
	}
	else if ( isForInteractive == 'false' ){
		offSetH = offSetHeight;
	}
	
	var diffY = 10;
	if (stylesObj != null && stylesObj != undefined) {

		if (direction == "down") {
			var diffY = -10;
		}
		
		if ((diffY < 0 && clipWert(stylesObj,"u") <= (offSetH-diffY)) ||
			(diffY >= 0 && clipWert(stylesObj,"o") >= (diffY))) {
			
			stylesObj.top = parseInt(stylesObj.top) + diffY + "px";
			clipRelativ(stylesObj, (-diffY), 0, (-diffY) , 0);			
			stylesObj.height=parseInt(stylesObj.height) - diffY + "px";
			
			interval = setTimeout("scrollPage('"+stylesObjName+"', '"+direction+"', "+offSetHeight+", '"+isForInteractive+"')", 65);
		}
		
	}
}
	
function stopScrolling(){
	if (interval != null && interval != undefined) {
		clearTimeout(interval);
	}
}


/* WINDOW RESIZE SIMULATOR */

function doResize() {

	var w = 800;
	var h = 660;

	
	if (window.innerHeight && window.innerWidth) {
		window.innerHeight = h;
		window.innerWidth  = w;
		
	} else if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth) {
		var diffW = w - parseInt(document.documentElement.clientWidth);
		var diffH = h - parseInt(document.documentElement.clientHeight);
		try { window.resizeBy(diffW,diffH); } catch(e) { }
		
	} else if (document.body && document.body.clientHeight && document.body.clientWidth) {
		var diffW = w - parseInt(document.body.clientWidth);
		var diffH = h - parseInt(document.body.clientHeight);
		try { window.resizeBy(diffW,diffH); } catch(e) { }
	
	} else {
		
	}		
}

/* OPEN POPUP */
function openWin(url) {
	var wdth = 420;
	var hght = 390;
	var popup = window.open(url,'popupWin','width='+wdth+',height='+hght+',top=50,left=50,resizable=no');
	popup.focus();
}

/* onload -caller
window.onload = function(){
	doResize();
	findImages();
} */