var mojimage = 2;

function addPixInputORI() {
if (mojimage < 13) {
    document.getElementById('zepix').innerHTML += "<table width='590' border='0' cellpadding='0' cellspacing='0'><tr><td width='140' align=right>Bild " + mojimage + "</td><td width='450' ><INPUT name=uplFile" + mojimage + " id=uplFile" + mojimage + " TYPE='file' style='width: 250px;' class='anzeigen-input' ></td></tr></table>";
    mojimage += 1;
} else {
    document.getElementById('zepix').innerHTML += "<br />Maximal 10 Bilder erlaubt.";
    document.form.add.disabled=true;
}
}

function addPixInput() {
if (mojimage < 13) {
    document.getElementById('zepix').innerHTML += "<br><INPUT name=uplFile" + mojimage + " id=uplFile" + mojimage + " TYPE='file' style='width: 250px;' class='anzeigen-input' >";
    mojimage += 1;
} else {
    document.getElementById('zepix').innerHTML += "<br />Maximal 10 Bilder erlaubt.";
    document.form.add.disabled=true;
}
}


 function PopIt(url,title, w, h){
		window.open(url,title,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=' + w + ',height=' + h + '');
}
 

function printIns(id)
  {


	priIns=window.open('/printInserat.php?iid=' + id, 'Druckansicht',
	'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=800,height=800');
	priIns.focus();


  }



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

function tBrojac(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 tBrojacDIV(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) 
    field.value = field.value.substring(0, maxlimit);
else
    document.getElementById(cntfield).innerHTML = maxlimit - field.value.length;
}


function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
    field.value = field.value.substring(0, maxlimit);
else
    countfield.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);
 
 
 }
	
function doSlideLog(){
	timeToSlide = 15; // in milliseconds
	obj = document.getElementById('lgant');
	obj2 = document.getElementById('rgant');
	if(obj.style.display == "none"){ // si c hidden on fait le slide
			fillAjax(1, 'buitone');
		document.form.ilogger.value = 1;
		document.form.iregger.value = 0;
		obj2.style.display = "none";
		
		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";
	fillAjax(0, 'buitone');
		document.form.ilogger.value = 0;
		document.form.iregger.value = 0;
	}
}
	function doSlideReg(){
	timeToSlide = 15; // in milliseconds
	obj = document.getElementById('rgant');
	obj2 = document.getElementById('lgant');
	if(obj.style.display == "none"){ // si c hidden on fait le slide
		fillAjax(1, 'buitone');
			document.form.iregger.value = 1;
			document.form.ilogger.value = 0;
		obj2.style.display = "none";
		
		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";
	fillAjax(0, 'buitone');
	document.form.iregger.value = 0;
	document.form.ilogger.value = 0;	
	}
}

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
		if (id == "lgant" || id == "rgant") fillAjax();
		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"
	}
}


