// Parameter der Excel-Datei fuer Initialisierung Datenstruktur
function lautspr(preis,best_no,marke,type,pn,imp,spl,dtot,daus,fmin,fmax,xmax,vcl,fcl3,vbr,fbr3,kenn,beschreibung_de,beschreibung_en,beschreibung_fr,link_bild,link_de,link_en,link_fr)
{
this.preis=preis;
this.best_no=best_no;
this.marke=marke;
this.type=type;
this.pn=pn; //power
this.imp=imp;
this.spl=spl;
this.dtot=dtot;
this.daus=daus;
this.fmin=fmin;
this.fmax=fmax;
this.xmax=xmax;
this.vcl=vcl;
this.fcl3=fcl3;
this.vbr=vbr;
this.fbr3=fbr3;
this.kenn=kenn;
this.beschreibung_de=beschreibung_de;
this.beschreibung_en=beschreibung_en;
this.beschreibung_fr=beschreibung_fr;
this.link_bild=link_bild;
this.link_de=link_de;
this.link_en=link_en;
this.link_fr=link_fr;
}

function such_lautspr(kdurch_min,kdurch_max,schdurch_min,schdurch_max,einb_min,einb_max,freq_min,freq_max,spl,imp,preis_min,preis_max,chassistyp,marke,leistung,abst_min,abst_max,cbbr,vol_min,vol_max)
{
this.kdurch_min=kdurch_min;
this.kdurch_max=kdurch_max;
this.schdurch_min=schdurch_min;
this.schdurch_max=schdurch_max;
this.einb_min=einb_min;
this.einb_max=einb_max;
this.freq_min=freq_min;
this.freq_max=freq_max;
this.spl=spl;
this.vol_min=vol_min;
this.vol_max=vol_max;
this.cbbr=cbbr;
this.abst_min=abst_min;
this.abst_max=abst_max;
this.imp=imp;
this.preis_min=preis_min;
this.preis_max=preis_max;
this.marke=marke;

this.leistung=leistung;

temp=chassistyp.split(";");
if(temp.length==2&&temp[1]=="")
{
	temp=new Array();
}
if(temp.length==1)
{
	temp=new Array();
}
this.chassistyp=temp;
}

// alle Daten der Tabelle einlesen
function suche_initialisiere()
{
	zeilen = allData.split("|");
	temp=new Array();
	array=new Array();
	for(i=0;i<zeilen.length;i++)
	{
		array=zeilen[i].split(";");
		if(array[1]!=""&&array.length>1)
		{
			while(array.length<24)  //zeilen auffüllen
			{
				array.push("");
			
			}
			
			array[3]=array[3].replace(/§§/g, ";");  //die §§ wieder durch ; ersetzen
			if(array[1]!="")
			{
				// temp.push alle Daten
				temp.push(new lautspr(array[0], array[1], array[2], array[3], array[4], array[5], array[6], array[7], array[8], array[9], array[10], array[11], array[12], array[13], array[14], array[15], array[16], array[17], array[18], array[19], array[20], array[21], array[22], array[23], array[24]));
			}
		}
	}
	zeilen=temp;
}

// Sucht nach Lautsprecher mit besonderen Daten
function suche(lautspr_vorschlag)
{
	temp=zeilen;
	temp2=new Array();
	if(lautspr_vorschlag.chassistyp.length>0)
	{
		temp2=new Array();
		for(i=0;i<temp.length;i++)
		{
			for(j=0;j<lautspr_vorschlag.chassistyp.length;j++)
			{
				if(temp[i].kenn==lautspr_vorschlag.chassistyp[j])
				{
					temp2.push(temp[i]);
					break;
				}
			}
		}
		temp=temp2;//nur rausgesuchte behalten, temp2 wird das nächste mal wieder geleert
	}

	if(lautspr_vorschlag.leistung!=0)
	{
		temp2=new Array();
		for(i=0;i<temp.length;i++)
		{
                        // Leistungsangabe als xx/yyy
			var PN_index = temp[i].pn.indexOf("\/");
                        if (PN_index > -1)
                        {
				var Pnenn = temp[i].pn.substr(0,PN_index);
				if(Pnenn>=lautspr_vorschlag.leistung)
				{
					temp2.push(temp[i]);
				}
                        }
                        else
                        {
				if(temp[i].pn>=lautspr_vorschlag.leistung)
				{
					temp2.push(temp[i]);
				}
                        }
		}
		temp=temp2;//nur rausgesuchte behalten, temp2 wird das nächste mal wieder geleert	
	}
	if(!(lautspr_vorschlag.kdurch_min==0||lautspr_vorschlag.kdurch_min==""))
	{
		temp2=new Array();
		for(i=0;i<temp.length;i++)
		{
			if(temp[i].dtot>=lautspr_vorschlag.kdurch_min)
			{
				temp2.push(temp[i]);
			}
		}
		temp=temp2;//nur rausgesuchte behalten, temp2 wird das nächste mal wieder geleert
	}
	if(!(lautspr_vorschlag.kdurch_max==0||lautspr_vorschlag.kdurch_max==""))
	{
		temp2=new Array();
		for(i=0;i<temp.length;i++)
		{
			if(temp[i].dtot<=lautspr_vorschlag.kdurch_max)
			{
				temp2.push(temp[i]);
			}
		}
		temp=temp2;//nur rausgesuchte behalten, temp2 wird das nächste mal wieder geleert
	}	
	if(!(lautspr_vorschlag.schdurch_min==0||lautspr_vorschlag.schdurch_min==""))
	{
		temp2=new Array();
		for(i=0;i<temp.length;i++)
		{
			if(temp[i].daus>=lautspr_vorschlag.schdurch_min)
			{
				temp2.push(temp[i]);
			}
		}
		temp=temp2;//nur rausgesuchte behalten, temp2 wird das nächste mal wieder geleert
	}
	if(!(lautspr_vorschlag.schdurch_max==0||lautspr_vorschlag.schdurch_max==""))
	{
		temp2=new Array();
		for(i=0;i<temp.length;i++)
		{
			if(temp[i].daus<=lautspr_vorschlag.schdurch_max)
			{
				temp2.push(temp[i]);
			}
		}
		temp=temp2;//nur rausgesuchte behalten, temp2 wird das nächste mal wieder geleert
	}
	if(!(lautspr_vorschlag.vol_min==0||lautspr_vorschlag.vol_min==""||lautspr_vorschlag.cbbr!="cb"))
	{
		temp2=new Array();
		for(i=0;i<temp.length;i++)
		{
			if(temp[i].vcl>=lautspr_vorschlag.vol_min)
			{
				temp2.push(temp[i]);
			}
		}
		temp=temp2;//nur rausgesuchte behalten, temp2 wird das nächste mal wieder geleert
	}
	if(!(lautspr_vorschlag.vol_max==0||lautspr_vorschlag.vol_max==""||lautspr_vorschlag.cbbr!="cb"))
	{
		temp2=new Array();
		for(i=0;i<temp.length;i++)
		{
			if(temp[i].vcl<=lautspr_vorschlag.vol_max)
			{
				temp2.push(temp[i]);
			}
		}
		temp=temp2;//nur rausgesuchte behalten, temp2 wird das nächste mal wieder geleert
	}
	if(!(lautspr_vorschlag.vol_min==0||lautspr_vorschlag.vol_min==""||lautspr_vorschlag.cbbr!="br"))
	{
		temp2=new Array();
		for(i=0;i<temp.length;i++)
		{
			if(temp[i].vbr>=lautspr_vorschlag.vol_min)
			{
				temp2.push(temp[i]);
			}
		}
		temp=temp2;//nur rausgesuchte behalten, temp2 wird das nächste mal wieder geleert
	}
	if(!(lautspr_vorschlag.vol_max==0||lautspr_vorschlag.vol_max==""||lautspr_vorschlag.cbbr!="br"))
	{
		temp2=new Array();
		for(i=0;i<temp.length;i++)
		{
			if(temp[i].vbr<=lautspr_vorschlag.vol_max)
			{
				temp2.push(temp[i]);
			}
		}
		temp=temp2;//nur rausgesuchte behalten, temp2 wird das nächste mal wieder geleert
	}
	if(!(lautspr_vorschlag.abst_min==0||lautspr_vorschlag.abst_min==""||lautspr_vorschlag.cbbr!="cb"))
	{
		temp2=new Array();
		for(i=0;i<temp.length;i++)
		{
			if(temp[i].fcl3>=lautspr_vorschlag.abst_min)
			{
				temp2.push(temp[i]);
			}
		}
		temp=temp2;//nur rausgesuchte behalten, temp2 wird das nächste mal wieder geleert
	}	
	if(!(lautspr_vorschlag.abst_max==0||lautspr_vorschlag.abst_max==""||lautspr_vorschlag.cbbr!="cb"))
	{
		temp2=new Array();
		for(i=0;i<temp.length;i++)
		{
			if(temp[i].fcl3<=lautspr_vorschlag.abst_max)
			{
				temp2.push(temp[i]);
			}
		}
	temp=temp2;//nur rausgesuchte behalten, temp2 wird das nächste mal wieder geleert
	}	
	if(!(lautspr_vorschlag.abst_min==0||lautspr_vorschlag.abst_min==""||lautspr_vorschlag.cbbr!="br"))
	{
		temp2=new Array();
		for(i=0;i<temp.length;i++)
		{
			if(temp[i].fbr3>=lautspr_vorschlag.abst_min)
			{
				temp2.push(temp[i]);
			}
		}
		temp=temp2;//nur rausgesuchte behalten, temp2 wird das nächste mal wieder geleert
	}	
	if(!(lautspr_vorschlag.abst_max==0||lautspr_vorschlag.abst_max==""||lautspr_vorschlag.cbbr!="br"))
	{
		temp2=new Array();
		for(i=0;i<temp.length;i++)
		{
			if(temp[i].fbr3<=lautspr_vorschlag.abst_max)
			{
				temp2.push(temp[i]);
			}
		}
	temp=temp2;//nur rausgesuchte behalten, temp2 wird das nächste mal wieder geleert
	}	
	if(!(lautspr_vorschlag.freq_min==0||lautspr_vorschlag.freq_min==""))
	{
		temp2=new Array();
		for(i=0;i<temp.length;i++)
		{
			if(temp[i].fmin<=lautspr_vorschlag.freq_min)
			{
				temp2.push(temp[i]);
			}
		}
		temp=temp2;//nur rausgesuchte behalten, temp2 wird das nächste mal wieder geleert
	}	
	if(!(lautspr_vorschlag.freq_max==0||lautspr_vorschlag.freq_max==""))
	{
		temp2=new Array();
		for(i=0;i<temp.length;i++)
		{
			if(temp[i].fmax>=lautspr_vorschlag.freq_max)
			{
				temp2.push(temp[i]);
			}
		}
		temp=temp2;//nur rausgesuchte behalten, temp2 wird das nächste mal wieder geleert
	}	
	if(!(lautspr_vorschlag.preis_min==0||lautspr_vorschlag.preis_min==""))
	{
		temp2=new Array();
		for(i=0;i<temp.length;i++)
		{
			if(temp[i].preis>=lautspr_vorschlag.preis_min)
			{
				temp2.push(temp[i]);
			}
		}
		temp=temp2;//nur rausgesuchte behalten, temp2 wird das nächste mal wieder geleert
	}	
	if(!(lautspr_vorschlag.preis_max==0||lautspr_vorschlag.preis_max==""))
	{
		temp2=new Array();
		for(i=0;i<temp.length;i++)
		{
			if(temp[i].preis<=lautspr_vorschlag.preis_max)
			{
				temp2.push(temp[i]);
			}
		}
		temp=temp2;//nur rausgesuchte behalten, temp2 wird das nächste mal wieder geleert
	}	
	if(!(lautspr_vorschlag.spl==0||lautspr_vorschlag.spl==""))
	{
		temp2=new Array();
		for(i=0;i<temp.length;i++)
		{
			if(temp[i].spl>=lautspr_vorschlag.spl)
			{
				temp2.push(temp[i]);
			}
		}
		temp=temp2;//nur rausgesuchte behalten, temp2 wird das nächste mal wieder geleert
	}	
	if(!(lautspr_vorschlag.imp==0||lautspr_vorschlag.imp==""))
	{
		temp2=new Array();
		for(i=0;i<temp.length;i++)
		{
			if(temp[i].imp==lautspr_vorschlag.imp)
			{
				temp2.push(temp[i]);
			}
		}
		temp=temp2;//nur rausgesuchte behalten, temp2 wird das nächste mal wieder geleert
	}	
	if(lautspr_vorschlag.marke!="")
	{
		temp2=new Array();
		woerter=lautspr_vorschlag.marke.split(" ");
		for(i=0;i<temp.length;i++)
		{
			for(j=0;j<woerter.length;j++)
			{
				if(temp[i].marke.search(new RegExp(woerter[j], "i"))!=-1)
				{
					temp2.push(temp[i]);
					break;
				}
			}
		}
		temp=temp2;//nur rausgesuchte behalten, temp2 wird das nächste mal wieder geleert
	}	return temp;
}