function nav2(ziel){
   window.location.href=ziel;
}

function sendmail2(ziel) {
      fenster=window.open(ziel,"version","resizable=yes,location=no,menubar=no,titlebar=no,toolbar=no,scrollbars=yes,width=450,height=270");
      if (fenster.closed==false) fenster.focus();
}

var ns4up = (document.layers) ? 1 : 0
var ie4up = (document.all) ? 1 : 0
var xsize = screen.width
var ysize = screen.height
var breite=550
var hoehe=420
var xpos=(xsize-breite)/2
var ypos=(ysize-hoehe)/2

function insert_tag(trg,typ) {
      f2=window.open("insert_tag.php?typ="+typ+"&trg="+trg,"insert_tag","resizable=yes,location=no,menubar=no,directories=no,titlebar=no,toolbar=no,status=no,scrollbars=yes,width="+breite+",height="+hoehe+",screenX="+xpos+",screenY="+ypos+",top="+ypos+",left="+xpos);
      if (f2.closed==false) f2.focus();
}

function pagelimit(ziel, rr){
 with(document.form1){
    if(limit.value!=0 && limit.value!='')
       window.location.href=ziel+rr+'limit='+limit.value;
 }
}

function recalc(ziel){
 //with(document.form1){
    if(document.getElementById("pers").value!=0 && document.getElementById("pers").value!='')
       window.location.href=ziel+'&pers='+document.getElementById("pers").value+'#rez_self';
 //}
}

function transform(wert, stellen, positiv, ort){
with (ort){
  if (wert.value != 0){
    wert.value = wert.value.replace(/,/,".");
    wert.value = parseFloat(wert.value);
    wert.value *= stellen;
    wert.value = Math.round(wert.value);
    wert.value /= stellen;
    if (isNaN(wert.value)) wert.value = '';
      if(wert.value <0 && positiv == 1) wert.value = '';
  }
}
}

function voten(ziel,g) {
 
 if(ziel!=0 && ziel!='' && (g==1 || g==2 || g==3)) {
	 
   if(g==1) {var remote_form='form_v'; var ergebnis='vote'; }
   else if(g==3) {var remote_form='form_st'; var ergebnis='vote_st'; }
   else     {var remote_form='form1';  var ergebnis='vote_rez'; }
   
   with(eval('document.'+remote_form)){
     var ab=0;
     var antw = eval(ergebnis).length;
     for (var c = 0; c < antw; c++){
        if(eval(ergebnis)[c].checked == true)  ab=eval(ergebnis)[c].value;
     }
     if(ab) window.location.href=ziel+'&'+ergebnis+'='+ab;
   }
 }
}

function setPointer(theRow, thePointerColor, rahmencolor, minus_cell, minus_anfang) {
    if (minus_anfang !='') var anfang=minus_anfang; else var anfang=0;
    if (thePointerColor == '' || typeof(theRow.style) == 'undefined')
        return false;
    if (typeof(document.getElementsByTagName) != 'undefined')
        var theCells = theRow.getElementsByTagName('td');
    else if (typeof(theRow.cells) != 'undefined')
        var theCells = theRow.cells;
    else
        return false;
    var rowCellsCnt  = theCells.length-minus_cell;
    for (var c = anfang; c < rowCellsCnt; c++) {
        theCells[c].style.backgroundColor = thePointerColor;

    }
    return true;
} // end of the 'setPointer()' function


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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];}
}



//---- Formular check ----------------

function vp(id1,breite,hohe){
      ff = window.open("viewpic.php?id1="+id1,"pocketbike",'resizable=no,location=no,scrollbars=no,menubar=no,titlebar=no,toolbar=no,width='+breite+',height='+hohe);
      if (ff.closed==false) ff.focus();
}

function vp2(id,typ){
      ff = window.open("viewpic2.php?id="+id+"&t="+typ,"pocketbike",'resizable=no,location=no,scrollbars=no,menubar=no,titlebar=no,toolbar=no,width=800,height=600');
      if (ff.closed==false) ff.focus();
}

function opwin(pfad,breite,hoehe,scroll) {
      if(pfad!=''){
        fenster=window.open(pfad,"backecke","resizable=yes,location=no,menubar=no,titlebar=no,toolbar=no,scrollbars="+scroll+",width="+breite+",height="+hoehe);
        if (fenster.closed==false) fenster.focus();
      }
}
function suche_go(form){
 if (document.all) {
  	with(eval("document."+form)){
    	if(q.value!='')  submit();
	}
 } else {
	if(document.getElementById('q').value!='') document.getElementById(form).submit();	
 }
}

tag_prompt = "Geben Sie einen Text ein:";
img_prompt = "Bitte geben Sie die volle Bildadresse ein:";
font_formatter_prompt = "Geben Sie einen Text ein - ";
link_text_prompt = "Geben Sie einen Linknamen ein (optional):";
link_url_prompt = "Geben Sie die volle Adresse des Links ein:";
link_email_prompt = "Geben Sie eine E-Mail-Adresse ein:";

function puttxt(tag) {
  var myField;
  tag =' '+tag;
  if (document.getElementById('content') && document.getElementById('content').type == 'textarea') {
    myField = document.getElementById('content');
  }
  else if (document.getElementById('comment') && document.getElementById('comment').type == 'textarea') {
    myField = document.getElementById('comment');
  }
  else {
    return false;
  }
  if (document.selection) {
    myField.focus();
    sel = document.selection.createRange();
    sel.text = tag;
    myField.focus();
  }
  else if (myField.selectionStart || myField.selectionStart == '0') {
    var startPos = myField.selectionStart;
    var endPos = myField.selectionEnd;
    var cursorPos = endPos;
    myField.value = myField.value.substring(0, startPos)
            + tag
            + myField.value.substring(endPos, myField.value.length);
    cursorPos += tag.length;
    myField.focus();
    myField.selectionStart = cursorPos;
    myField.selectionEnd = cursorPos;
  }
  else {
    myField.value += tag;
    myField.focus();
  }
}


function klapp(name, link, txt1, txt2) {
  var e = document.getElementById(name);
  e.style.display = (e.style.display == 'block') ? 'none' : 'block';
  if(link) {
   if(document.all)  document.getElementById(link).innerText   =  (e.style.display == 'none') ? txt1 : txt2;
   else              document.getElementById(link).textContent =  (e.style.display == 'none') ? txt1 : txt2;
  }
}

function chkFormular(dest) {
         if (dest.value != '') return true;
         else                  return false;
}


var selectedText = "";
AddTxt = "";

function getActiveText(msg) {
 selectedText = (document.all) ? document.selection.createRange().text : document.getSelection();
 if (msg.createTextRange) msg.caretPos = document.selection.createRange().duplicate();
 return true;
}

function tag_link(theform,thetype) {
    if (selectedText)  var dtext=selectedText;  else  var dtext="";
    linktext = prompt(link_text_prompt,dtext);
    var prompttext;
    if (thetype == "URL") {
       prompt_text = link_url_prompt;
       prompt_contents = "http://";
    }
    else {
       prompt_text = link_email_prompt;
       prompt_contents = "";
    }
    linkurl = prompt(prompt_text,prompt_contents);
    if ((linkurl != null) && (linkurl != "")) {
       if ((linktext != null) && (linktext != "")) {
          AddTxt = "["+thetype+"="+linkurl+"]"+linktext+"[/"+thetype+"] ";
          AddText(AddTxt,theform);

       }
       else {
          AddTxt = "["+thetype+"]"+linkurl+"[/"+thetype+"] ";
          AddText(AddTxt,theform);
       }
     }
}

function AddText(NewCode,theform2) {
      theform = eval('document.'+theform2);
      if (theform.comment.createTextRange && theform.comment.caretPos) {
       var caretPos = theform.comment.caretPos;
       caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? NewCode + ' ' : NewCode;
      } else theform.comment.value+=NewCode;
      AddTxt = "";
      theform.comment.focus();
}

function showLoader() {
	document.form1.SubmitBtn.disabled = 'disabled'; 
	document.getElementById('loaderDiv').style.display = 'inline';
}
