/*editor-functions*/
function checkTextlength (srcObj, maxLength, displID)
{
  if (srcObj.value.length > maxLength)
     srcObj.value = srcObj.value.substr (0, maxLength);
  if (document.getElementById(displID))
     document.getElementById(displID).innerHTML = maxLength - srcObj.value.length;
}

function insert(aTag, eTag, oObjekt) {
  var input = document.forms['newsedit'].elements[oObjekt];
  input.focus();
  /* für Internet Explorer */
  if(typeof document.selection != 'undefined') {
    /* Einfügen des Formatierungscodes */
    var range = document.selection.createRange();
    var insText = range.text;
    range.text = aTag + insText + eTag;
    /* Anpassen der Cursorposition */
    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();
  }
  /* für neuere auf Gecko basierende Browser */
  else if(typeof input.selectionStart != 'undefined')
  {
    /* Einfügen des Formatierungscodes */
    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);
    /* Anpassen der Cursorposition */
    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;
  }
  /* für die übrigen Browser */
  else
  {
    /* Abfrage der Einfügeposition */
    var pos;
    var re = new RegExp('^[0-9]{0,3}$');
    while(!re.test(pos)) {
      pos = prompt("Einfügen an Position (0.." + input.value.length + "):", "0");
    }
    if(pos > input.value.length) {
      pos = input.value.length;
    }
    /* Einfügen des Formatierungscodes */
    var insText = prompt("Bitte geben Sie den zu formatierenden Text ein:");
    input.value = input.value.substr(0, pos) + aTag + insText + eTag + input.value.substr(pos);
  }
}
/*Ende editor-functions*/


function popup (datei, titel, hoehe, breite)
{
  window.open(" + datei +", " + titel + ", "height="+hoehe+", width="+breite+", resizable=no, scrollbars=yes, toolbar=no, location=no, status=no");
  return;
}

function help (datei, hoehe, breite)
{
	 window.open (datei, '',"height=" + hoehe + ", width=" + breite + ", resizable=no, scrollbars=yes, toolbar=no, location=no, status=no");
	 return;
}

var win = "";
function fenster(Grafik,width,height,name,titel)
 {
 	/*Dafür sorgen, dass immer nur ein Fenster geöffnet ist*/
	if (win != "")
 	{ 
 		/*Falls ein Fenster geöffnet ist, dieses erst schliessen*/
		win.close();
	}
   	win=window.open("",name,"width="+width+",height="+(height+60)+",left=150,top=50"); 
   	win.document.open("text/html");
   	win.document.write("<BODY leftmargin='0' topmargin='0' marginheight='0' marginwidth='0'>");
   	win.document.bgColor="#939EB2";
   		
	/*Stylesheets für das neue Fenster*/
  		win.document.write("<style type= text/css>" +
	"a{color:#C40000; text-decoration:none; font-size:12px;font-family:Arial,sans-serif; }" +
	"a:link { color:#e84b17; text-decoration:underline; font-size:12px;font-family:Arial,sans-serif; }" +
	"a:visited { color:#e84b17; text-decoration:underline; font-size:12px;font-family:Arial,sans-serif; }" +
	"a:hover { color: #000000; text-decoration:none; font-size:12px;font-family:Arial,sans-serif; }" +
	"</style>");

	win.focus();
   	win.document.write("<TITLE>" +titel +"</title>");
   	win.document.write("<IMG src='"+Grafik+"'>");
   	win.document.write("<div align=center>&nbsp;</div>");
   	win.document.write("<div align=center><a href='javascript:window.print()'>Seite drucken</a></div>");
   	win.document.write("<div align=center><a href='javascript:self.close()'>Fenster schlie&szlig;en</a></div>");
   	win = "";
}
 

var win = "";
function fenster_mit_text(Grafik,b,h,n,titel,text,zugabe)
{
 	/*Dafür sorgen, dass immer nur ein Fenster geöffnet ist*/
	if (win != ""&&win.closed==false)
 	{ 
 		/*Falls ein Fenster geöffnet ist, dieses erst schliessen*/
		win.close();
	}
   	win=window.open("",n,"width="+b+",height="+(h+zugabe)+",left=50,top=20"); 
   	win.document.open("text/html");
   	win.document.write("<BODY leftmargin='0' topmargin='0' marginheight='0' marginwidth='0'>");
   	win.document.bgColor="#C8C8C8";
   		
		/*Stylesheets für das neue Fenster*/
   		win.document.write("<style type= text/css>" +
		"a{color:red; text-decoration:none; font-size:11px;font-family:Verdana,Arial,sans-serif; }" +
		"a:link { color:red; text-decoration:none; font-size:11px;font-family:Verdana,Arial,sans-serif; }" +
		"a:vlink { text-decoration:none; color: red; font-size:11px;font-family:Verdana,Arial,sans-serif; }" +
		"a:hover { color: blue; text-decoration:none; font-size:11px;font-family:Verdana,Arial,sans-serif; }" +
		"a:alink { color: red; text-decoration:none; font-size:11px;font-family:Verdana,Arial,sans-serif; }" +
		"</style>");
	
	win.focus();
   	win.document.linkColor="red";
   	win.document.vlinkColor="red";
   	win.document.write("<TITLE>" +titel +"</title>");
   	win.document.write("<IMG src='"+Grafik+"'>");
   	win.document.write("<div align=center>" +text+ "</div>");
   	win.document.write("<div align=center>&nbsp;</div>");
   	win.document.write("<div align=center><a href='javascript:window.print()'>Seite drucken</a></div>");
   	win.document.write("<div align=center><a href='javascript:self.close()'>Fenster schlie&szlig;en</a></div>");
   	win = "";
}

//Bildanzeige genaue Bildgröße
var Fenstername;
var Fenster;
function popup_bild (id, bild, titel, hoehe, breite, typ)
{
  if (Fenster){Fenster.close();}
  Fenstername = id;
  if (typ!='')
  {
	Fenster=window.open("bspMovie-schuhe-sport-nottuln.php?titel=" + titel + "&film="+ bild + "&artid=" + id + "&media=" + typ+ "&hoehe="+hoehe+"&breite="+breite+"&ty=<?=$type?>", Fenstername, "height="+hoehe+", width="+breite+", resizable=no, scrollbars=no, toolbar=no, location=no, status=no");	   
  }
  else
  { 
	Fenster=window.open("bspImages-schuhe-sport-nottuln.php?titel=" + titel + "&bild="+ bild + "&artid=" + id + "&ty=<?=$type?>", Fenstername, "height="+hoehe+", width="+breite+", resizable=no, scrollbars=no, toolbar=no, location=no, status=no");	   
  }
  Fenster.focus();
  return;
}

/*Funktionen um die Seite als Startseite des Browsers 
zu erklären und die aktuelle Seite zu bookmarken*/
var browser = navigator.appName;
var version = navigator.appVersion.substring(0, 1);
var ie =
  ((browser == "Microsoft Internet Explorer") &&
  (version >= 4))
;
var ns =
  ((browser == "Netscape") &&
  (version >= 4 ))
;

function setHomePage(siteURL) {
  if (ie) {
    document.body.style.behavior = "url(#default#homepage)";
    document.body.setHomePage(siteURL);
  } else
    alert(
      "Die Seite konnte nicht automatisch als " +
      "Startseite eingestellt werden, tun Sie " +
      "dies bitte manuell!"
    );
}

function addToFavorites(siteURL, description) {
  if (ie)
    window.external.AddFavorite(siteURL, description);
  else if (ns)
    alert("Drücken Sie Strg+D zum Bookmarken dieser Seite!");
  else
    alert(
      "Die Seite kann nicht automatisch den " +
      "Favoriten hinzugefügt werden!"
    );
}


function montre(id)
{
	with (document)
	{
		if (getElementById)
			getElementById(id).style.display = 'block';
		else if (all)
			all[id].style.display = 'block';
		else
			layers[id].display = 'block';
	}
}

function cache(id)
{
	with (document)
	{
		if (getElementById)
			getElementById(id).style.display = 'none';
		else if (all)
			all[id].style.display = 'none';
		else
			layers[id].display = 'none';
	}
}
