//<!-- 

//teaser
function teaserOver(jahre, obj) {
	obj.style.backgroundImage = 'url(lib/img/teaser_grey2_'+jahre+'.gif)' ;
}
function teaserOut(jahre, obj) {
	obj.style.backgroundImage = 'url(lib/img/teaser_grey1_'+jahre+'.gif)' ;
	window.setTimeout("hideInfoMenu()", 3000);
}

//register
var bolInfoMenuOver = false ;
function infoMenuOver(bolOver) {
	bolInfoMenuOver = bolOver ;
}
function showInfoMenu() {
	var objDivStyle = document.getElementById('infomenu').style ;
	objDivStyle.display = 'block' ;
	
	objDivStyle.left = (tempX+10)+'px' ;
	objDivStyle.top =(tempY)+'px' ;
}

function hideInfoMenu() {
	//alert('bolInfoMenuOver: ' + bolInfoMenuOver);
	if(!bolInfoMenuOver) {
		try {
			document.getElementById('infomenu').style.display = 'none' ;	
		}catch(e){}
	} else {
		window.setTimeout("hideInfoMenu()", 3000);
	}
}


//Temporary variables to hold mouse x-y pos.s
var tempX = 0 ;
var tempY = 0 ;

try {
	// If NS -- that is, !IE -- then set up for mouse capture
	document.captureEvents(Event.MOUSEMOVE)
} catch(e) {}

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;


// Main function to retrieve mouse x-y pos.s
function getMouseXY(e) {
  try { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } catch(ex) {  // grab the x-y pos.s if browser is NS
    if(e.pageX) tempX = e.pageX
    if(e.pageY) tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  
  return true
}

//FAQ
function showFAQ( index ) {
	var objFaq = document.getElementById('faq_'+index) ;
	if( objFaq.style.display == 'none' ) {
		objFaq.style.display = 'block' ;
	} else {
		objFaq.style.display = 'none' ;
	}
}
function showAnswer( index, subindex ) {
	var objFaq = document.getElementById('faq_'+index+'_'+subindex) ;
	var objPlusMinusImg = document.getElementById('plusminus_'+index+'_'+subindex) ;
	if( objFaq.style.display == 'none' ) {
		objFaq.style.display = 'block' ;
		objPlusMinusImg.src = 'lib/img/minus.gif' ;
	} else {
		objFaq.style.display = 'none' ;
		objPlusMinusImg.src = 'lib/img/plus.gif' ;
	}
}

varLeft = 0;
varTop = 0;

function setFontSize(size) {
	var link = document.location.href ;
	
	//alert(link);
	
	if( document.location.search != '' ) {
		link += '&fontsize='+size ;
	} else {
		link += '?fontsize='+size ;
	}
	
	document.location.href = link ;
}

function showImageBig(imageObject,img) {
	//getPosition(imageObject) ;
	var imageMouseoverObject = document.getElementById('imageMouseover');
	imageMouseoverObject.onload = function() { 	
		var imageMouseoverObject = document.getElementById('imageMouseover');
		//höhe zentrieren
		imageMouseoverObject.style.top = (( getBodyHeight() - imageMouseoverObject.height) / 2 ) + 'px' ;
	};
	imageMouseoverObject.src = img ;
	imageMouseoverObject.style.display = 'block' ;
	imageMouseoverObject.style.left = varLeft - 150 + 'px' ;
}

function hideImageBig(path) {
	var imageMouseoverObject = document.getElementById('imageMouseover');
	imageMouseoverObject.src = path+'spacer.gif' ;
	imageMouseoverObject.style.display = 'none' ;
}

function getPosition(e) {   
	varTop = 0 ;
	varLeft = 0 ;
	
	if (!e) { e = window.event; }   
	
	var myTarget = e.currentTarget;   
	
	if (!myTarget) {    myTarget = e.srcElement;   }   
	else if (myTarget == "undefined") {    myTarget = e.srcElement;   } 
	
	while(myTarget!= document.body) {      
		//varTop += myTarget.offsetTop;      
		varLeft += myTarget.offsetLeft;      
		myTarget = myTarget.offsetParent;   
	}
} 

function getBodyHeight() {
  if( window.innerHeight && window.scrollMaxY ) {// Firefox  
		pageHeight = window.innerHeight + window.scrollMaxY;
	} else if( document.body.scrollHeight > document.body.offsetHeight ) { // all but Explorer Mac
		pageHeight = document.body.scrollHeight;
	}	else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		pageHeight = document.body.offsetHeight + document.body.offsetTop; 
	}
	return pageHeight ;
}

function getScrollHeight() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return scrOfY ; //[ scrOfX, scrOfY ];
}

function doOnload() {	
	doOnloadSpecial();
}

function doOnloadSpecial() {
	//dummy: do nothing... will be overwritten in page
}
/*
function changeSearch( objSelect ) {
	if( objSelect.selectedIndex == 0 ) {
		document.forms.suche.action = 'search.php' ;
	} else {
		document.forms.suche.action = 'galerie.php' ;
	}
}*/

function showEignungscheck() {
	displayContactForm('big') ;
	setContentAJAX('kontakt', libpath+'/include/eignungscheck.php') ;
	
}

function showContactForm() {
	displayContactForm('small') ;
	setContentAJAX('kontakt', libpath+'/include/contact_form.php') ;
}

function showContactFormShopUsed($ShopUsedId, ProductTitle, ShopUsedEmail, pid) {
	displayContactForm('small') ;
	setContentAJAX('kontakt', libpath+'/include/contact_form_shop_used.php', 'shopUsedId', $ShopUsedId, 'productTitle', ProductTitle, 'shopUsedEmail', ShopUsedEmail, 'pid', pid ) ;
}

function showContactFormLeasing(type) {
	displayContactForm('small') ;
	setContentAJAX('kontakt', libpath+'/include/contact_form_leasing.php?type='+type) ;
}
function showContactFormFactoring(type) {
	displayContactForm('small') ;
	setContentAJAX('kontakt', libpath+'/include/contact_form_factoring.php?type='+type) ;
}

function displayContactForm( size ) {
	var objDiv = document.getElementById('kontakt') ;
	//alert(objDiv);
	if( size != null && size=='big' ) {
		objDiv.style.width = '570px' ;
		objDiv.style.height = '670px' ;
		objDiv.style.left = '350px' ;
		objDiv.style.backgroundImage = 'url('+libpath+'/image/back_eigungscheck.png)';
	} else {
		objDiv.style.width = '500px' ;
		objDiv.style.height = '670px' ;
		objDiv.style.left = '500px' ;
		objDiv.style.backgroundImage = 'url('+libpath+'/image/back_kontakt_500.png)';
	}
	objDiv.style.display = 'block' ;
	objDiv.style.top	= getScrollHeight() + 30 + 'px' ;
	
}
function hideContactForm() {
	document.getElementById('kontakt').style.display = 'none' ;
}

function setContentAJAX(divId, page) {
	var data = '' ;
	//alert(arguments.length);
	
	if(arguments.length>2) {
		try {
			for(var i=2; i<arguments.length; i=i+2) {
				data += arguments[i]+'='+arguments[i+1]+'&' ;
			}
		} catch(e) {
			alert(e);
		}
	}
	//alert(page) ;
	new Ajax.Updater(divId, page, 
		{
			method: 'post',
			parameters: data
		}
	);
}

var subnavheadid ;
function showSubNavTop(id) {
	hideSubNavTop() ;
	var objDiv = document.getElementById('subnav'+id) ;
	if(objDiv!=null) {
		objDiv.style.display = 'block';
		subnavheadid = 'subnav' + id ;
	}
}

function hideSubNavTop() {
	if(subnavheadid != null) {
		var objDivStyle = document.getElementById(subnavheadid).style ;
		objDivStyle.display = 'none';
	}
}

//Image Menu
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_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_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 searchFocus( objField ) {
	//alert( objField.value );
	if( objField.value == 'Ihre PLZ' ) {
		objField.value 			= '' ;
		objField.style.color 	= '#9a9a9a' ;
	} else {
		objField.style.color 	= '#000000' ;
	}		
}

function searchBlur( objField ) {
	//alert( objField.value );
	if( objField.value == '' ) {
		objField.value 			= 'Ihre PLZ' ;
		objField.style.color 	= '#9a9a9a' ;
	} else {
		objField.style.color 	= '#000000' ;
	}
}

function nurZahlen(el) {
  var val = el.value.replace(/[^\,^,\d]/g, ''); //
  el.value = val;
}

//Menu
var actPageId = 0 ;
function showMenu(pid, obj) {
	el = 'sub' + pid ;
	objSubMenu = document.getElementById(el) ;
	objSubMenu.style.display = "block";
	
	if( pid != actPageId) {
		window.setTimeout('hideMenuTimeOut()', 10) ;
	}
}

function hideMenu(pid) {
	el = 'sub' + pid ;
	document.getElementById(el).style.display = "none";
	actPageId = 0 ;
}

function hideMenuTimeOut() {
	try {
		el = 'sub' + actPageId ;
		document.getElementById(el).style.display = "none";
	} catch(e) {}
}

function loadLink(parameter, valueNew) {
	link   	= document.location.href.substring(0,document.location.href.indexOf('?') ) ;
	link 	+= '?' ;
	if(document.location.search.length > 0) {
      var get_param_str = document.location.search.substring(1, location.search.length);
      var get_params = get_param_str.split("&");
      for(i = 0; i < get_params.length; i++) {
         var key_value = get_params[i].split("=");
         if(key_value.length == 2) {
            var key = key_value[0];
            var value = key_value[1];
            if(key!=parameter) link 	+= key+'='+value+'&' ;
         }
      }      
   }
    link 	+= parameter+'='+valueNew ;
	//alert(link);
	document.location.href = link ;
}
// -->
