﻿	var showvalue,hidevalue;
	var tpid,poid,urls="/Community/Forum.aspx";
	var	isauth=0,islog=true;
	var onick,unick;
	var rf=true,mf=true;
	var pleft,ptop;
	var caid;
	var getRefById;
	var startLink;
	var newText;

	showvalue='visible';
	hidevalue='hidden';

	// QUICK OBJECT REFERENCE
	if(document.getElementById) {
		getRefById = function(id){
			return document.getElementById(id);
		};
	} else if(document.all) {
		getRefById = function(id) {
	return document.all[id];
	};
	} else {
		getRefById = function() {
	return null;
	};
	}

	/* SCRIPTS FOR MOD OPTIONS MENU */
	function showMenu(prod,tp,po,evnt){
		var obj;	
		if(islog){
			tpid=tp;
			poid=po;
			
			for (var i = 0; i<document.aspnetForm.elements.length; i++) {
				if (document.aspnetForm.elements[i].name.indexOf('lblTpid') > -1) {
					document.aspnetForm.elements[i].value=tpid ;
					i=document.aspnetForm.elements.length;
				}
				else  if (document.aspnetForm.elements[i].name.indexOf('lblPoid') > -1) {
					document.aspnetForm.elements[i].value=poid ;
					i=document.aspnetForm.elements.length;
				}
			}
			
			obj = document.getElementById(prod).style;	
			
			pleft = evnt.clientX-20+document.body.scrollLeft+"px";
			ptop = evnt.clientY+10+document.documentElement.scrollTop+"px";
			
			obj.left = pleft;
			obj.top = ptop;
			
			obj.clip = "rect(0px 220px 430px 0px)";		
			obj.visibility=showvalue;

		}else{
			alert("You need to log in first to use this feature");
		}
	}

	function nop(){
		// not sure why this function is still here?
	}

	function hideMenu(prod){
		var obj;
		obj = document.getElementById(prod).style;		
		obj.visibility = hidevalue;	
	}

	// ADD HTML TAGS TO TEXT
	function formatText(el,tag,type) {
		var selectedText = document.selection?document.selection.createRange().text:el.value.substring(el.selectionStart,el.selectionEnd);
		// remove 'http://' if the user typed it into the string, as it will be automatically added in this script to ensure usability
		if(selectedText.match("http://")===null){
			startLink = "http://";
		}else{
			startLink = "";
		}
		// wrap tag around text
		if(selectedText!==''){
			switch (type){
			case "normal":
				newText='<'+tag+'>'+selectedText+'</'+tag+'>';
				break;
			case "link":
				// check if what the user has typed is formatted as a URL, if so, insert the url into href
				if(selectedText.match("http://")!==null||selectedText.match("www.")!==null){
					newText='<a href="'+startLink+selectedText+'" target="_blank">'+selectedText+'</a>';
				} else{
					newText='<a href="INSERT YOUR LINK URL HERE" target="_blank">'+selectedText+'</a>';
				}
				break;
			case "image":
				if(selectedText.match("http://")!==null||selectedText.match("www.")!==null){
					newText='<img src="'+startLink+selectedText+'" border="0" alt="" />';
				} else{
					newText='<img src="INSERT YOUR IMAGE URL HERE" border="0" alt="" />';
				}
				break;
			}
			el.value=el.value.replace(selectedText,newText);
		}
		// add tags at cursor
		else {
			//IE support
			if (document.selection) {
				el.focus();
				sel = document.selection.createRange();
				switch (type){
				case "normal":
					sel.text = '<'+tag+'>'+'</'+tag+'>';
					break;
				case "link":
					sel.text = '<a href="INSERT YOUR LINK URL HERE" target="_blank">INSERT YOUR LINK TEXT HERE</a>';
					break;
				case "image":
					sel.text = '<img src="INSERT YOUR IMAGE URL HERE" alt="" border="0" />';
					break;
				}
			}			
			//Mozilla/Netscape support
			else if (el.selectionStart || el.selectionStart == '0') {
				var startPos = el.selectionStart;
				var endPos = el.selectionEnd;
				var beforeText = el.value.substring(0, startPos);
				var afterText = el.value.substring(endPos, el.value.length);
				switch(type){
				// el.value is the text in the textbox (not just what is currently selected)
				case "normal":
					el.value = beforeText + '<'+tag+'>'+'</'+tag+'>'+afterText;
					break;
				case "link":
					el.value = beforeText + '<a href="INSERT YOUR LINK URL HERE" target="_blank">INSERT YOUR LINK TEXT HERE</a>'+afterText;
					break;
				case "image":
					el.value = beforeText + '<img src="INSERT YOUR IMAGE URL HERE" alt="" border="0" />'+afterText;
					break;
				}
				}
			}	
		}

	// INSERT SMILIES INTO TEXTBOX
	function insertText(str,id) {
	var e = getRefById(id), s = null, r = null;

	if(e) {
	if((s = document.selection) && s.createRange) {
	var repos = false;

	/* Element must have focus otherwise text
	* will be written into other elements. */
	e.focus();
	if((r = s.createRange())) {
	if(r.text.length) {repos = true;}
	r.text = str;
	/* Clear the selection to stop continuous
	* overwriting of inserted text. */
	if(repos && s.empty) {s.empty();}
	}
	} else {
	e.value += str;
	}
	}
	}