// JavaScript Document
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];}
}

/*
********* layer  - Object start
*/

function lay (id,idvon,idbis,einheit,valuemax,idselect,valuemin){
 // OK alles
 this.einheit = einheit;
 // id der Von & bis Felder
 this.idbis = idbis;
 this.idvon = idvon;
 // Einschränkugen von Value Werten 
 this.valuemax = valuemax;
 this.valuemin = valuemin;

 this.constructor = lay;
 this.show = false;
 this.id = id;
 this.idselect =idselect;
 
 this.namevon = "";
 this.namebis = "";
 
 this.ebenemenge = 10;
 this.vonbis = Array(2);
 this.ebene = Array (this.ebenemenge);
 this.changevar = false;
 this.submit_doit = false;
 this.is_click = false;
 this.closecoutervalue=0;

 // OK Var
 this.vonzw =0;
 this.biszw =0;
 
 if (document.getElementById(this.idvon)) {
    this.vonzw = document.getElementById(this.idvon).value;
    } 
 if (document.getElementById(this.idbis)) {
    this.biszw = document.getElementById(this.idbis).value;
    } 

 for (var x=0; x<this.ebenemenge; x++)
      {
      this.ebene[x] = false;
       }	
             
 this.keypress = function (id) {
//	this.debug('j');
 	}


 this.ifclose = function () {
  this.hidden();
  if (this.vonzw!=this.get_inputin_value("js"+this.idvon)) {
 	this.set_inputin_value("js"+this.idvon,this.vonzw);
	this.changevar=true;
	this.submit_doit=false;
	}
  if (this.biszw!=this.get_inputin_value("js"+this.idbis)) {
  	this.set_inputin_value("js"+this.idbis,this.biszw);
	this.changevar=true;
	this.submit_doit=false;
	};  
 }

 

 this.changeselect = function () {
 trj = "";
 noid = "";
 jaid = "";
 trn = "";
 ne = 0;
 ja = 0; 
 a = this.idselect.split(',');
 for( i=0; i<a.length; i++)  { 
    if (this.get_inputin_select(a[i])) {
  	ja=ja+1;
  	jaid=jaid+trj+a[i];
  	trj=',';
  	}
  	else
  	{
  	ne=ne+1;
  	noid=noid+trn+a[i];
  	trn=',';
  	}
     }

  if (ne==0) {
  	this.innerformnselect ("all");
//	this.debug('all '+ne+' ');
  	}
     else
	{     
  	this.innerformnselect (jaid);
//	this.debug('zahl '+ne+' '+jaid+' ');
     	}
 }

this.get_inputin_select = function (idin) {
 back = "1";
 if (document.getElementById(idin)) {
    back = document.getElementById(idin).checked;
    }
 return back;
 }
 
 this.formatZahl = function (zahl, k, fix) { 
    if(!k) k = 0; 
    var neu = ''; 
    // Runden 
    var f = Math.pow(10, k); 
    zahl = '' + parseInt( zahl * f + (.5 * (zahl > 0 ? 1 : -1)) ) / f ; 
    // Komma ermittlen 
    var idx = zahl.indexOf('.'); 
    // fehlende Nullen einf?gen 
    if(fix) 
    	{ 
         zahl += (idx == -1 ? '.' : '' ) 
         + f.toString().substring(1); 
    	} 
    // Nachkommastellen ermittlen 
    idx = zahl.indexOf('.'); 
    if( idx == -1) idx = zahl.length; 
    else neu = ',' + zahl.substr(idx + 1, k); 
  
    // Tausendertrennzeichen 
    while(idx > 0) 
    	{ 
        if(idx - 3 > 0) 
        neu = '.' + zahl.substring( idx - 3, idx) + neu; 
        else 
        neu = zahl.substring(0, idx) + neu; 
        idx -= 3; 
    	} 
    if (neu==0) {neu="";};
    return neu; 
 } 

 this.makezahl = function (za) {
 back=0;
 back1 = za.replace (/^\s+/, '').replace (/\s+$/, '');
  back2 = back1.replace (/\./g, '');
 back = parseInt(back2);
 return back;
 }

 this.testvonbis = function (id1,id2) {
 this.vonbis(0) = 1;
 this.vonbis(1) = 2;
 }

 this.debug = function (text) {
 this.set_outhtml ('proto',this.get_outhtml('proto')+text);
 }

 this.get_inputin_value = function (idin) {
 back = "";
 if (document.getElementById(idin)) {
    back = document.getElementById(idin).value;
    } 
 return back;
 }
 
 this.set_inputin_value = function (idin,wert) {
 back = false;
 if (document.getElementById(idin)) {
    document.getElementById(idin).value = wert;
    back=true;
    }
 return back;
 }

 this.set_outhtml = function (idout,html) {
 if (document.getElementById(idout)) {
	document.getElementById(idout).innerHTML = html; 
 	}
 }

 this.get_outhtml = function (idout) {
 if (document.getElementById(idout)) {
	return document.getElementById(idout).innerHTML; 
 	}
 }

 this.change = function (idvon,idbis,idtextvalue) {
 textout=false;
 von = 0;
 bis = 0;
 von=this.makezahl(this.get_inputin_value("jsin"+this.idvon));
 bis=this.makezahl(this.get_inputin_value("jsin"+this.idbis));
 vonf=this.formatZahl(von);
 bisf=this.formatZahl(bis);
 if (von>=this.valuemin && von<this.valuemax) {
 	this.set_inputin_value("jsin"+this.idvon,vonf);
	}
 	else
 	{ 	
 	if (von>this.valuemax)	{
 		this.set_inputin_value("jsin"+this.idvon,this.valuemax-1);
  	 	vonf = this.formatZahl(this.valuemax-1);
  	 	von = this.valuemax-1;
 		} 
 		else
 		{
 		if (von>1 && von<this.valuemin)	{
 		   this.set_inputin_value("jsin"+this.idvon,this.valuemin);
  	 	   vonf = this.formatZahl(this.valuemin);
  	 	   von = this.valuemin;
 		} else
 			{
 		  this.set_inputin_value("jsin"+this.idvon,'');
		   }
		}
	}
 if (bis>0 && bis<=this.valuemax) {
 	this.set_inputin_value("jsin"+this.idbis,bisf);
	}
 	else
 	{	
	if (bis>this.valuemax)	{
 		this.set_inputin_value("jsin"+this.idbis,this.valuemax);
  	 	bisf = this.formatZahl(this.valuemax);
  	 	bis = this.valuemax;
		}
		else
		{
 		this.set_inputin_value("jsin"+this.idbis,'');
		}
	}

 if (von>0 && bis>0 && bis<=von)
 	{
 	bis="";
 	}
 if (!von>0) {von=""};
 if (!bis>0) {bis=""};
 if (von>0 && bis>0) {
 	textout=true;
 	}
 if ( von>0 & !textout) {
 	textout=true;
 	}
 if (bis>0 && !textout) {
 	textout=true;
 	}
 if (!textout) {
 	} 
 this.innerformvonbis(this.idvon,von,this.idbis,bis);
 }
 
 this.toggle = function()  {
  if (this.get_inputin_value('winopen')!='no'){
  	this.message_out("Eingabge<br/>Bestätigen");
	return;   	
   	} 	   
  this.is_click=false;
  if (this.show) {
       this.hidden();
       }
       else {
       this.visible();
       }
  }
 this.message_out = function (text) {
 errorid = this.get_inputin_value('winopen');
 this.set_outhtml (errorid,text);
 } 
 
 this.message_in = function (text) {
 this.set_outhtml (this.id+'_error',text);
 } 
 
  
 this.innerformnselect = function (selectvalue) {
// this.debug(selectvalue+'<br/> ');
 if ((selectvalue=='all') &&  ''==this.get_inputin_value("js"+this.idbis)) {
	selectvalue = this.get_inputin_value("js"+this.idbis);
 	this.biszw = selectvalue;
   	this.is_click = false;
    	this.changevar = false;
 	} 
 if (this.biszw!=selectvalue) {
 	this.biszw = selectvalue;
   	this.is_click = true;
    	this.changevar = true;
 	}
// this.debug(selectvalue+'<br/> ');
 this.sub_aktiv_select (true); 
 }
  

  this.innerformvonbis = function (namevon,vnamevon,namebis,vnamebis) {
  if (this.vonzw!=vnamevon) {
	this.vonzw=vnamevon;
 	this.changevar=true;
	};
  if (this.biszw!=vnamebis) {
	this.biszw=vnamebis;
 	this.changevar=true;
	}; 
   this.sub_aktiv (true); 
  }

 this.sub_aktiv_select = function(va) {
 if (this.biszw!=this.get_inputin_value("js"+this.idbis)) {
 	document.getElementById("submit"+this.id).className="fubu01";
 	this.set_inputin_value('winopen',this.id+'_error'); 	   
 	}
 	else
 	{
/*
 	document.getElementById("submit"+this.id).className="fubu01de";
    	if (this.get_inputin_value('winopen') == this.id+'_error') { 	   
 	   this.set_inputin_value('winopen','no'); 
 	   this.message_in ('');	   
 	   }
*/
 	}

 } 

 this.sub_aktiv = function(va) {
 if (this.vonzw!=this.get_inputin_value("js"+this.idvon)  || this.biszw!=this.get_inputin_value("js"+this.idbis)) {
 	document.getElementById("submit"+this.id).className="fubu01";
    	this.set_inputin_value('winopen',this.id+'_error'); 	   
 	}
 	else
 	{
/*
   	document.getElementById("submit"+this.id).className="fubu01de";
   	if (this.get_inputin_value('winopen')==this.id+'_error') { 	   
 	   this.set_inputin_value('winopen','no'); 
    	   this.message_in ('');	   	   
 	   }
*/
 	}
 } 
 
 this.submit = function() {
// this.debug('submit='+this.vonzw+' '+this.biszw+'<br/> ');
 if (this.vonzw=='0') {this.vonzw='';};
 if (this.biszw=='0') {this.biszw='';};
// this.debug('submit='+this.vonzw+' '+this.biszw+'<br/> ');
 this.changevar=false;
 if (this.get_inputin_value('winopen') == this.id+'_error') { 	   
    this.set_inputin_value('winopen','no'); 
    this.message_in ('');	   
    }
   if (this.vonzw!=this.get_inputin_value("js"+this.idvon)) {
 	this.set_inputin_value("js"+this.idvon,this.vonzw);
	this.changevar=true;
	this.submit_doit=false;
	this.is_click=false;

	}
  if (this.biszw!=this.get_inputin_value("js"+this.idbis)) {
  	this.set_inputin_value("js"+this.idbis,this.biszw);
	this.changevar=true;
	this.submit_doit=false;

	};
 this.sub_aktiv (this.changevar);  
 if (this.changevar && !this.submit_doit)	
 	{
	document.filter02.submit();
	this.submit_doit=true;
	this.set_outhtml(this.id+'_textmenge',"Loading");
	}
// this.debug('submit='+this.vonzw+' '+this.biszw+'<br/> ');

 }
  
  this.hidden = function () {
   document.getElementById(this.id).style.visibility = 'hidden';
    for (var x=0; x< this.ebenemenge; x++)
      {
      this.ebene[x] = false;
       }
   this.show = false;
  }
  
 this.visible = function () {
   this.show = true;
   document.getElementById(this.id).style.visibility = 'visible';

  }

 this.autoclose = function (wert) {
 if (wert) {
  this.is_click=false;
   }
   else {
   this.is_click=true;
   }
 }

 this.ifhidden = function () {
  hidden=true;
  for (var x=0; x<this.ebenemenge; x++)
      {
      if (this.ebene[x]) {
         hidden = false;     
  	 } 
       }
  if (hidden && !this.is_click) {
  	this.hidden(this.id);	
  	}
  } 
  
  this.clearebene = function (nr) {
  if (nr<this.ebenemenge) {
     this.ebene[nr] = false;  
     }
  } 
 
 this.ifopen = function () {
  if (document.getElementById(this.id).style.visibility == 'hidden') {
  	 back=true;
  	 }
  	 else
  	 { 
  	 back=false;
  	 }
  return back;
 }
 
 this.message = function (text) {
//  this.set_outhtml (this.id+'_error',text);
 }


 this.setebene = function (nr) {
 if (nr<this.ebenemenge) {
    this.ebene[nr] = true;
    }
 }
 
  this.settextvonbis = function (textid,textmenge,formid1,formid2) {
  document.getElementById('pr_layer_textvalue').innerHTML = document.getElementById('jsinfiprvon').selectedIndex+" bis "+document.getElementById('jsinfiprbis').selectedIndex;

 }



 }
/* 
************ Layer - objekt ende
*/




//-------------------------------- Formulare


/**
 * toggle FAQ Items
 *
 * @param id 		the id of the FAQ item to hide or show
 * @param single	true to show only one item at a time, false the open as many as you want
 */
function toggleFaq(id, single, hash) {	
		
	if(single) {
		//show only one Q+A at a time
		toggleAll(false, hash);		
		showHideFaq(id, true, hash);

	}
	else {
		//open as many Q+A as you like		
		if(document.getElementById('irfaq_a_'+id+'_'+hash).style.display == 'none') {
			showHideFaq(id, true, hash);
		}
		else {
			showHideFaq(id, false, hash);
		}			
	}	
 }

/**
 * shows or hides a FAQ item at a time depending on the given status
 *
 * @param id 		the id of the FAQ item to hide or show
 * @param status	true to show the item, false to hide it

 */
function showHideFaq(id, status, hash) {
	var faq_id = 'irfaq_a_'+id+'_'+hash; //answer
	var pm_id  = 'irfaq_pm_'+id+'_'+hash; // plus/minus icon
	
	if(status) {
		document.getElementById(faq_id).style.display = 'inline';
//		document.getElementById(pm_id).src = tx_irfaq_pi1_iconMinus;
	}
	else {
		document.getElementById(faq_id).style.display = 'none';	
//		document.getElementById(pm_id).src = tx_irfaq_pi1_iconPlus;
	}

}

/**
 * shows or hides all FAQ items with one click
 *
 * @param mode	true to show the items, false to hide them
 */
 function toggleAll(mode, hash, count) {
	for(i = 0; i < count; i++) {
		showHideFaq(i+1, mode, hash);
	}				
 }



/* 
************ Timer - Ausblenden
*/


function schlaf_layer () {
 schlafzimmer02.ifhidden();
 }

function bade_layer () {
 badezimmer02.ifhidden();
 }

function ka_layer () {
 kategorie.ifhidden();
 }


function pr_layer () {
 preis.ifhidden();
 }

function pr_terrasse () {
 terrasse.ifhidden();
 }



function pr_grundstueck () {
 grundstueck.ifhidden();
 }

function pr_wohnflaeche () {
 wohnflaeche.ifhidden();
 }

function catid_layer () {
 catid.ifhidden();
 }
 
function landid_layer () {
 landid.ifhidden();
 }
 
function typeid_layer () {
 typeid.ifhidden();
 }
 
