
function showpic(pic,titel,w,h,ordner) {
 window.open(ordner+'include/pic_show.php?pic='+pic+'&titel='+titel,'', 'width='+w+',height='+h+',left='+(screen.width-w)/2+',top='+(screen.height-h)/2+',toolbar=no,menubar=no,scrollbars=no,resizable=yes');
}


// typ = clear , b , i , u
function format_textarea(form_name,textarea_name,typ) {

var element = document.forms[form_name].elements[textarea_name];
if (document.selection) {
 // Anfangs und Endpunkte herausfinden ---------
 var range = document.selection.createRange();
 var stored_range = range.duplicate();
 stored_range.moveToElementText(element);
 stored_range.setEndPoint('EndToEnd',range);
 element.selectionStart = stored_range.text.length - range.text.length;
 element.selectionEnd = element.selectionStart + range.text.length;
 // ----------------


 if (element.selectionStart != element.selectionEnd) {

  var new_value = (element.value).substring(0,element.selectionStart);

  if (typ == "clear") {

   var x = (element.value).substring(element.selectionStart,element.selectionEnd);
   var symbols = new Array("<b>","</b>","<i>","</i>","<u>","</u>");

   while (symbol = symbols.shift()) {
    while (x.indexOf(symbol)>-1) {
     var pos = x.indexOf(symbol);
     x = "" + (x.substring(0, pos) + x.substring((pos + symbol.length), x.length));
    }
   } // while symbols

   new_value += x;

  } else {

   new_value += "<" + typ + ">" + (element.value).substring(element.selectionStart,element.selectionEnd) + "</" + typ + ">";

  } // if clear / typ

  new_value += (element.value).substring(element.selectionEnd,element.length);
  element.value = new_value;

 } // if start != end
} // if selection

} // function format_textarea für i, u , b

// function für bsp [s1] [/s1] , [B] [/B]
function format_textarea2(form_name, textarea_name, aTag, eTag) {
  var input = document.forms[form_name].elements[textarea_name];
  input.focus();
  //* für IE
  if(typeof document.selection != 'undefined') {
    // Einfügen
    var range = document.selection.createRange();
    var insText = range.text;
    range.text = aTag + insText + eTag;
    // cursor position
    range = document.selection.createRange();
    if (insText.length == 0) {
      range.move('character', -eTag.length);
    } else {
      range.moveStart('character', aTag.length + insText.length + eTag.length);
    }
    range.select();
  }
  // neue auf Gecko basierende Browser
  else if(typeof input.selectionStart != 'undefined') {
    // Einfügen
    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = input.value.substring(start, end);
    input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end);
    // cursor position
    var pos;
    if (insText.length == 0) {
      pos = start + aTag.length;
    } else {
      pos = start + aTag.length + insText.length + eTag.length;
    }
    input.selectionStart = pos;
    input.selectionEnd = pos;
  }
} // function format_textarea2 für [B] [/B] ..


// CHANGE PIC ------------------
var bilder = new Array ("","bowling-25.jpg","bowling-1.jpg","bowling-100.jpg","bowling-101.jpg","bowling-103.jpg","bowling-104.jpg","bowling-106.jpg");
bilder.push ("bowling-117.jpg","bowling-121.jpg","bowling-24.jpg","bowling-25.jpg","bowling-26.jpg","bowling-29.jpg","bowling-32.jpg","bowling-34.jpg");
bilder.push ("bowling-35.jpg","bowling-37.jpg","bowling-44.jpg","bowling-45.jpg","bowling-46.jpg","bowling-48.jpg","bowling-59.jpg","bowling-61.jpg");
bilder.push ("bowling-62.jpg","bowling-64.jpg","bowling-67.jpg","bowling-69.jpg","bowling-74.jpg","bowling-75.jpg","bowling-76.jpg","bowling-80.jpg");
bilder.push ("bowling-82.jpg","bowling-84.jpg","bowling-88.jpg");

function change_pic(ordner) {
 var y,x,z,i;

 var show = false;
 while (show == false) {
  y = Math.round(Math.random() * bilder.length);
  if (y < 1 || y >= bilder.length) y = 1;
  show = true;
  for (i=1; i <= 5; i++) {
   str = document.getElementById(i).src;
   if (str.match("images/fotos/" + bilder[y])) show = false;
  }
 }

 x = Math.round(Math.random() * 5);
 if (x > 5) x = 5;
 if (x < 1) x = 1;

// document.getElementById(x).src = ordner + "images/fotos/" + bilder[y];

 z  = "<a href=\"javascript:showpic('../images/fotos/" + bilder[y] + "','NXP-Bowling Center',450,300,'" + ordner + "');void(0);\">";
 z += "<img id=\"" + x + "\" src=\"images/fotos/" + bilder[y] + "\" height=\"75\" border=\"0\"></a>";
 document.getElementById("pic_" + x).innerHTML = z;


 setTimeout("change_pic('"+ordner+"')",2000);

} // function change_pic

// Bestimmte DIVs drucken
function function_print(element_id,ordner) {

 var a = window.open('','','width=650,height=400,resizable');
 a.document.open("text/html");
 a.document.write("<html><head><link href=\"" + ordner + "include/styles.css\" rel=\"stylesheet\" type=\"text/css\">");
 a.document.write("</head><body bgcolor=\"#514D4C\" onblur=\"window.close()\" onclick=\"window.close()\"><center>");

// a.document.write("<table cellpadding=\"0\" cellspacing=\"0\"><tr><td><img src=\"index/nxp-bowling-logo.gif\"></td><td><img src=\"index/navi_info.gif\"></td></tr></table><br>");

// a.document.write("<img src=\"" + ordner + "images/fotos/bowling-67.jpg\" height=\"75\" border=\"0\">&nbsp;&nbsp;");
// a.document.write("<img src=\"" + ordner + "images/fotos/bowling-100.jpg\" height=\"75\" border=\"0\">&nbsp;&nbsp;");
// a.document.write("<img src=\"" + ordner + "images/fotos/bowling-25.jpg\" height=\"75\" border=\"0\">&nbsp;&nbsp;");
// a.document.write("<img src=\"" + ordner + "images/fotos/bowling-45.jpg\" height=\"75\" border=\"0\">&nbsp;&nbsp;");
// a.document.write("<img src=\"" + ordner + "images/fotos/bowling-75.jpg\" height=\"75\" border=\"0\">");

// a.document.write("<br><br>");
 a.document.write(document.getElementById("" + element_id + "").innerHTML);
 a.document.write("</center></body></html>");
 a.document.close();
 a.print();

}

// Divs
function div_expand(div) {
 if (document.getElementById(div).style.display == "") document.getElementById(div).style.display = "none";
 else document.getElementById(div).style.display = "";
}

