function insertTag(startTag, endTag, inputName) {
	
	var inputBox = document.getElementById(inputName);
	var startPos = inputBox.selectionStart;
    var endPos = inputBox.selectionEnd;
    var selectedText = inputBox.value.substring(startPos, endPos);
    
	inputBox.value = inputBox.value.substr(0, startPos) + startTag + selectedText + endTag + inputBox.value.substr(endPos);
    
    var position;
    if (selectedText.length == 0) {
      position = startPos + startTag.length;
    } else {
      position = startPos + startTag.length + selectedText.length + endTag.length;
    }
	
    inputBox.selectionStart = position;
    inputBox.selectionEnd = position;
	inputBox.focus();
}

function SwitchVisibility(id) {

	var allCodes = document.getElementById("content").getElementsByTagName("table");
	var allTabs = document.getElementById("content").getElementsByTagName("span");
	
	if (id == 1) {
		for (var i = 0; i < allCodes.length; i++) {
			if (allCodes[i].className == "vbnet") {
				allCodes[i].style.display = "block";
				
			} else if (allCodes[i].className == "csharp") {
				allCodes[i].style.display = "none";
			}
		}
		
		for (var i = 0; i < allTabs.length; i++) {
			if (allTabs[i].className == "vbnetTab") {
				allTabs[i].style.borderBottomColor = "#F8F4EE";
				
			} else if (allTabs[i].className == "csharpTab") {
				allTabs[i].style.borderBottomColor = "#000";
			}
		}
		
	} else if (id == 2) {
		for (var i = 0; i < allCodes.length; i++) {
			if (allCodes[i].className == "vbnet") {
				allCodes[i].style.display = "none";
				
			} else if (allCodes[i].className == "csharp") {
				allCodes[i].style.display = "block";
			}
		}
		
		for (var i = 0; i < allTabs.length; i++) {
			if (allTabs[i].className == "vbnetTab") {
				allTabs[i].style.borderBottomColor = "#000";
				
			} else if (allTabs[i].className == "csharpTab") {
				allTabs[i].style.borderBottomColor = "#F8F4EE";
			}
		}
	}

}

function ShowHide (itemID) {
	if (document.getElementById(itemID).style.display == "none") {
		document.getElementById(itemID).style.display = "block";
	} else {
		document.getElementById(itemID).style.display = "none";
	}
}
