var valide=true;
var toppos=(screen.availHeight-200-100)/2;
var leftpos=(screen.availWidth-200)/2;
var defaultstate='105799';
var student=614793;
var teaching=10001095;
var traning=10001084;
var toppos=(screen.availHeight-200-100)/2;
var leftpos=(screen.availWidth-200)/2;
var divcor=false;
var error=false;
var text='';
var url="http://"+location.host;
var req = new Array();
var activeImage;
var win;
var openwin;
var clicked=false;
var x=0;
var selid='';

//var Countrys = new Object();
var Regions = new Array();
var enableCats;

function getElById(id){
	return(document.getElementById==null) ?
   (document.all==null ? null : document.all[id]) : document.getElementById(id);
}


function setHoverMode(id,mode){
	if(getElById(id)){
		getElById(id).style.visibility=mode;
	}
	
}


function setButtonMode(id,obj){
	getElById(id).disabled=!obj.checked;
	
}

function setFormAction(action,field,form){
	getElById(field).value=action;
	document.forms[form].submit();
}


function resetForm(name){
	document.forms[name].reset();
}

function PrevStep(){
	getElById('step').value=getElById('step').value-1;
	setFormAction('prev','action','register');
}

function NextStep(){
	step=getElById('step').value;
	if(ValidateRegister(parseInt(step))){
		setFormAction('next','action','register');
	}
}

function Finalize(){
	setFormAction('finalize','action','register');
}

function Upload(){
	if(ValidateImageData()){
		setFormAction('upload','action','register');
	}
	
}

function ValidateRegister(step){
	
	/*try{*/
		switch(step){

			case 5:
			   return ValidateDrivingData();
			break;

			case 3:
			 return ValidateViewData();
			break;
			case 2:
			  return ValidateJobData();
			break;
			
			case 1:
		
			   
			   return ValidatePersonData(); 
			break;
			case 4:
			case 6:
			case 7:
			case 8:
			default:
			  return true;
			break;			
		}
		
		
	/*}
	catch(Error){
	alert(Error.message)
	}*/
	
}


function checkLogin(obj){
	var email=getElById('email');
	//var user=getElById('user');
	var passwd=getElById('passwd');
	var x=0;
  if(IsEmptyString(email.value)){
  	error=true;
   setNodeText('E_EMAIL_EMPTY');

  }
  /*if(IsEmptyString(user.value)){
  	error=true;
     setNodeText('E_USER_EMPTY');

  }*/
  if(IsEmptyString(passwd.value)){
  	error=true;
    setNodeText('E_PASS_EMPTY');

  } 

 
  if(error){
  	pos=getPosition(obj);
  	SetErrorDiv('Fehler','block',pos.y);
  	error=false;
  	return;
  }
  setFormAction('login','loginaction','login');


}	
	



function checkLostPass(){
	text='';
	var pin=getElById('pin');
	//var user=getElById('username');
  if(IsEmptyString(pin.value)){
  	error=true;
  	setNodeText('E_PIN');
  }
   getElById('action').value='apply';
  document.forms['account'].submit();
  /*if(IsEmptyString(user.value)){
  	error=true;
  	setNodeText('E_USERNAME');
  }*/

  /*if(error){
  	SetErrorDiv('Fehler','block',240);
  	return;
  }*/
 
}	

function checkUserdata(){
	/*valide=true;

	if(getElById('sex').value==0){

		setNodeText('E_SEX');
		valide=false;
	
	}

	if(IsEmptyString(getElById('first').value)){

		setNodeText('E_FIRST');
		valide=false;
	
	}
	if(IsEmptyString(getElById('last').value)){
		setNodeText('E_LAST');
		valide=false;
		
	}	
	if(!validdate(getElById('day').value,getElById('mon').value,getElById('year').value)){
		setNodeText('E_BIRTHDAY');
		valide=false;
		
	}


	if(getElById('state').value==0){
		setNodeText('E_STATE');
		valide=false;
	
	}	
	
	if(IsEmptyString(getElById('svr').value)){
		setNodeText('E_SVR');
		valide=false;
		
	}	
	
	if(!valide){
  	SetErrorDiv('Fehler','block',280);
  	return false;
	}*/
	setFormAction('save','action','account');		
	
}

function checkPasswd(){
	text='';
	var passerror=false;
	var oldpass=getElById('oldpass');
	var newpass=getElById('newpass');
	var newpass2=getElById('newpass2');		
	if(IsEmptyString(oldpass.value)){
	  	error=true;
	  	setNodeText('E_OLDPASS');

	}
	if(IsEmptyString(newpass.value)){
	  	error=true;
	  	passerror=true;
	  	setNodeText('E_NEWPASS');

	}	
	if(IsEmptyString(newpass2.value)){
	  	error=true;
	  	passerror=true;
	  	setNodeText('E_NEWPASS2');
	 
	}
	if(!passerror && !StringIsEqual(newpass.value,newpass2.value)){
	  	error=true;
	  	passerror=true;
	  	setNodeText('E_PASSERROR');
	 
	}
  if(error){
 		SetErrorDiv('Fehler','block',240);
  	return;
  }
  setFormAction('save','accountaction','account');
	
}

function checkCommunication(){
	text='';
	var email=getElById('contact_email');
	if(IsEmptyString(getElById('contact_mobile').value)){
		setNodeText('E_MOBILE');
		valide=false;
			
	}		
	if(!CheckEmail(email.value)){
	  	valide=false;

			setNodeText('E_EMAIL');	
	}
  if(!valide){
  	SetErrorDiv('Fehler','block',240);
  	text='';
  	return;
  }	
	setFormAction('save','accountaction','account');	
	
}
function checkCode(formname,action){
	text='';
	var code=getElById('code');
	if(IsEmptyString(code.value)){
	  	error=true;
	  	setNodeText('E_CODEEMPTY');	

	}	
  if(error){
  	SetErrorDiv('Fehler','block',240);
  	text='';
  	return;
  }
	setFormAction('confirm','accountaction','account');
		
}

function checkAddress(){
	valide=true;
	if(IsEmptyString(getElById('street').value)){
		setNodeText('E_STREET');
		valide=false;
			
	}	
	if(IsEmptyString(getElById('number').value)){
		setNodeText('E_NUMBER');
		valide=false;
		
	}		
	if(IsEmptyString(getElById('plz').value)){
		setNodeText('E_ZIP');
		valide=false;
		
	}	
	if(IsEmptyString(getElById('city').value)){
		setNodeText('E_CITY');
		valide=false;
			
	}	
  if(!valide){
  	SetErrorDiv('Fehler','block',240);
  	text='';
  	return;
  }	
	setFormAction('save','accountaction','account');		
}

function checkViewData(){
	if(!ValidateViewData()){
		return false;
	}
	setFormAction('save','accountaction','account');
}

function checkGeneralData(){
	valide=true;
	boxvalid=false;
	if(getElById('resent').value==0){
		setNodeText('E_JOB');
		valide=false;
	
	}	
	var v=getElById('resent').value;
	if((v==student || v==teaching || v==traning)&& IsEmptyString(getElById('studies').value)){
		setNodeText('E_STUDIES');
		valide=false;
			
	}
	var box=document.getElementsByName('type[]');

	if(getElById('licens').value==1){
  	for(i=0;i<box.length;i++){
  		if(box[i].checked==true){
  			boxvalid=true;
  			break;
  		}
  	}		
		if(!boxvalid){
			setNodeText('E_LICENS');
			valide=false;
		}
	}
	else if(!error){
		for(i=0;i<box.length;i++){
			box[i].checked=false;
		}
	}
	if(!valide){
  	SetErrorDiv('Fehler','block',240);
  	return false;
	}
	setFormAction('save','accountaction','account');
}


function checkBank(){
	valide=true;

	if(IsEmptyString(getElById('accountid').value)){

		setNodeText('E_BANKACCOUNT');
		valide=false;
	
	}
	if(IsEmptyString(getElById('bank').value)){
		setNodeText('E_BANKBLZ');
		valide=false;
		
	}	
	if(!valide){
  	SetErrorDiv('Fehler','block',240);
  	return false;
	}
	setFormAction('save','accountaction','account');	
	
	
}

function openBankChooser(){
	if(win){
		win.close();
	}
	var para='toolbar=no,resizable=no,top=50,left=200,scrollbars=no,width=500,height=600';
	win=window.open('/bankchooser?popup=1','Bankensuche',para);
  if(win){
  	win.focus();

  }
	return ;
}

function setPage(page,pageid,action,form,actionid){
	getElById(pageid).value=page;
	setFormAction(action,form,actionid);
}

function setStyle(row,mode){

	id=row.getAttribute('id');
	if(id!=getElById('object').value){
	for(i=0;i < row.childNodes.length;i++){
			td=row.childNodes[i];
		  td.style.backgroundColor=mode=='over'?'#e8e8e8':'#ffffff'
	}
	}
}

function selectItem(id){
	old=getElById('object').value;
	getElById('object').value=id;
	if(old!=''){
		oldrow=getElById(old);
		setStyle(oldrow,'out');
	}
	
	row=getElById(id);
	for(i=0;i < row.childNodes.length;i++){
    td=row.childNodes[i];
    td.style.backgroundColor='#999999'		
	}
	getElById('bankapply').disabled=false;
}


function applyBank(){
	valide=true;
	id=getElById('object').value;
	if(id==''){
		setNodeText('E_BANKBLZ');
  	SetErrorDiv('Fehler','block',280);
  	return false;		
	}
	row=getElById(id);
	var blz=row.childNodes[0].innerHTML;
	var name=row.childNodes[1].innerHTML;
	if(opener && opener.getElById){
		opener.getElById('blz').value=blz;
		opener.getElById('name').value=name;
		opener.getElById('bank').value=id;
		self.close();
	}
}

function ValidatePersonData(){
	valide=true;

	if(getElById('sex').value==0){

		setNodeText('E_SEX');
		valide=false;
	
	}

	if(IsEmptyString(getElById('first').value)){

		setNodeText('E_FIRST');
		valide=false;
	
	}
	if(IsEmptyString(getElById('last').value)){
		setNodeText('E_LAST');
		valide=false;
		
	}	
	if(!validdate(getElById('day').value,getElById('mon').value,getElById('year').value)){
		setNodeText('E_BIRTHDAY');
		valide=false;
		
	}
	if(IsEmptyString(getElById('street').value)){
		setNodeText('E_STREET');
		valide=false;
			
	}	
	if(IsEmptyString(getElById('number').value)){
		setNodeText('E_NUMBER');
		valide=false;
		
	}		
	if(IsEmptyString(getElById('plz').value)){
		setNodeText('E_ZIP');
		valide=false;
		
	}	
	if(IsEmptyString(getElById('city').value)){
		setNodeText('E_CITY');
		valide=false;
			
	}
	if(IsEmptyString(getElById('mobile').value)){
		setNodeText('E_MOBILE');
		valide=false;
			
	}	
	if(!CheckEmail(getElById('email').value)){
		setNodeText('E_EMAIL');
		valide=false;
	
	}	
	if(getElById('state').value==0){
		setNodeText('E_STATE');
		valide=false;
	
	}	
	
	if(IsEmptyString(getElById('svr').value)){
		setNodeText('E_SVR');
		valide=false;
		
	}	
	
	if(!valide){
  	SetErrorDiv('Fehler','block',280);
  	return false;
	}
	return true;							
}

function ValidateJobData(){
	valide=true;


	if(getElById('resent').value==0){
		setNodeText('E_JOB');
		valide=false;
	
	}	
	var v=getElById('resent').value;
	if((v==student || v==teaching || v==traning)&& IsEmptyString(getElById('studies').value)){
		setNodeText('E_STUDIES');
		valide=false;
			
	}
	if(!valide){
  	SetErrorDiv('Fehler','block',240);
  	return false;
	}
	return true;		
}

function ValidateViewData(){
	valide=true;

	
	if(IsEmptyString(getElById('height').value)){
		setNodeText('E_SIZEEMPTY');
		valide=false;	
	}	
	if(!IsEmptyString(getElById('height').value) && !IsIntegerString(getElById('height').value)){
		setNodeText('E_SIZEERROR');
		valide=false;	
	} 	
	if(IsEmptyString(getElById('weight').value)){
		setNodeText('E_HEIGHTEMPTY');
		valide=false;
	}	
	if(!IsEmptyString(getElById('weight').value) && !IsFloatString(getElById('weight').value)){
		setNodeText('E_HEIGHTERROR');
		valide=false;	
	}			
	if(!valide){
  	SetErrorDiv('Fehler','block',240);
  	return false;
	}
	return true;
}

function ValidateImageData(){
	valide=true;

	if(IsEmptyString(getElById('image').value)){
		setNodeText('E_IMAGEEMPTY');
		valide=false;	
		
	}
	if(!valide){
  	SetErrorDiv('Fehler','block',240);
  	return false;
	}
	return true;	
}

function ValidateDrivingData(){
	valide=false;

	var box=document.getElementsByName('type[]');

	if(getElById('licens').value==1){
  	for(i=0;i<box.length;i++){
  		if(box[i].checked==true){
  			valide=true;
  			break;
  		}
  	}		
		if(!valide){
			setNodeText('E_LICENS');;
		}
	}
	else{
		valide=true;
		for(i=0;i<box.length;i++){
			box[i].checked=false;
		}
	}
	if(!valide){
  	SetErrorDiv('Fehler','block',240);
  	return false;
	}
	return true;		
	
}

function CheckLicens(obj){
	var box=document.getElementsByName('type[]');
	for(i=0;i<box.length;i++){
		box[i].disabled=obj.value==2?true:false;
	}
}

function CheckState(obj){
	setSelectMode('workpermit',obj.value==defaultstate);
}

function setSelectMode(id,mode){
	getElById(id).disabled=mode;
}

function CheckEmail(email){
	return !email.match(/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,5}$/i)?false:true;
}

function IsEmptyString(string){

	return string.search(/[\w]{1,}/) == -1 ? true :false;
}

function StringIsEqual(string1,string2){
	return string1==string2;
	
}

function IsIntegerString(string){
  return string==parseInt(string)?true:false;

	
}

function IsFloatString(string){
 string=string.replace(/,/,'.');
 return string==parseFloat(string)?true:false;
	
}
function validdate(day,month,year){
	
	if(day.length==0 || month.length==0  || year.length==0 ){
		return false;
	}
	if(year.length < 4){
		return false;		
	}	
	if(!checkMonthDays(parseInt(day),month,year)){
		return false;		
	}
	return true;
}
function daysInFebruary (year){
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function checkMonthDays (day,month,year){
  
	var DayInMonth= new Array();
	DayInMonth[1]=31;
  DayInMonth[2]=daysInFebruary(year);
  DayInMonth[3]=31;
  DayInMonth[4]=30;
  DayInMonth[5]=31;
  DayInMonth[6]=30;
  DayInMonth[7]=31;
  DayInMonth[8]=31;
  DayInMonth[9]=30;
  DayInMonth[10]=31;
  DayInMonth[11]=30;
  DayInMonth[12]=31;
	DayInMonth['01']=31;
  DayInMonth['02']=daysInFebruary(year);
  DayInMonth['03']=31;
  DayInMonth['04']=30;
  DayInMonth['05']=31;
  DayInMonth['06']=30;
  DayInMonth['07']=31;
  DayInMonth['08']=31;
  DayInMonth['09']=30;  

  return day <= DayInMonth[month];
}


function setFocus(id){
	if(getElById(id)){
		getElById(id).focus();
	}
}

function ReloadPage(path){
	if(path && path!=''){
		document.location.href=path;
	}
}

function SetEmpty(id){
	elem=getElById(id);

	try{
		 elem.innerHTML='';
	}
	catch(Error){
		alert(Error.message)
	}	
}


function setNodeText(str){
	text+=(text.length>0?'|':'')+str
}

function viewMode(element,mode){
 element.style.display = mode;	
}
function callErrorXML(nodename,divid,number,search,replace){
  if(window.XMLHttpRequest){
  	req[number]=new XMLHttpRequest();
  }
  else if(window.ActiveXObject){
  	req[number]=new ActiveXObject("Microsoft.XMLHTTP");
  }

  if(req[number]){
  	var jetzt = new Date();
  	var path="Error.php?file=&nodes="+nodename+'&ser='+(jetzt.getTime());
    
    req[number].onreadystatechange=function(){
    	if(req[number].readyState==4){
       renderErrorXML(divid,number,search,replace);

    	}
    }
    req[number].open("GET",path,true);
    req[number].send(null);
  }
}
function renderErrorXML(id,number,search,replace){
    if(req[number].status==200){
    	div=getElById(id);
    	text=req[number].responseText
      if(search && search!='undefined' && replace && replace!='undefined'){
       	text = text.replace(search, replace);

      }

			div.innerHTML=text;
  viewMode(getElById('overlay'),'block');
	viewMode(getElById('overlaybox'),'block');			
			syncIframe(getElById('overlaybox'),getElById('overlayshim'));
				
			
    }
  

}

function SetErrorDiv(header,mode,top,search,replace){
	if(!divcor){
		getElById('overlay').style.height=document.all?document.body.offsetHeight:window.innerHeight;
		divcor=true;
	}
	getElById('overlayhead').innerHTML=header;
	callErrorXML(text,'overlaycont',x,search,replace);
	x++;
		
  setPos(getElById('overlaybox'),top);
	
}

function ResetErrorDiv(){
	text='';
	getElById('overlayhead').innerHTML='';
	getElById('overlaycont').innerHTML='';
	viewMode(getElById('overlay'),'none');
	viewMode(getElById('overlaybox'),'none');
	viewMode(getElById('overlayshim'),'none');
	clicked=false;
	error=false;

}

function syncIframe(elem,ielem){

	
	ielem.style.width = elem.offsetWidth;
	ielem.style.height = elem.offsetHeight;
	ielem.style.top = elem.style.top;
	ielem.style.left = elem.style.left;
	viewMode(ielem,'block');

}
function setPos(objRef,top) {

   try{ 
	 	var leftpos = (document.all)?(document.body.offsetWidth-200)/2:(window.innerWidth-200)/2;

		var objW = parseInt(objRef.offsetWidth);

    objRef.style.left = (leftpos-(objW/2))+"px";
	
		objRef.style.top =top+"px";
   

   }
   catch(Error){alert(Error.message)}

}

function getPosition(element){
/* der Aufruf dieser Funktion ermittelt die absoluten Koordinaten
   des Objekts element */

  var elem=element,tagname="",x=0,y=0;
  
/* solange elem ein Objekt ist und die Eigenschaft offsetTop enthaelt
   wird diese Schleife fuer das Element und all seine Offset-Eltern ausgefuehrt */
  while ((typeof(elem)=="object")&&(typeof(elem.tagName)!="undefined")){
    
  	y+=elem.offsetTop; 	
    x+=elem.offsetLeft;    /* Offset des jeweiligen Elements addieren */
    tagname=elem.tagName.toUpperCase(); /* tag-Name ermitteln, Grossbuchstaben */
   

/* wenn beim Body-tag angekommen elem fuer Abbruch auf 0 setzen */
    if (tagname=="BODY"){
      elem=0;
    }
/* wenn elem ein Objekt ist und offsetParent enthaelt
   Offset-Elternelement ermitteln */
    if (typeof(elem)=="object"){
      if (typeof(elem.offsetParent)=="object"){
        elem=elem.offsetParent;
      }
    }
  }

/* Objekt mit x und y zurueckgeben */
  position=new Object();
  position.x=x;
  position.y=y;
  return position;
}
function openImage(id){
if(win && win.open){
		win.close();
	}
	aid=getElById('activeItem').value;
	//var link=url+'/image.php?id='+aid;
	var link=url+'/'+aid+'?popup=true&immo='+id;

	var param='top=10,left=10,width=550,height=550,scrollbars=no';
	win= window.open(link,'Bilder',param);
 if(win)
	win.focus();
}

function popUpImage(id){
if(win && win.open){
		win.close();
	}

	var link=url+'/'+id+'?popup=true';

	var param='top=10,left=10,width=550,height=550,scrollbars=no';
	win= window.open(link,'Bilder',param);
 if(win)
	win.focus();
}



function swapImage(id){
	var img=getElById('bigone');
	var imgtitle=getElById('Imagetitle');
	aid=getElById('activeItem').value;
	var div=getElById('imgdiv_'+id);
	var adiv=getElById('imgdiv_'+aid);
	div.className='smallImageactive links';
	adiv.className='smallImage links';
	getElById('activeItem').value=id;
	path=getElById('Path_'+id).value;
	title=getElById('Title_'+id).value;
	if(imgtitle && title!=''){
		imgtitle.innerHTML=title;
	}
	img.src=path;
	img.setAttribute('alt',title);
	img.setAttribute('title',title);
	layer=getElById('resize');
	if(layer){
	switch(getElById('PopUp_'+id).value){
		case 'true':
		 layer.style.visibility='visible';
		break;
		default:
		layer.style.visibility='hidden';
		break;
	}
	}
	
}

function rezizePage(width){
	
	var div=getElById('popup');
	var height=div.offsetHeight;

	window.resizeTo(width, height);
}

function unsubsricbe(){
 var box=document.getElementsByName('unsubscribe[]');
 var valid=false;
		for(i=0;i<box.length;i++){
			if(box[i].checked){
				valid=true;
			}
		}
	if(!valid){
		obj=getElById('remove');
		setNodeText('E_UNSUB');
		pos=getPosition(obj);
		SetErrorDiv('Fehler','block',pos.y-100);
		return;
	}	
	setFormAction('unsubscribe','subsribeaction','subscribe');
}



function createBill(){
	
	
}



/*********************		Detailsuche		*********************/

function getCheckedRegions(id){		// prüft ob es schon selektierte Bezirke gibt 

	var abox=document.getElementsByName(id+'[]');
	if(abox && typeof(abox)=="object"){

		for(x=0;x<abox.length;x++){
			tmp=new Object();
			l=Regions.length;
		/*	Regions[l]=1;*/
			
			tmp.id=abox[x].value
			tmp.checked=abox[x].checked==true;
			
			Regions[l]=abox[x];
			
		}
	}
}


function getCountry(){	// lädt alle Bundesländer des gewählten Staates

	var str='';
	var set='';
	var sel=getElById('state');
	CallCountries(sel.value);
}


function getDistrict(){

	var str='';
	var set='';
	var box=document.getElementsByName('country[]');
	
	
	for(i=0;i<box.length;i++){
		if(box[i].checked){
			str+=(str!=''?',':'')+box[i].value;
			getCheckedRegions(box[i].value);
			
		}
	}
	enableCat();
	CallDistricts(str);
}


function CallCountries(str){
	
  if(window.XMLHttpRequest){
  	req[0]=new XMLHttpRequest();
  }
  else if(window.ActiveXObject){
  	req[0]=new ActiveXObject("Microsoft.XMLHTTP");
  }

  if(req[0]){
  	var jetzt = new Date();
		//path=url+"?id=11329&mode=country&ser="+(jetzt.getTime());
  	var path="/loadregion?mode=country&ser="+(jetzt.getTime());
    var params="state="+str;
    req[0].open("POST",path,true);
		req[0].setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		req[0].setRequestHeader("Content-length", params.length);
		req[0].setRequestHeader("Connection", "close");    
    req[0].onreadystatechange=function(){
    	if(req[0].readyState==4){
       renderDivXML('Countries',0,setRegionSelect);

    	}
    }
    
    req[0].send(params);
  }	
	
}


function CallDistricts(str){
	
  if(window.XMLHttpRequest){
  	req[1]=new XMLHttpRequest();
  }
  else if(window.ActiveXObject){
  	req[1]=new ActiveXObject("Microsoft.XMLHTTP");
  }

  if(req[1]){
  	var jetzt = new Date();

  	var path="/loadregion?mode=district&ser="+(jetzt.getTime());
    
    var params="countrys="+str;
    req[1].open("POST",path,true);
		req[1].setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		req[1].setRequestHeader("Content-length", params.length);
		req[1].setRequestHeader("Connection", "close");    
    req[1].onreadystatechange=function(){
    	if(req[1].readyState==4){
       renderDivXML('District',1,setRegionSelect);

    	}
    }

    
    req[1].send(params);
  }	
	
	
}


function renderDivXML(id,num,func){

  if(req[num].status==200){
    	div=getElById(id);
    	text=req[num].responseText
      obj=getElById(id);
      obj.innerHTML=text;
      func();

				
			
   }	
	 
}

function setRegionSelect(){
	for(z=0;z<Regions.length;z++){
		b=Regions[z]
  	if(b.checked==true){
			if(getElById(b.id)){
     		bo=getElById(b.id);
     		bo.checked=true;
			}
    }
  }	
	Regions= new Array();	
}
	



function selAll(ckbox,ck){	// selektiert alle Bezirke
	
	var box=document.getElementsByName(ckbox);
	for(i=0;i<box.length;i++){
		box[i].checked=ck;
		
	}
	enableCat();
	
}


function getCat(ckbox,ck){	// 
	enableCat();
}


function enableCat(){
	
	var box=document.getElementsByName('country[]');
	
	for(i=0;i<box.length;i++){
		if(box[i].checked){
			var abox=document.getElementsByName(box[i].value+'[]');
			var enable_search = true;
			for(x=0;x<abox.length;x++){
				if(abox[x].checked){
					var enableCats = true;
					var cat=document.getElementsByName('objectcat[]');
					for(c=0;c<cat.length;c++){
						if(cat[c].checked){
							var enablePrice = true;
						}
					}
					
				}
			}
			
		}
	}
	var search = false;
	var profile = false;
	var cat=document.getElementsByName('objectcat[]');
	var price=document.getElementsByName('pricecat[]');
	var s_from=getElById('s_from');		// input s_from
	var s_to=getElById('s_to');		// input s_to
	var p_from=getElById('p_from');		// input p_from
	var p_to=getElById('p_to');		// input p_to
	if(getElById('search')){
		 search=getElById('search');		// button search
	}
	if(getElById('profile')){
		 search=getElById('profile');		// button search
	}
	if(enable_search){
		
		
		if(search){
			search.disabled=false;
		}
		if(profile){
			profile.disabled=false;
		}
	}
	else{
		
		
		
		if(search){
			search.disabled=true;
		}
		if(profile){
			profile.disabled=true;
		}
	}
	
	
		
}

function enabledelete(){
	
	
	var del=document.getElementsByName('del[]');
	for(i=0;i<del.length;i++){
		if(del[i].checked){
			
			var enable_delete = true;
		}
	}
	
	var delbut = getElById('delbut');
	if(enable_delete){
		delbut.disabled = false;
	}
	else{
		delbut.disabled = true;
	}
}


function sendSearch(){		// sendet die Suchanfrage // wurde durch POST ersetzt
	
	var countrys = '';
	var districts = '';
	var categorys = '';
	var prices = '';
	
	var box=document.getElementsByName('country[]');
	
	for(i=0;i<box.length;i++){
		if(box[i].checked){
			
			countrys+=(countrys!=''?',':'')+box[i].value;
			
			var abox=document.getElementsByName(box[i].value+'[]');
			
			for(x=0;x<abox.length;x++){
				if(abox[x].checked){
					
					districts+=(districts!=''?',':'')+abox[x].value;
					
				}
			}
			
		}
	}
	
	var cat=document.getElementsByName('objectcat[]');
	var price=document.getElementsByName('pricecat[]');
	
	for(c=0;c<cat.length;c++){
		if(cat[c].checked){
			categorys+=(categorys!=''?',':'')+cat[c].value;
		}
	}
	
	for(p=0;p<price.length;p++){
		if(price[p].checked){
			prices+=(prices!=''?',':'')+price[p].value;
		}
	}
	
	if(countrys){
		countrys='countries='+countrys;
	}
	
	if(districts){
		districts='&districts='+'dis_'+districts;
	}
	
	if(categorys){
		categorys='&categories='+categorys;
	}
	
	if(prices){
		prices='&prices='+prices;
	}
	
	
	document.location.href = 'http://pbe.2web.at/immobilielist?'+countrys+districts+categorys+prices;
}


function  applyProfile(action,mode){
	var s_from = getElById('s_from');
	var s_to = getElById('s_to');
	var p_from = getElById('p_from');
	var p_to = getElById('p_to');
	error=false;	
	
	if(s_from.value!='' && !IsIntegerString(s_from.value)){
		alert('Bitte geben Sie eine ganze posititve Zahl für Fläche von ein!');
		error=true;
	}
	
	if(s_to.value!='' && !IsIntegerString(s_to.value)){
		alert('Bitte geben Sie eine ganze posititve Zahl für Fläche bis ein!');
		error=true;
	}
	
	if(p_from.value!='' && !IsIntegerString(p_from.value)){
		alert('Bitte geben Sie eine ganze posititve Zahl für Preis von ein!');
		error=true;
	}
	
	if(p_to.value!='' && !IsIntegerString(p_to.value)){
		alert('Bitte geben Sie eine ganze posititve Zahl für Preis bis ein!');
		error=true;
	}
	if(error){
		return false;
	}
	
	if(getElById('profile_name').value==''){
		alert('Bitte geben Sie einen Profilnamen ein!');
		error=true;
	}
	
	if(!error){
		setFormAction(action,mode,'immoprofile');
	}
	
}

function IsIntegerString(string){
  return string==parseInt(string)?true:false;

	
}

function IsFloatString(string){
 string=string.replace(/,/,'.');
 return string==parseFloat(string)?true:false;
	
}