
function upd(field, form){
	form.inOrt.value=form.inDisOrt.value ;
}

function check_wohngebiet(sel) {
	var f = sel.form;
	var opt = sel.options[sel.selectedIndex].value;
	if(opt=="1") {
		f.elements["inWohngebiet"].style.display = "inline";
	} else {
		f.elements["inWohngebiet"].style.display = "none";
		f.elements["inWohngebiet"].value = "0";
	}
	return true;
}



function doSlideSelHm(id, form){

   obj=document.getElementById(id);
   visible=(obj.style.display!="none")
   if (visible && form.inOrtsteil.value=="1" ) {
     obj.style.display="none";
     
   } else {
      obj.style.display="block";
     
   }
}



function doSlideSel(id, form){
	timeToSlide = 15; // in milliseconds
	obj = document.getElementById(id);
	//if(obj.style.display == "none"){ // si c hidden on fait le slide
	var divstl = new String();
	divstl=obj.style.visibility;
		if(divstl.toLowerCase() == "hidden" || divstl==""){
		if(form.inOrtsteil.value=="1"){ // if Inner Circle
			obj.style.visibility = "hidden";
			obj.style.display = "block";
			height = obj.offsetHeight;
			obj.style.height="0px";
			obj.style.visibility = "visible";
			pxPerLoop = height/timeToSlide;
			slide(obj,0,height,pxPerLoop);
		}else{
			obj.style.display = "none";
		}
	} else {
		obj.style.display = "none";
	}
	
	
}

function doSlide(id){
	timeToSlide = 15; // in milliseconds
	obj = document.getElementById(id);
	if(obj.style.display == "none"){ // si c hidden on fait le slide
		obj.style.visibility = "hidden";
		obj.style.display = "block";
		height = obj.offsetHeight;
		obj.style.height="0px";
		obj.style.visibility = "visible";
		pxPerLoop = height/timeToSlide;
		slide(obj,0,height,pxPerLoop);
	} else {
		obj.style.display = "none";
	}
}

function slide(obj,offset,full,px){
	if(offset < full){
		obj.style.height = offset+"px";
		offset=offset+px;
		setTimeout((function(){slide(obj,offset,full,px);}),1);
	} else {
		obj.style.height = "auto"; //Can be usefull in updated divs otherwise
//just use full+"px"
	}
}


function showPicture(uid, oid, img) {
	poppi=window.open('/slika.php?uid=' + uid + '&oid=' + oid + '&img=' + img, 'Detailansicht',
	'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=600,height=600');
	poppi.focus();
}

function printIns(id, insid) {
	priIns=window.open('/printInserat.php?id=' + id + '&insid=' + insid, 'Druckansicht',
	'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=600,height=800');
	priIns.focus();
}

function toggleBoxSearch(mkON, mkOFF) {
	if(document.layers)	   //NN4+
    {
       document.layers[mkON].visibility = "show";
		document.layers[mkOFF].visibility = "hide";}
    
	else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var objON = document.getElementById(mkON);
        objON.style.visibility = "visible";
        var objOFF = document.getElementById(mkOFF);
        objOFF.style.visibility = "hidden";
    }
    else if(document.all)	// IE 4
    {
        document.all[mkON].style.visibility = "visible";
		document.all[mkOFF].style.visibility = "hidden";
    } 
}
  

function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
   var obj = document.layers ? document.layers[szDivID] :
   document.getElementById ?  document.getElementById(szDivID).style :
   document.all[szDivID].style;
   obj.visibility = document.layers ? (iState ? "show" : "hide") :
   (iState ? "visible" : "hidden");
}
  



function addPixInput() {
	if (mojimage != 20) {
		document.getElementById('zepix').innerHTML += "<table width=100%><tr><td class=\"data_title\">Foto:</td><td class=\"data_content\"><INPUT NAME=zeUploadFile" + mojimage + " TYPE='file' ></td></tr></table>";
		mojimage += 1;
	} else {
		document.getElementById('zepix').innerHTML += "<table width=100%><tr><td>nur 20 Fotos erlaubt</td></tr></table>";
		document.form.add.disabled=true;
	}
}
function addGrInput() {
	if (mojgr != 20) {
		document.getElementById('zegr').innerHTML += "<table width=100%><tr><td class=\"data_title\">Grundriss:</td><td><INPUT NAME=zeUploadFileGr" + mojgr + " TYPE='file' ></td></tr></table>";
		mojgr += 1;
	} else {
		document.getElementById('zegr').innerHTML += "<table width=100%><tr><td>nur 20 Grundrisse erlaubt</td></tr></table>";
		document.form.add.disabled=true;
	}
}

function trim_separated_text(field, countfield, maxlimit, exclude) {
	wordcounter=0;
	for (x=0;x<field.value.length;x++) {
		if (field.value.charAt(x) == "," ) {
			wordcounter++;
		}
		if (field.value.charAt(x) == exclude ) {
			field.value = field.value.substring(0, x) + field.value.substring(x+1);
		}
		// Counts the spaces while ignoring double spaces, usually one in between each word.
		if (wordcounter > maxlimit) {
			field.value = field.value.substring(0, x);
		} else {
			countfield.value = maxlimit - wordcounter;
		}
	}
}

function trim_text(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
cntfield.value = maxlimit - field.value.length;
}

function gSearchFriendly(from,to) {
    	
         	var str = from.value.toLowerCase();
			
         	str = str.replace(/[\xc0-\xc5\xe0-\xe5\u0100-\u0105\u0386\u0391\u03ac\u03b1\u0410\u0430\u05d0]/g,'a');
         	str = str.replace(/[\xc8-\xcb\xe8-\xeb\u0116-\u011b\u0112\u0113\u0388\u0395\u03ad\u03b5\u042d\u044d]/g,'e');
         	str = str.replace(/[\xa1\xcc-\xcf\xec-\xef\u0128-\u012b\u012e-\u0132\u013a\u0389\u038a\u0390\u0397\u0399\u03aa\u03ae\u03af\u03b7\u03b9\u03ca\u0418\u0438]/g,'i');
         	str = str.replace(/[\xd2-\xd6\xd8\xf0\xf2-\xf6\xf8\u014d\u014c\u0150\u0151\u038c\u038f\u039f\u03a9\u03bf\u03c9\u03cc\u03ce\u041e\u043e]/g,'o');
         	str = str.replace(/[\xb5\xd9-\xdc\xf9-\xfc\u0171\u0173\u0168-\u0170\u0423\u0443]/g,'u');
         	str = str.replace(/[\u0392\u03b2\u05d1]/g,'b');
         	str = str.replace(/[\xc7\xe7\u0106-\u010d\u0147\u0148\u05da\u05db]/g,'c');
         	str = str.replace(/[\xd0\u010e-\u0111\u0394\u03b4\u05d3]/g,'d');
         	str = str.replace(/[\u03a6\u03c6]/g,'f');
         	str = str.replace(/[\u011c-\u0123\u0393\u03b3\u05d2]/g,'g');
         	str = str.replace(/[\u0124-\u0127\u05d4]/g,'h');
         	str = str.replace(/[\u0134\u0135]/g,'j');
         	str = str.replace(/[\u0136\u0137\u039a\u03ba\u05d7\u05e7]/g,'k');
         	str = str.replace(/[\u0139-\u013e\u0141\u0142\u039b\u03bb\u05dc]/g,'l');
         	str = str.replace(/[\u039c\u03bc\u05dd\u05de]/g,'m');
         	str = str.replace(/[\xd1\xf1\u0143-\u0148\u039d\u03bd\u05df\u05e0]/g,'n');
         	str = str.replace(/[\u0154-\u0159\u03a1\u03c1\u05e8]/g,'r');
         	str = str.replace(/[\u03a0\u03c0\u05e3\u05e4]/g,'p');
         	str = str.replace(/[\x8a\x9a\xdf\u015a-\u0161\u03a3\u03c2\u03c3\u05e1]/g,'s');
         	str = str.replace(/[\u0162-\u0167\u021a\u021b\u03a4\u03c4\u05d8\u05ea]/g,'t');
         	str = str.replace(/[\u05d5]/g,'v');
         	str = str.replace(/[\u03be\u039e]/g,'x');
         	str = str.replace(/[\x9f\xdd\xfd\xff\u038e\u03a5\u03ab\u03b0\u03c5\u03cb\u03cd\u05d9]/g,'y');
         	str = str.replace(/[\x9e\u0179-\u017e\u0396\u03b6\u05d6]/g,'z');
         	str = str.replace(/[\u05e2]/g,'aa');
         	str = str.replace(/[\xc6\xe6]/g,'ae');
         	str = str.replace(/[\u03a7\u03c7]/g,'ch');
         	str = str.replace(/[\u039e\u03be\u0152\u0153]/g,'oe');
         	str = str.replace(/[\xde\xfe\u0398\u03b8]/g,'th');
         	str = str.replace(/[\u05e5\u05e6]/g,'ts');
         	str = str.replace(/[\u03c8\u03a8\u0398\u03b8]/g,'ps');
         	str = str.replace(/[\u05e9]/g,'sh');
         	str = str.replace(/[\xdf]/g,'sz');
         	str = str.replace(/[^a-z 0-9]+/g,'');
         	str = str.replace(/\s+/g, "-");
         	to.value = str;
      	
   	}
 
 function goNewsAndCount(from,to, cnt, max){
		
		gSearchFriendly(from,to);
		//tBrojac(from,cnt,max);
		//changed1 (from);
 
 
 }
	
