function google()
{
	ebaywin=window.open("http://www.preisvergleich.net/redirects/ebay.php","","scrollbars=yes,resizeable=yes,menubar=yes,toolbar=yes,location=yes,directories=yes,status=yes");
	ebaywin.blur();
	window.focus();
	razywin=window.open("http://www.foren.de/popup/index.htm","","toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=410,height=360,left=307,top=233");
}

function DoPrompt(action)
{
   document.REPLIER.beitrag.value=document.REPLIER.beitrag.value+action;
   document.REPLIER.beitrag.focus();
}

function storeCaret (textEl)
{
        if (textEl.createTextRange)
        textEl.caretPos = document.selection.createRange().duplicate();
}

function insertAtCaret (textEl, text)
{
	if (navigator.appVersion.indexOf("MSIE")!=-1)
	{
		if (textEl.createTextRange && textEl.caretPos) {
			var caretPos = textEl.caretPos;
		        caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
			text + ' ' : text;
		}
		else
			textEl.value  = textEl.value + text;
	} else DoPrompt(text);
		document.REPLIER.beitrag.focus();
}

function insertURL ()
{
	url=prompt('Bitte die URL eingeben (www...):','');
	if (url!=null) {
		titel=prompt('Und nun bitte den Text eingeben, der im Beitrag angezeigt werden soll:','');
		if (titel!=null) {
			AroundSelection(document.REPLIER.beitrag,'[url=' + url + ']' + titel + '[/url]','');
		}
	}
}

function insertIMG ()
{
	img=prompt('Bitte die URL des Images eingeben (www...):','');

	if (img!=null) {
		AroundSelection(document.REPLIER.beitrag,'[img]' + img + '[/img]','');
	}
}

function insertEmail ()
{
	email=prompt('Bitte die Emailadresse eingeben:','');

	if (email!=null) {
		titel=prompt('Und nun bitte den Text eingeben, der im Beitrag angezeigt werden soll:','');

		if (titel!=null) {
			AroundSelection(document.REPLIER.beitrag, '[url=mailto:' + email + ']' + titel + '[/url]','');
		}
	}
}

function insertList() {
	anzahl=prompt('Anzahl der Punkte (max. 9):','1');

	if (anzahl>=10) {
		anzahl=9;
	}

	if (anzahl!=null || isNaN(anzahl)==false) {
		liststring='[list]';

		for (var i=1; i<=anzahl; i++) {
			liststring += '\r\n[punkt][/punkt]';
		}

		liststring+='\r\n[/list]';

		AroundSelection(document.REPLIER.beitrag, liststring,'');
	}
}

function InsertZitat()
{
	person=prompt('Bitte den Namen der zu zitierenden Person eingeben.','');

	if (person!=null) {
	        var nicklength = person.length;

		for (var i=0; i<=nicklength; i++)
		{
			person = person.replace('[','');
			person = person.replace(']','');
		}

		AroundSelection(document.REPLIER.beitrag,'[Zitat=' + person + '][/Zitat]','');
	}
}

function AroundSelection(textarea, links, rechts) {
	var input = textarea;
	input.focus();
	/* is IE ? */
        if(typeof document.selection != 'undefined') {
		/* Einf?gen des Formatierungscodes */
	        var range = document.selection.createRange();
		var insText = range.text;
		range.text = links + insText + rechts;
		/* Anpassen der Cursorposition */
		range = document.selection.createRange();
		if (insText.length == 0) {
			range.move('character', -rechts.length);
		} else {
			range.move('character', links.length);
			range.moveEnd('character', insText.length);
		}
		range.select();
	}
	/* Gecko-Browser */
	/* test		 */
	else if(typeof input.selectionStart != 'undefined')
	{
		var sStart = input.selectionStart;
		var sEnd = input.selectionEnd;
		var sInsText = input.value.substring(sStart, sEnd);
		input.value = input.value.substr(0, sStart) + links + sInsText + rechts + input.value.substr(sEnd);
		var cpos;
		textarea.focus();
		if (sInsText.length == 0) {
			cpos = sStart + links.length;
			input.selectionStart = cpos;
			input.selectionEnd = cpos;
		} else {
			input.selectionStart = sStart + links.length;
			input.selectionEnd = sStart + links.length + sInsText.length;
		}
	} else {
		textarea.value = textarea.value + links + rechts;
	}
	//textarea.focus();
}

function trim(s)
{
    while (s.substring(0,1) == " ")
    {
        s = s.substring(1,s.length);
    }
    while (s.substring(s.length-1,s.length) == " ")
    {
        s = s.substring(0,s.length-1);
    }
    return s;
}

function webClient()
{

  var i;

  this.IE    = false;
  this.NS    = false;
  this.OP    = false;
  this.release = null;

  if ((i = navigator.userAgent.indexOf("Opera")) >= 0) {
    this.OP = true;
    this.version = parseFloat(navigator.userAgent.substr(i + 5));
    return;
  }


  if ((i = navigator.userAgent.indexOf("MSIE")) >= 0) {
    this.IE = true;
    this.release = parseFloat(navigator.userAgent.substr(i + 4));
    return;
  }

  if ((i = navigator.userAgent.indexOf("Netscape6/index.html")) >= 0) {
    this.NS = true;
    this.release = parseFloat(navigator.userAgent.substr(i + 10));
    return;
  }

  if ((i = navigator.userAgent.indexOf("Netscape7/index.html")) >= 0) {
    this.NS = true;
    this.release = parseFloat(navigator.userAgent.substr(i + 10));
    return;
  }

  if ((i = navigator.userAgent.indexOf("Gecko")) >= 0) {
    this.NS = true;
    this.release = 6.1;
    return;
  }
}


var webClient = new webClient();

var activeButton = null;
var activeSubButton = null;

 if (webClient.IE)
	 document.onmousedown = pageMouseDown;
  else
     document.addEventListener("mousedown", pageMouseDown, true);


function pageMouseDown(event)
{

  var el;

  //if (activeButton == null)
  //  return;

  if (webClient.IE)
    el = window.event.srcElement;
  else
    el = (event.target.tagName ? event.target : event.target.parentNode);

  if (el == activeButton || el == activeSubButton)
    return;

  if (el.className != "menuButton"  && el.className != "menuItem" &&
      el.className != "menuItemSep" && el.className != "menu") {
	    if (activeButton) closeMenu(activeButton);
    	if (activeSubButton) closeSubMenu(activeSubButton);
	}
}

p=777;
WMTT=null;
document.onmousemove=aktualisiereBuchungen;

function aktualisiereBuchungen(e)
{
	x=(document.all)?window.event.x+document.body.scrollLeft:e.pageX;
	y=(document.all)?window.event.y+document.body.scrollTop:e.pageY;

	if (WMTT!=null)
	{
		versetzungY=0;
		versetzungX=15;

		if(position=="left")
		{
			versetzungX=-245;
			if(WMTT.id=="tt_serverstatus")
			{
				versetzungX=-285;
			}
			else
			{
				if(WMTT.id=="tt_downloadqueue")
				{
					versetzungX=-400;
				}
				else
				{
					versetzungX=-245;
				}
			}
		}
		else
		{
			if(position=="top")
			{
				versetzungY=-70;
			}
		}

		var WMTTID = WMTT.id;
		var ersterTeilDerID = WMTTID.substr(0,6);

		if( (WMTTID!="tt_medialinks") && (ersterTeilDerID!="banner") )
		{
			WMTT.style.left=(x+versetzungX)+"px";
			WMTT.style.top=(y+versetzungY+8)+"px";
		}
		else
		{
			if(ersterTeilDerID=="banner")
			{
				WMTT.style.left=15+"px";
				WMTT.style.top=4+"px";
			}
			else
			{
				WMTT.style.left=8+"px";
				WMTT.style.top=50+"px";
			}
		}
	}
}

function zeigeBox(id,inputposition)
{
	aktualisiereBuchungen;
	position=inputposition;
	WMTT=document.getElementById(id);
	WMTT.style.display="block"
}

function schliesseBox()
{
	if (WMTT!=null)	WMTT.style.display="none";
}
