
function createRoundedCorners()
{
	var content = document.getElementById("content").innerHTML;
	var test = content;
	var index = 0;
	while (content.indexOf(">", index) != -1)
	{
		startTag = content.indexOf("<", index);
		stopTag = content.indexOf(">", index);
		tag = content.substring(startTag, stopTag);
		index = stopTag + 1;
	}

	while (content.indexOf("<img", 0) != -1)
	{
		startPosition = content.indexOf("<img", 0);
		stopPosition = content.indexOf(">", startPosition) + 1;
		image = content.substring(startPosition, stopPosition);
		if (image.indexOf("rel='no_rounded_corners'") != -1 || image.indexOf('rel="no_rounded_corners"') != -1)
		{
			contentFirst = content.substring(0, startPosition);
			contentLast = content.substring(startPosition+4);
			content = contentFirst + "<-img" + contentLast;
		} else {
			startPositionSrc = image.indexOf("src=", 0) + 5;
			stopPositionSrc = image.indexOf("\"", startPositionSrc);
			if (stopPositionSrc == -1)
			{
				stopPositionSrc = image.indexOf("'", startPositionSrc);
			}
			source = image.substring(startPositionSrc, stopPositionSrc);
			startPositionStyle = image.indexOf("style=", 0) + 7;
			stopPositionStyle = image.indexOf("\"", startPositionStyle);
			if (stopPositionStyle == -1)
			{
				stopPositionStyle = image.indexOf("'", startPositionStyle);
			}
			style = image.substring(startPositionStyle, stopPositionStyle);
			var newImage = new Image();
			newImage.src = source;
			cssSize = "width: " + newImage.width + "px; height: " + newImage.height + "px;";
			cssSizeCorner = "width: " + Math.round((newImage.width/2)-1) + "px; height: " + Math.round(newImage.height/2) + "px;";
			imageDiv = '<div class="image" style="' + style + '; background-image: url(\'' + source + '\'); ' + cssSize + '"><div class="lt" style="' + cssSizeCorner + '"></div><div class="rt" style="' + cssSizeCorner + '"></div><div class="lb" style="' + cssSizeCorner + '"></div><div class="rb" style="' + cssSizeCorner + '"></div></div>';
			content = content.replace(image, imageDiv);
			content = content.replace("&amp;", "&");
		}
	}
	content = content.replace(/<-img/g, "<img");
	document.getElementById("content").innerHTML = content;
}

function switchSponsorLogo(index)
{
	var logos = new Array("files/sponsors/he.jpg", "files/sponsors/dk.jpg", "files/sponsors/vriendenclub.jpg");
	if (index+1 >= logos.length)
	{
		index = 0;
	} else
	{
		index = index + 1;
	}

	document.getElementById("sponsors").src = logos[index];
	setTimeout('switchSponsorLogo(' + index + ')', 2000);
}

function insertUBB(startTag, endTag) {
	obj = document.getElementById("message");
  //IE support
  if (document.selection) {
    obj.focus();
    selection = document.selection.createRange();
    selection.text = startTag + selection.text + endTag;
  }
  //MOZILLA/NETSCAPE support
  else if (obj.selectionStart || obj.selectionStart == '0') {
    obj.value = obj.value.substring(0, obj.selectionStart)
                  + startTag + obj.value.substring(obj.selectionStart, obj.selectionEnd) + endTag
                  + obj.value.substring(obj.selectionEnd, obj.value.length);
  } else {
    myField.value += myValue;
  }
}

function openEmoticons() {
	popup_width = 218;
	popup_height = 302;
	var left_position = (screen.width/2)-(popup_width/2);
	var top_position = (screen.height/2)-(popup_height/2);
	window.open("images/emoticons/emoticons.html", "", "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+popup_width+",height="+popup_height+",left ="+left_position+",top="+top_position);

}
