//vars
var scroll_faster_txt;
var back_to_page_txt;
var err_msg;
if(Lang=="DE"){
	scroll_faster_txt = 'Klicken Sie schneller zu blättern';
	back_to_page_txt = 'ZURÜCK ZUR SEITE';
	err_msg = 'Die erforderlichen Informationen unvollständig oder fehlerhaft:';
}else{//is en
	scroll_faster_txt = 'Click to scroll faster';
	back_to_page_txt = 'BACK TO PAGE';
	err_msg = 'The required information is incomplete or contains errors:';
}

var cm_ss = 10;	// Higher value = faster
var cm_timer = 10;	// Lower value = faster
 
var oidtsd = false;
//was objectIdToSlideDown
var cm_a = false;
var cm_sip = false;


function sHC(e,iId)
{	
	
	if(cm_sip)return;
	cm_sip = true;
	if(!iId)iId = this.id;
	iId = iId + '';
	
	var nId = iId.replace(/[^0-9]/g,'');
	var aD = document.getElementById('cm_a' + nId);
 
	oidtsd = false;
	
	if(!aD.style.display || aD.style.display=='none'){		
		
		//this.onmouseout = '';
		
		if(cm_a &&  cm_a!=nId){	
			oidtsd = nId;
			sC(cm_a,(cm_ss*-1));
		}else{
			
			aD.style.display='block';
			aD.style.visibility = 'visible';
			
			sC(nId,cm_ss);
		}
	}else{
		sC(nId,(cm_ss*-1));
		cm_a = false;
	}	
}

function sC(iId,d)
{
	
	var obj =document.getElementById('cm_a' + iId);
	var contentObj = document.getElementById('cm_ac' + iId);
	height = obj.clientHeight;
	if(height==0)height = obj.offsetHeight;
	height = height + d;
	rerunFunction = true;
	if(height>contentObj.offsetHeight){
		height = contentObj.offsetHeight;
		rerunFunction = false;
	}
	if(height<=1){
		height = 1;
		rerunFunction = false;
	}
 
	obj.style.height = height + 'px';
	var topPos = height - contentObj.offsetHeight;
	if(topPos>0)topPos=0;
	contentObj.style.top = topPos + 'px';
	if(rerunFunction){
		setTimeout('sC(' + iId + ',' + d + ')',cm_timer);
	}else{
		if(height<=1){
			obj.style.display='none'; 
			if(oidtsd && oidtsd!=iId){
				document.getElementById('cm_a' + oidtsd).style.display='block';
				document.getElementById('cm_a' + oidtsd).style.visibility='visible';
				sC(oidtsd,cm_ss);				
			}else{
				cm_sip = false;
			}
		}else{
			cm_a = iId;
			cm_sip = false;
		}
	}
}
 
function iSH()
{
	var divs = document.getElementsByTagName('DIV');
	var divCounter = 1;
	for(var no=0;no<divs.length;no++){
		if(divs[no].className=='cm_l1'){
			divs[no].onclick = sHC;			
			divs[no].id = 'cm_q'+divCounter;
			var answer = divs[no].nextSibling;
			while(answer && answer.tagName!='DIV'){
				answer = answer.nextSibling;
			}
			answer.id = 'cm_a'+divCounter;	
			contentDiv = answer.getElementsByTagName('DIV')[0];
			contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px'; 	
			contentDiv.className='cm_l2_content';
			contentDiv.id = 'cm_ac' + divCounter;
			answer.style.display='none';
			answer.style.height='1px';
			divCounter++;
		}		
	}	
}
	
currentFullImage = 0;// set what the main image in the popup currently is
	
	function showPreview(imageArrayPos){
		
		preciewArrayCount = pageImages.length;
		
		currentFullImage = imageArrayPos;// set what the main image in the popup currently is
		
		document.fullImage.src=pageImages[imageArrayPos];
		
		backHTML = '<a href="#" onClick="SwapImg(\'backImg\'); return false;">'+'<img src="'+pathToImg+'prev_arrow.png" name="imgBack" id="imgBack"> Previous'+'</a>';
		
		closeHTML = '<a href="#" onClick="showPage(); return false;">Close</a>';

		forwardHTML = '<a href="#" onClick="SwapImg(\'forwardImg\'); return false;">'+'Next <img src="'+pathToImg+'next_arrow.png" name="imgForward" id="imgForward">'+'</a>';
		
		if(preciewArrayCount<=1){
			fullHTML = '<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="10">&nbsp;</td><td width="180" align="left">&nbsp;</td><td width="500" align="center">'+closeHTML+'</td><td width="180" align="right">&nbsp;</td><td width="10">&nbsp;</td></tr></table>';
		}else{
			fullHTML = '<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="10">&nbsp;</td><td width="180" align="left">'+'</td><td width="500" align="center">'+backHTML+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+closeHTML+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+forwardHTML+'</td><td width="180" align="right">'+'</td><td width="10">&nbsp;</td></tr></table>';
		}
		
		document.getElementById('galleryImageNav').innerHTML = fullHTML;
		
		document.getElementById('MainContent').style.left= '-370px';
		document.getElementById('MainImage').style.left= '-2000px';
		countG = 0-(880-240);
		showGallery();
		scroll(0,0);
	}
	function SwapImg(Type){
		
		arrayCount = pageImages.length - 1;
		
		if(Type == 'forwardImg'){
			moveToArrayElement = currentFullImage + 1;
			if(moveToArrayElement>arrayCount){
				moveToArrayElement = 0;
			}
		}else{
			moveToArrayElement = currentFullImage - 1;
			if(moveToArrayElement<0){
				moveToArrayElement = arrayCount;
			}
		}
		currentFullImage = moveToArrayElement;
		document.fullImage.src=pageImages[moveToArrayElement];
		
	}
	
	var countG = 0-(880-240);
	
	function showGallery(){
		
		document.getElementById('ImageGallery').style.left = countG+'px';
		
		width = 240;	
		
		if(countG < (width-60)){
			countG = countG+14;
			setTimeout(showGallery,2);
		}else if(countG < (width-30)){
			countG = countG+6;
			setTimeout(showGallery,2);
		}else if(countG < width){
			countG = countG+2;
			setTimeout(showGallery,2);
		}
		
	}

	function showPage() {
		countG = 0-(880-240);
		document.getElementById('ImageGallery').style.left= '-2000px';
		count2 = 0-mainContentWidth;
		SetImage('load',880);	
	}
	//window.onload = initSlideShow;
// SCROLLING layer script

var timeout;
var delay = 10;

function recScroll(elementId, direction, speed) { 
  clearTimeout(timeout);
  var intElemScrollTop = window.document.getElementById(elementId).scrollTop;
  if (direction == 'down') {
    window.document.getElementById(elementId).scrollTop = intElemScrollTop + speed;
  } else {
    window.document.getElementById(elementId).scrollTop = intElemScrollTop - speed;
  }
  if (intElemScrollTop != window.document.getElementById(elementId).scrollTop ) {
    timeout=setTimeout("recScroll('"+elementId+"', '"+direction+"', "+speed+");",delay);
  } else {
    recScrollLimit(elementId,direction);
  }
}
function recScrollStop() {
  clearTimeout(timeout);
}
function recScrollLimit(elementId, direction) {
  //alert("You can't keep scrolling "+elementId+" "+direction+".");
}

function recScrollBy(elementId, direction, pixels, speed) { 
  clearTimeout(timeout);
  if (pixels > 0) {
    var intElemScrollTop = window.document.getElementById(elementId).scrollTop;
    if (direction == 'down') {
      window.document.getElementById(elementId).scrollTop = intElemScrollTop + speed;
    } else {
      window.document.getElementById(elementId).scrollTop = intElemScrollTop - speed;
    }
    pixels = pixels - speed;
    timeout=setTimeout("recScrollBy('"+elementId+"', '"+direction+"', "+pixels+", "+speed+");",delay);
  }
}

function scrollWheel(event){
  var delta = 0;
  var pixelsPerEvent = 40;
  var elementId = 'MainText';

  /* Delta is a multiple of 120 (except for Mozilla where it is a multiple of 3) */
  /* In Opera and Mozilla the delta is negative compared to IE. */
  if (!event) /* Get the event for IE. */
    event = window.event;
  if (event.wheelDelta) { /* IE/Opera. */
    delta = event.wheelDelta/120;
    if (window.opera)
      delta = -delta;
  } else if (event.detail) { /* Mozilla */
    /* I'm not going to divide by 3 since Mozilla's scrolling is so slow. */
     delta = -event.detail;
  }

  /* Act if delta != 0 */
  if (delta) {
    if (delta < 0) {
      direction = 'down';
      delta = -delta;
    } else {
      direction = 'up';
    }
    pixels = pixelsPerEvent * delta;
    speed = delta * 5;
    //alert("Scrolling "+elementId+" "+direction+" by "+pixels); /* for debugging */
    recScrollBy(elementId,direction,delta,speed);
  }
}

/* Initialization code. */
/* Mozilla browsers use DOMMouseScroll which listens for scrolling _anywhere_ on the window */
if (window.addEventListener)
  window.addEventListener('DOMMouseScroll', scrollWheel, false);
  /* document.getElementById('thumbnails').addEventListener('DOMMouseScroll', scrollWheel, false); */

/* The following will listen for scrolling _anywhere_ in the window */
/* It is therefore preferable to assign this as an event for the area you wish to scroll */
/* e.g. <DIV ID="thumbnails" onmousewheel="wheel()"> */
//window.onmousewheel = document.onmousewheel = scrollWheel;


function insertScroll(){
	document.getElementById('scrollButtons').innerHTML=writeScrollButtons();
	//alert('insert scroll called');
}

function writeScrollButtons(){
	if (parseInt(document.getElementById('MainText').offsetHeight) < parseInt(document.getElementById('MainText').scrollHeight)) {
     	ScrollText = '<div id="scrollHolder">  <a href="#" onmousedown="recScroll(\'MainText\',\'up\',5);" onmouseup="recScroll(\'MainText\',\'up\',1);" onmouseover="recScroll(\'MainText\',\'up\',1);MM_swapImage(\'arrowUp\',\'\',\''+pathToImg+'arrow_up_over.png\',0);" onmouseout="recScrollStop();MM_swapImgRestore();" onclick="return false;"><img src="'+pathToImg+'arrow_up.png" title="'+scroll_faster_txt+'" width="40" height="16" style="padding:5px" id="arrowUp" name="arrowUp"></a><a href="#" onmousedown="recScroll(\'MainText\',\'down\',5);" onmouseup="recScroll(\'MainText\',\'down\',1);" onmouseover="recScroll(\'MainText\',\'down\',1);MM_swapImage(\'arrowDown\',\'\',\''+pathToImg+'arrow_down_over.png\',0);" onmouseout="recScrollStop();MM_swapImgRestore();" onclick="return false;"><img src="'+pathToImg+'arrow_down.png" title="'+scroll_faster_txt+'" width="40" height="16" style="padding:5px" id="arrowDown" name="arrowDown"></a></div>';
	}else{
		ScrollText = '<div id="scrollTextAlt" style="height:30px;"></div>';
	}
	return ScrollText;
}



// SLIDE out the main boxes
function SetClass(Type){
	
	if(Type==1){
		document.getElementById('FullImage').className='FullImageHover';
	}else{
		document.getElementById('FullImage').className='FullImage';
	}

}


var count3;

var runInit3='yes';

function SetImage(Type,imgWidth){

	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
    	//Non-IE
    	myWidth = window.innerWidth;
   		myHeight = window.innerHeight;
  	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    	//IE 6+ in 'standards compliant mode'
    	myWidth = document.documentElement.clientWidth;
    	myHeight = document.documentElement.clientHeight;
  	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    	//IE 4 compatible
    	myWidth = document.body.clientWidth;
    	myHeight = document.body.clientHeight;
  	}

	ImageWidth = myWidth - (240 + mainContentWidth) + 3;
	
	//alert(ImageWidth+' - '+imgWidth);
	
	if(ImageWidth>0){
		//InnerText = '<a href="#" id="FullImage" style="float:right" onClick="showPreview(0); return false;"><img src="'+pathToImg+'view_full_image_'+Lang+'.png"></a>';
		InnerText = '';
		if(imgWidth>=ImageWidth){
			document.getElementById('MainImage').innerHTML = InnerText;
		}
		document.getElementById('MainImage').style.width = ImageWidth+'px'; //set how much available space there is for the img
	}else{
		document.getElementById('MainImage').innerHTML = '';	
	}
	
	DivHeight = (myHeight - 660)/2;
	
	if((myHeight - 660)<0){
		document.getElementById('ContentSpcr').style.height = '0px';
		if(navigator.appName == "Netscape"){
			ImageWidth=ImageWidth-17; // if netscape acount for js not knowing about scroll bars
			document.getElementById('MainImage').style.width = ImageWidth+'px'; //set how much available space there is for the img
		}
	}else{
		document.getElementById('ContentSpcr').style.height = DivHeight+'px';
		setsession('spcrHeight',DivHeight);
	}
	
	
	count3 = 0-ImageWidth;
	
	
	if(ImageWidth>0){
		if(Type=='load'){
	
			document.getElementById('MainMenu').style.left = '0px';	
			init2();
			if(bgImg=='yes'){
				init3();
				//setTimeout(init3,500);
				runInit3='no';
			}
	
		}else if(Type=='Siteload'){
		
			init1();
			init2();
			init3();
			//setTimeout(init3,500);
			runInit3='no';
		
		}else if(Type=='resize'){
			if(runInit3=='yes'){
				if(bgImg=='yes'){
					init3();
					//setTimeout(init3,500);
					runInit3='no';
				}
			}
		}
		checkThis = 240 + mainContentWidth;
		if(ImageWidth>checkThis){
			if(runInit3=='yes'){
				if(bgImg=='yes'){
					init3();
					//setTimeout(init3,500);
					runInit3='no';
				}
			}
		}
		
	}else{
		document.getElementById('MainMenu').style.left = '0px';
		document.getElementById('MainContent').style.left = '240px';
		runInit3='yes';
	}
	document.getElementById('MainTour').style.width=(myWidth-240)+'px';
}

var count1 = -240;
	
function init1() {
	
	document.getElementById('MainMenu').style.left = count1+'px';
	
	width = 0;	
	
	if(count1 < (width-30)){
		count1 = count1+14;
		setTimeout(init1,2);
	}else if(count1 < (width-15)){
		count1 = count1+6;
		setTimeout(init1,2);
	}else if(count1 < width){
		count1 = count1+2;
		setTimeout(init1,2);
	}
}

var count2 = 0-mainContentWidth;
	
function init2() {
	
	if(countG<(1-(880-240))){
	
		document.getElementById('MainContent').style.left = count2+'px';
		
		width = 236;	
		
		if(count2 < (width-60)){
			count2 = count2+14;
			setTimeout(init2,2);
		}else if(count2 < (width-30)){
			count2 = count2+6;
			setTimeout(init2,2);
		}else if(count2 < width){
			count2 = count2+2;
			setTimeout(init2,2);
		}
	
	}
}
	
function init3() {
	
	if(countG<(1-(880-240))){
	
		document.getElementById('MainImage').style.left = count3+'px';
		
		width = 236+mainContentWidth;	
		
		
		if(count3 < (width-60)){
			count3 = count3+14;
			setTimeout(init3,2);
		}else if(count3 < (width-30)){
			count3 = count3+6;
			setTimeout(init3,2);
		}else if(count3 < width){
			count3 = count3+2;
			setTimeout(init3,2);
		}
	}
}
//tour funcs
function tour(tourId){
	
	var flashvars = {};
	var params = {};
	params.loop = "false";
	params.menu = "false";
	params.quality = "best";
	params.scale = "noscale";
	params.salign = "tl";
	params.wmode = "transparent";
	var attributes = {};
	attributes.id = "TourHolder";
	swfobject.embedSWF(pathRoot+"tour/"+pageTours[tourId], "TourHolder", "100%", "100%", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
	
	document.getElementById('MainContent').style.display='none';
	document.getElementById('MainImage').style.display='none';
	document.getElementById('MainTour').style.display='block';
}
function closeTour(){
	TheHtml = '<div id="TourHolder" style="width:100%; height:100%; position:absolute"></div><div style="width:150px; height:50px; position:absolute; right:0; top:10px; text-align:right;"><a href="#" onClick="closeTour(); return false" style="font-weight:bold; color:#FFF; text-decoration:none;">'+back_to_page_txt+'</a>&nbsp;&nbsp;&nbsp;&nbsp;</div>';
	
	document.getElementById('MainTour').innerHTML = TheHtml;
	document.getElementById('MainTour').style.display='none';
	document.getElementById('MainContent').style.display='block';
	document.getElementById('MainImage').style.display='block';
}

// Image rollovers
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function YY_checkform() { //v4.71
//copyright (c)1998,2002 Yaromat.com
  var a=YY_checkform.arguments,oo=true,v='',s='',err=false,r,o,at,o1,t,i,j,ma,rx,cd,cm,cy,dte,at;
  for (i=1; i<a.length;i=i+4){
    if (a[i+1].charAt(0)=='#'){r=true; a[i+1]=a[i+1].substring(1);}else{r=false}
    o=MM_findObj(a[i].replace(/\[\d+\]/ig,""));
    o1=MM_findObj(a[i+1].replace(/\[\d+\]/ig,""));
    v=o.value;t=a[i+2];
    if (o.type=='text'||o.type=='password'||o.type=='hidden'){
      if (r&&v.length==0){err=true}
      if (v.length>0)
      if (t==1){ //fromto
        ma=a[i+1].split('_');if(isNaN(v)||v<ma[0]/1||v > ma[1]/1){err=true}
      } else if (t==2){
        rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$");if(!rx.test(v))err=true;
      } else if (t==3){ // date
        ma=a[i+1].split("#");at=v.match(ma[0]);
        if(at){
          cd=(at[ma[1]])?at[ma[1]]:1;cm=at[ma[2]]-1;cy=at[ma[3]];
          dte=new Date(cy,cm,cd);
          if(dte.getFullYear()!=cy||dte.getDate()!=cd||dte.getMonth()!=cm){err=true};
        }else{err=true}
      } else if (t==4){ // time
        ma=a[i+1].split("#");at=v.match(ma[0]);if(!at){err=true}
      } else if (t==5){ // check this 2
            if(o1.length)o1=o1[a[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!o1.checked){err=true}
      } else if (t==6){ // the same
            if(v!=MM_findObj(a[i+1]).value){err=true}
      }
    } else
    if (!o.type&&o.length>0&&o[0].type=='radio'){
          at = a[i].match(/(.*)\[(\d+)\].*/i);
          o2=(o.length>1)?o[at[2]]:o;
      if (t==1&&o2&&o2.checked&&o1&&o1.value.length/1==0){err=true}
      if (t==2){
        oo=false;
        for(j=0;j<o.length;j++){oo=oo||o[j].checked}
        if(!oo){s+='* '+a[i+3]+'\n'}
      }
    } else if (o.type=='checkbox'){
      if((t==1&&o.checked==false)||(t==2&&o.checked&&o1&&o1.value.length/1==0)){err=true}
    } else if (o.type=='select-one'||o.type=='select-multiple'){
      if(t==1&&o.selectedIndex/1==0){err=true}
    }else if (o.type=='textarea'){
      if(v.length<a[i+1]){err=true}
    }
    if (err){s+='* '+a[i+3]+'\n'; err=false}
  }
  if (s!=''){alert('The required information is incomplete or contains errors:\t\t\t\t\t\n\n'+s)}
  document.MM_returnValue = (s=='');
}