﻿// Author: Fk
// Project: Realis.MeinSport
// Path: C:\code\MeinSport\MeinSport\Scripts
// Creation date: 18.03.2008 15:31
// Last modified: 27.05.2008 11:05

var controls = new Array();
function Cisd(panelID)
{
  var panelElement = document.getElementById(panelID);
  if (!panelElement)
    alert("Failed to find panel element in method Cisd '" + panelID + "'");
  var expanderId =
    panelID == "postingSmileysCollapsed" ? "smilesExpander" :
    panelID == "postingImagesCollapsed" ? "imagesExpander" :
    "documentsExpander";
  var contentId =
    panelID == "postingSmileysCollapsed" ? "smiles" :
    panelID == "postingImagesCollapsed" ? "images" :
    "documents";
  var iconImageId =
    panelID == "postingSmileysCollapsed" ? "smiliesExpandImage" :
    panelID == "postingImagesCollapsed" ? "imagesExpandImage" :
    "documentsExpandImage";
  var titleId =
    panelID == "postingSmileysCollapsed" ? "titleSmiles" :
    panelID == "postingImagesCollapsed" ? "titleImage" :
    "titleDocuments";

  this.expandLink = document.getElementById(expanderId);
  this.contentContainer = document.getElementById(contentId);
  this.visible = false;
  this.expandIcon = document.getElementById(iconImageId);
  this.titleBar = document.getElementById(titleId);
  try
  {
    this.titleBar.onclick = toogle;
    this.expandLink.onclick = toogle;
  }
  catch (e)
  {
  }
}
function toogle()
{
  for(var i=0;i<controls.length;i++)
  {
		if( controls[i].expandLink.id == this.id ||
			controls[i].titleBar.id == this.id)
		{    
			if(controls[i].visible)
			{
				controls[i].expandIcon.src = "/Images/SportScheck/Icons/ExpandIcon.png";
				controls[i].contentContainer.style.display = "none";    
			}
			else 
			{
				controls[i].expandIcon.src = "/Images/SportScheck/Icons/CollapseIcon.png"
				controls[i].contentContainer.style.display = "block";
			}
			
			controls[i].visible = !controls[i].visible;
		}
		else 
		{
			controls[i].visible = false;
			controls[i].expandIcon.src = "/Images/SportScheck/Icons/ExpandIcon.png";
			controls[i].contentContainer.style.display = "none";
		}
  }
}
function IsIE()
{
  if(navigator.userAgent.indexOf("MSIE")!=-1)
		return true;
  return false;
}
function getDOMObject(documentID)
{
	if (document.all)
		return document.all[documentID];
	else if(document.getElementById)
		return document.getElementById(documentID);
	else if (document.layers)
		return document.layers[documentID];
	else if (document.getElementById && !document.all)
		return document.getElementById(documentID);
}
var command = "";
function InitToolbarButtons() 
{
	var kids = document.getElementsByTagName('DIV');
	var k=0;
	for (var i=0; i < kids.length; i++)
	{
		if (kids[i].className.indexOf("button") != -1)
		{
			kids[i].onmouseover = tbmouseover;
			kids[i].onmouseout = tbmouseout;
			kids[i].onmousedown = tbmousedown;
			kids[i].onclick = tbclick;
		}
		else if (kids[i].className.indexOf("postingFormExtras") != -1)
		{
			var control = new Cisd(kids[i].id);
			controls[k] = control;
			k++;
		}
	}
	toogle();
	kids = document.getElementsByTagName('input');
	for (var i=0; i < kids.length; i++)
	{
		if (kids[i].id.indexOf("InsertImageButton") > 0)
		{
			if (kids[i].onclick != null)
			{
				if (kids[i].onclick.toString().indexOf("InsertSmile") > 0)
				{
					kids[i].onclick();
					kids[i].onclick = null;
				}
			}
		}
	}
}
function tbmousedown(e)
{
  var evt = e ? e : window.event; 
  if (evt.returnValue)
    evt.returnValue = false;
  else if (evt.preventDefault)
    evt.preventDefault();
  else
    return false;
}
function tbmouseup()
{
}
function tbmouseout()
{ 
	this.style.backgroundColor = "rgb(255,255,255)";
}
function tbmouseover()
{ 
	this.style.backgroundColor = "rgb(215,227,239)";
}
function tbclick()
{  
  if ((this.id == "forecolor") ||
		(this.id == "hilitecolor"))
	{
    parent.command = this.id;
    parent.iframeID = iframeID;
    var buttonElement = document.getElementById(this.id);        
    var oldcolor = GetEditBoxColor("forecolor");
    var color = GetColorFromUser(oldcolor, buttonElement);    
    selectColor(color);
  }
  else if (this.id == "createImage")
  {
    var szURL = prompt(
			"Gib eine URL zu einem Bild an: \n\rDu kannst das Bild auch noch " +
			"nachträglich vergrößern oder verkleinern indem du draufklickst.",
			"http://");
    if ((szURL != null) && (szURL != "")) 
    {
			if (IsIE() &&
				document.getElementById(iframeID).contentWindow.document.selection.
				type == "None")
			{
				document.getElementById(iframeID).contentWindow.focus();
				var sel = document.getElementById(iframeID).contentWindow.document.
					selection.createRange();
				sel.pasteHTML("<img src="+szURL+"/>");
				sel.select();
			}
			else
				if(IsIE() == false &&
					document.getElementById(iframeID).contentWindow.getSelection() == "")
				{
					var linkObj = textboxDocumentObject.createElement("img");
					linkObj.src = szURL;
					textboxDocumentObject.body.appendChild(linkObj);
				}
				else
					document.getElementById(iframeID).contentWindow.document.execCommand(
						"CreateImage",false,szURL);
		}
	}
  else if (this.id == "createVideo")
  {
    var szURL = prompt(
			"Gib die \"Embed\" URL zu einem Video an: (z.B. YouTube, Sevenload,...)",
			"");
    if ((szURL != null) && (szURL != "")) 
    {
			var cutIndex = szURL.lastIndexOf("object>");
			if (cutIndex != -1)
			{
				szURL = szURL.substr(0, cutIndex + 7);
			}
			
			if (IsIE() &&
				document.getElementById(iframeID).contentWindow.document.selection.
				type == "None")
			{
				document.getElementById(iframeID).contentWindow.focus();
				var sel = document.getElementById(iframeID).contentWindow.document.
					selection.createRange();
				sel.pasteHTML(szURL);
				sel.select();
			}
			else
				if(IsIE() == false &&
					document.getElementById(iframeID).contentWindow.getSelection() == "")
				{
					var linkObj = textboxDocumentObject.createElement("div");
					linkObj.innerHTML = szURL.replace(/</g, "&lt;").replace(/>/g, "&gt;");
					textboxDocumentObject.body.appendChild(linkObj);
				}
				else
					document.getElementById(iframeID).contentWindow.document.execCommand(
						"CreateVideo",false,szURL);
		}
	}
  else if (this.id == "createlink")
  {
    var szURL = prompt("Gib eine URL ein:", "http://");
    if ((szURL != null) && (szURL != "")) 
    {
			if (IsIE() &&
				document.getElementById(iframeID).contentWindow.document.selection.
				type == "None")
			{
				document.getElementById(iframeID).contentWindow.focus();
				var sel = document.getElementById(iframeID).contentWindow.document.
					selection.createRange();
				sel.pasteHTML("<a href="+szURL+" target='_blank'>"+szURL+"</a>");
				sel.select();
			}
			else
				if(IsIE() == false &&
					document.getElementById(iframeID).contentWindow.getSelection() == "")
				{
					var linkObj = textboxDocumentObject.createElement("a");
					linkObj.href = szURL;
					linkObj.innerHTML = szURL;
					linkObj.target = "_blank";
					textboxDocumentObject.body.appendChild(linkObj);
				}
				else
					document.getElementById(iframeID).contentWindow.document.execCommand(
						"CreateLink",false,szURL);
		}
	}
  else if(this.id == "mailto")
  {
    var szURL = prompt("Gib eine Email Addresse ein:", "");
    if ((szURL != null) && (szURL != "")) 
    {
      if (IsIE() &&
				document.getElementById(iframeID).contentWindow.document.selection.
				type == "None")
      {
        document.getElementById(iframeID).contentWindow.focus();
        var sel = document.getElementById(iframeID).contentWindow.document.
					selection.createRange();
        sel.pasteHTML(
					"<a style='border-bottom:dashed 1px;text-decoration:none' "+
					"href=mailto:"+szURL+">"+szURL+"</a>");
        sel.select();
      }
      else
      {
        if(IsIE() == false &&
					document.getElementById(iframeID).contentWindow.getSelection() ==
					"")
        {
          var linkObj = textboxDocumentObject.createElement("a");
          linkObj.href = "mailto:" + szURL;
          linkObj.style.textDecoration = "none";
          linkObj.style.borderBottom = "dashed 1px rgb(0,0,239)";
          linkObj.innerHTML = szURL;
          textboxDocumentObject.body.appendChild(linkObj);
        }
        else
        {
          szURL = "mailto:" + szURL;
          document.getElementById(iframeID).contentWindow.document.
						execCommand("CreateLink",false,szURL);
        }
      }
    }
  }
  else if(this.id == "codesnippet")
  {
    parent.command = this.id;
    parent.iframeID = iframeID;
    var buttonElement = document.getElementById(this.id);
    var code = GetSnipetFromUser(buttonElement);
    if ((code != null) &&
			(code != "") &&
			IsIE())
    {
      if(textboxDocumentObject.selection.type != "None") 
        textboxDocumentObject.selection.clear();
      document.getElementById(iframeID).contentWindow.focus();
      var sel = document.getElementById(iframeID).contentWindow.document.
				selection.createRange();
      sel.pasteHTML(code);
      sel.select();
    }
  }
  else
  {
    document.getElementById(iframeID).contentWindow.focus();
    document.getElementById(iframeID).contentWindow.document.execCommand(
			this.id, false, null);
    document.getElementById(iframeID).contentWindow.focus();
  }
}
function dismisscolorpalette()
{
}
var iframeID;
var once = 0;
function Start(iframe_id) {

	
  iframeID = iframe_id;
  IFrameInit();
  InitToolbarButtons();
  if (document.addEventListener)
  {
    document.addEventListener("mousedown", dismisscolorpalette, true);
    document.getElementById(iframeID).contentWindow.document.addEventListener(
			"mousedown", dismisscolorpalette, true);
    document.addEventListener("keypress", dismisscolorpalette, true);
    document.getElementById(iframeID).contentWindow.document.addEventListener(
			"keypress", dismisscolorpalette, true);
  }
  else if (document.attachEvent)
  {
    document.attachEvent("mousedown", dismisscolorpalette, true);
    document.getElementById(iframeID).contentWindow.document.attachEvent(
			"mousedown", dismisscolorpalette, true);
    document.attachEvent("keypress", dismisscolorpalette, true);
    document.getElementById(iframeID).contentWindow.document.attachEvent(
			"keypress", dismisscolorpalette, true);
  }
}
function viewsource(source)
{
  var html;
  if (source)
  {
    html = document.createTextNode(document.getElementById(iframeID).
			contentWindow.document.body.innerHTML);
    document.getElementById(iframeID).contentWindow.document.body.innerHTML =
			"";
    html = document.getElementById(iframeID).contentWindow.document.importNode(
			html,false);
		document.getElementById(iframeID).contentWindow.document.body.appendChild(
			html);
    document.getElementById("toolbar1").style.visibility="hidden";
    document.getElementById("toolbar2").style.visibility="hidden";  
  }
  else
  {
    html = document.getElementById(iframeID).contentWindow.document.body.
			ownerDocument.createRange();
    html.selectNodeContents(document.getElementById(iframeID).contentWindow.
			document.body);
    document.getElementById(iframeID).contentWindow.document.body.innerHTML =
			html.toString();
    document.getElementById("toolbar1").style.visibility="visible";
    document.getElementById("toolbar2").style.visibility="visible";
  }
}
function usecss(source)
{
  document.getElementById(iframeID).contentWindow.document.execCommand(
		"useCSS", false, !(source));
}
function readonly(source)
{
  document.getElementById(iframeID).contentWindow.document.execCommand(
		"readonly", false, !(source));
}
function SetHiddenVar()
{
	var result = getDOMObject(iframeID).contentWindow.document.body.innerHTML;
	return result;
}
var emoticons = null;
function ExecCommand(command, value, valueIsID)
{
	var extraObj;
	if(null != valueIsID && valueIsID==true)
	{
		extraObj = getDOMObject(value);
		value = extraObj.value;
	}
	document.getElementById(iframeID).contentWindow.focus();
	document.getElementById(iframeID).contentWindow.document.execCommand(
		command, false, value);
	document.getElementById(iframeID).contentWindow.focus();
}
function InsertSmile(smileSrc)
{
	var textToBeInserted = "<img src='"+smileSrc+"' />";
	if(IsIE())
	{
		var sel = textboxDocumentObject.createElement(textToBeInserted);
		textboxDocumentObject.body.insertBefore(sel);
		sel.unselectable = "on";
	}
	else
	{
		textboxDocumentObject.execCommand("InsertImage",false,smileSrc);
	}
}
function InsertImage(imageSrc)
{
	var textToBeInserted = "<img src='"+imageSrc+"' width='500' />";
	if(IsIE())
	{
		var linkObj = textboxDocumentObject.createElement(linkText);
		linkObj.innerHTML = textToBeInserted;
		textboxDocumentObject.body.insertBefore(linkObj);
	}
	else if(IsIE() == false &&
		document.getElementById(iframeID).contentWindow.getSelection() == "")
	{
		var linkObj = textboxDocumentObject.createElement("img");
		linkObj.src = imageSrc;
		linkObj.width = 500;
		textboxDocumentObject.body.appendChild(linkObj);
	}
	else
	{
		textboxDocumentObject.execCommand("InsertImage",false,imageSrc);
	}
}
var textboxDocumentObject = null;
var textboxObject = null;
function IFrameInit()
{    
	textboxDocumentObject =
		document.getElementById(iframeID).contentWindow.document;
	textboxObject = document.getElementById(iframeID).contentWindow;
	textboxDocumentObject.designMode = "on";
	try 
	{
		textboxDocumentObject.execCommand("undo", false, null);
	}
	catch (e)
	{
	}
}
function over()
{
  this.style.border='2px dotted white';
}
function out()
{
  this.style.border='1px solid gray';
}
function click()
{
  selectColor(this.id);
}
function selectColor(color)
{
  textboxObject.focus();
  textboxDocumentObject.execCommand("forecolor", false, color);
  textboxObject.focus();
}
function GetEditBoxColor(colorCommand)
{    
	return DecimalToRGB(textboxDocumentObject.queryCommandValue(colorCommand));
}
function DecimalToRGB(value)
{
	var hex_string = '';
	for (var hexpair = 0; hexpair < 3; hexpair++)
	{
   	var byteVar = value & 0xFF;
	    value >>= 8;
	    var nybble2 = byteVar & 0x0F;
	    var nybble1 = (byteVar >> 4) & 0x0F;
	    hex_string += nybble1.toString(16);
	    hex_string += nybble2.toString(16);
  }
	return hex_string.toUpperCase();
}
function GetColorFromUser(oldcolor, buttonElement)
{
	var posX = 0;
	var posY = 0;

	if(IsIE())
	{
		posX = event.screenX;
		posY = event.screenY + 20;
	}
	var screenW = screen.width;
	var screenH = screen.height - 20;
	if (posX + 232 > screenW) { posX = posX - 232 - 40; }
	if (posY + 164 > screenH) { posY = posY - 164 - 80; }
	var wPosition;
	var newcolor;	
	if (window.showModalDialog)
	{
    wPosition = 'dialogLeft:' +posX+ '; dialogTop:' +posY;
    newcolor = showModalDialog('/html/ColorPicker.html',
			oldcolor, 'dialogWidth:238px; dialogHeight: 195px; ' +
			'resizable: no; help: no; status: no; scroll: no; ' + wPosition);
	}
	else
	{	
    var colorPicker = getDOMObject("colorpalette");
    if (colorPicker.style.visibility=="visible")
    {
      colorPicker.style.visibility="hidden";
      return;
    }
    posX = getOffsetLeft(buttonElement);
    posY = getOffsetTop(buttonElement)+24;
    parent.colorPaletePosX = posX;
    parent.colorPaletePosY = document.body.clientHeight -
			getOffsetTop(buttonElement)+195;
    colorPicker.style.left = posX+"px";
    colorPicker.style.top = posY+"px";
    colorPicker.style.position = "absolute";
    colorPicker.style.visibility="visible";
    return;
	}	
	return newcolor
}
function GetSnipetFromUser(buttonElement)
{
	var posX = 0;
	var posY = 0;
	if(IsIE())
	{
		posX = event.screenX;
		posY = event.screenY + 20;
	}
	var screenW = screen.width;
	var screenH = screen.height - 20;
	posX = screenW/2 - 190;
	posY = screenH/2 - 130;
	var wPosition;
	var code;
	if (window.showModalDialog)
	{
    wPosition = 'dialogLeft:' +posX+ '; dialogTop:' +posY;
    code = showModalDialog('/html/InsertCodeSnipet.html',
			"Get Code Snipet",
      'dialogWidth:380px; dialogHeight: 265px; '
      + 'resizable: no; help: no; status: no; scroll: no; '
      + wPosition);
	}
	else
	{
		posX = getOffsetLeft(buttonElement)+24;
		posY = getOffsetTop(buttonElement)-227;
		var codeSnipet = getDOMObject("codeSnipet");
		codeSnipet.style.left =posX +"px";
		codeSnipet.style.top = posY+"px";
		codeSnipet.style.position = "absolute";
		codeSnipet.contentWindow.document.getElementById("txtCodeSnipet").focus();
		codeSnipet.style.visibility="visible";
	}
	return code;
}
function GetImgUrl(obj)
{
	var imgSrc = obj.src;
	if(null != imgSrc)
	{
		var textToBeInserted = "<img src='"+imgSrc+"' />";
		if(IsIE())
		{
			var sel = textboxDocumentObject.createElement(textToBeInserted);
			textboxDocumentObject.body.insertBefore(sel);
			sel.unselectable = "on";
		}
		else
		{
			textboxDocumentObject.execCommand("InsertImage",false,imgSrc);
		}
	}
}
function InsertDocument(pdfPic, docDescription, docURL)
{
	var pdfImgText = "<img src="+pdfPic+" />";
	var linkText = "<a href='"+docURL+"'>ggg</a>";
	if(IsIE())
	{
		var linkObj = textboxDocumentObject.createElement(linkText);
		linkObj.innerHTML = pdfImgText + docDescription;
		textboxDocumentObject.body.insertBefore(linkObj);
	}
	else
	{
		var el = textboxDocumentObject.createElement("a");
		el.innerHTML = pdfImgText + docDescription;
		el.href = docURL;
		textboxDocumentObject.body.appendChild(el);
	}
}
function getOffsetTop(elm)
{
  var mOffsetTop = elm.offsetTop;
  var mOffsetParent = elm.offsetParent;
  while(mOffsetParent)
  {
    mOffsetTop += mOffsetParent.offsetTop;
    mOffsetParent = mOffsetParent.offsetParent;
  }
  return mOffsetTop;
}
function getOffsetLeft(elm)
{
  var mOffsetLeft = elm.offsetLeft;
  var mOffsetParent = elm.offsetParent;
  while(mOffsetParent)
  {
    mOffsetLeft += mOffsetParent.offsetLeft;
    mOffsetParent = mOffsetParent.offsetParent;
  }
	return mOffsetLeft;
}
function ProcessRequest(text)
{
  if(null == text || "" == text)
		return;
  document.getElementById(iframeID).contentWindow.focus();
  var sel = document.getElementById(iframeID).contentWindow.document.selection.
		createRange();
  sel.pasteHTML(text);
  sel.select();
}
var action = "post";
var postID = null;
function GetElement(sender)
{
  var postText;
  if(sender.id.indexOf("reply") != -1)
  {
    SetSubmitPost_Text("Antwort abschicken");
    postText = "";
    postID = sender.id.split("|")[1];
  }
  else if(sender.id.indexOf("edit") != -1)
  {
    action = "edit";
    postID = sender.id.split("_")[1];
    postText = getDOMObject(
			sender.id.replace("hrefedit","postText")).innerHTML;
    SetSubmitPost_Text("Editiere Beitrag");
  }
  else if(sender.id.indexOf("quote") != -1)  
  {
    action = "quote";
    postID = sender.id.split("|")[1];
    var postUserName = sender.id.split("|")[2];
    postText = getDOMObject("postText_"+postID).innerHTML;
    postText = "<div class='quoteContainer'>"+
			"<span class='quoteTitle'>"+postUserName + " schrieb: </span>"+
			"<div class='quoteText'> "+postText +
			"</div></div><br /><br />";
    SetPostHeader_Text("Zitieren");
  }
  if(IsIE())
  {
    textboxObject.focus();
    textboxDocumentObject.execCommand("SelectAll", false, null);
    textboxDocumentObject.selection.clear();
    var range = textboxDocumentObject.selection.createRange();
    range.pasteHTML(postText);
    range.select();
    textboxDocumentObject.execCommand("SelectAll", false, null);
    textboxDocumentObject.selection.empty();
  }
  else
  {
		textboxObject.focus();
		textboxDocumentObject.body.innerHTML = postText;
		var newP = textboxDocumentObject.createElement("p");
		newP.innerHTML = "&nbsp;";
		textboxDocumentObject.body.appendChild(newP);
  }
}
function GetPersonalMessageElement(sender)
{
	var postText;
	if (sender.id.indexOf("reply") != -1) {
		location.hash = "#Post";
		SetSubmitPost_Text("Antwort abschicken");
		SetPostHeader_Text(sender.id.split("|")[2]);
		postText = '';
	} // if (sender.id.indexOf)
	else if (sender.id.indexOf("quote") != -1) {
	location.hash = "#Post";
	postID = sender.id.split("|")[1];
	var postUserName = sender.id.split("|")[2];
	var postGuestbookOwner = sender.id.split("|")[3];
	var postDate = sender.id.split("|")[4];
	postText = getDOMObject("postText_" + postID).innerHTML;
	postText = "<br /><br /><div class='quoteContainer'>" +
			"<span class='quoteTitle'>Antwort auf " +
			(postUserName == "" ? "" :
			"<a href='/User/" + postUserName + "#Guestbook'>" +
			postUserName + "</a>'s Eintrag ") +
			(postGuestbookOwner == postUserName ? "" :
			(postUserName == "" ? "" : "bei ") +
			"<a href='/User/" + postGuestbookOwner +
			"#Guestbook'>" + postGuestbookOwner + "</a> ") +
			"am " + postDate + ": </span>" +
			"<div class='quoteText'> " + postText +
			"</div></div>";
	SetSubmitPost_Text("Antwort auf " + postGuestbookOwner);
	SetPostHeader_Text(postUserName);
	} // else if
  if(IsIE())
  {
    textboxObject.focus();
    textboxDocumentObject.execCommand("SelectAll", false, null);
    textboxDocumentObject.selection.clear();
    var range = textboxDocumentObject.selection.createRange();
    range.pasteHTML(postText);
    range.select();
    textboxDocumentObject.execCommand("SelectAll", false, null);
    textboxDocumentObject.selection.empty();
  }
  else
  {
		textboxObject.focus();
		textboxDocumentObject.body.innerHTML = postText;
		var newP = textboxDocumentObject.createElement("p");
		newP.innerHTML = "&nbsp;";
		textboxDocumentObject.body.appendChild(newP);
  }
 }

 function GetGuestbookElement(sender) 
{
  var postText;
  if (sender.id.indexOf("edit") != -1) {
  	location.hash = "#Post";
  	action = "edit";
  	postID = sender.id.split("_")[1];
  	postText = getDOMObject(sender.id.replace("hrefedit", "postText")).innerHTML;
  	SetSubmitPost_Text("Editiere Beitrag");
  }
  else if (sender.id.indexOf("reply") != -1) {
		location.hash = "#Post";
  	action = "reply";
  	postID = sender.id.split("|")[1];
  	var postUserName = sender.id.split("|")[2];
  	var postGuestbookOwner = sender.id.split("|")[3];
  	var postDate = sender.id.split("|")[4];
  	postText = "";
  	SetSubmitPost_Text("Antwort bei " + postGuestbookOwner);
  }
  else if (sender.id.indexOf("quote") != -1) {
		location.hash = "#Post";
  	action = "quote";
  	postID = sender.id.split("|")[1];
  	var postUserName = sender.id.split("|")[2];
  	var postGuestbookOwner = sender.id.split("|")[3];
  	var postDate = sender.id.split("|")[4];
  	postText = getDOMObject("postText_" + postID).innerHTML;
  	postText = "<br /><br /><div class='quoteContainer'>" +
			"<span class='quoteTitle'>Antwort auf " +
			(postUserName == "" ? "" :
			"<a href='/User/" + postUserName + "#Guestbook'>" +
			postUserName + "</a>'s Eintrag ") +
			(postGuestbookOwner == postUserName ? "" :
			(postUserName == "" ? "" : "bei ") +
			"<a href='/User/" + postGuestbookOwner +
			"#Guestbook'>" + postGuestbookOwner + "</a> ") +
			"am " + postDate + ": </span>" +
			"<div class='quoteText'> " + postText +
			"</div></div>";
  	SetSubmitPost_Text("Antwort auf " + postGuestbookOwner);
  }
  else if (sender.id.indexOf("delete") != -1) {

		//location.hash = "#Post";
		action = "delete";
		postID = sender.id.split("|")[1];
		var postUserName = sender.id.split("|")[2];
		var postGuestbookOwner = sender.id.split("|")[3];
		// Handle deletion on server
		sender.href = "/User/" + postGuestbookOwner +
			"?DeleteGuestbookEntry=" + postID;
  } // else if
  else {
  	//location.hash = "#Post";
  	SetSubmitPost_Text("Eintrag abschicken");
  	postText = '';
  }
  if(IsIE())
  {
		textboxObject.focus();
		textboxDocumentObject.execCommand("SelectAll", false, null);
		textboxDocumentObject.selection.clear();    
		var range = textboxDocumentObject.selection.createRange();
		range.pasteHTML(postText);   
		range.select();        
		textboxDocumentObject.execCommand("SelectAll", false, null);
		textboxDocumentObject.selection.empty();  
  }
  else
  {
		textboxObject.focus();
		textboxDocumentObject.body.innerHTML = postText;
		var newP = textboxDocumentObject.createElement("p");
		newP.innerHTML = "&nbsp;";
		textboxDocumentObject.body.appendChild(newP);
  }
  FocusTxtBox();
}
function btnCancel_Click()
{
  var obj = getDOMObject(iframeID);
  obj.contentWindow.document.body.innerHTML = "";
  SetSubmitPost_Text("Neuen Eintrag abschicken");
  SetPostHeader_Text("Neuen Beitrag schreiben");
}
function btnSumbitPost_Click(postEditTextBox_ClientID)
{
	getDOMObject('postTextBoxHiddenID').value =
		getDOMObject(postEditTextBox_ClientID).contentWindow.document.body.innerHTML;
	var value = "post|";
	if(null != postID)
	{
		value = action + "|" + postID;
		postID = null;
	}
	if (getDOMObject('postActionHiddenField') != null) {
		getDOMObject("postActionHiddenField").value = value;
	}
}
function SetSubmitPost_Text(text)
{
  var inputObjs = document.getElementsByTagName("input");    
  for(var i=inputObjs.length-1 ; i>=0;i--)
  {
    if(inputObjs[i].type=="submit" &&
	    inputObjs[i].onclick != null &&
			inputObjs[i].onclick.toString().indexOf("btnSumbitPost_Click")!=-1)
    {
      inputObjs[i].value = text;
      return;
    }
  }
}
function SetPostHeader_Text(text)
{
  var inputObjs = document.getElementsByTagName("input");    
  for(var i=0; i<inputObjs.length; i++)
  {
    if(inputObjs[i].type=="text" &&
	    inputObjs[i].id.indexOf("postcontrol1_txtSubject")!=-1)
    {        
      inputObjs[i].value = text;
      return;
    }
  }
}
function FocusTxtBox()
{
  getDOMObject(iframeID).contentWindow.focus();
  try
  {
		getDOMObject(iframeID).contentWindow.document.selection.createRange();
  }
  catch (e)
  {
  }
}
