

// array which holds the currently opened tags
var arr_mykeys = new Array();

// currently selected text
var selected_data = "";

// text which is to be added to the post
var PostMessage = "";

// form object that has to be used
var currentform = "";

var vbphrase = {

	// standard only
	"enter_text_to_be_formatted" : "Enter the text to be formatted",
	"enter_link_text" : "Enter the text to be displayed for the link (optional):",
	"enter_list_type" : "What type of list do you want? Enter '1' for a numbered list, enter 'a' for an alphabetical list, or leave blank for a list with bullet points:",
	"enter_list_item" : "Enter a list item.\nLeave the box empty or press 'Cancel' to complete the list:",

	// both
	"must_enter_subject" : "You must enter a title / subject!",
	"message_too_short" : "The message you have entered is too short. Please lengthen your message to at least %1$s characters.",
	"enter_link_url" :  "Please enter the URL of your link:",
	"enter_image_url" : "Please enter the URL of your image:",
	"enter_email_link" : "Please enter the email address for the link:",
	"message_too_big" : "The message you have entered is too big. Please lengthen your message to less than 3000 characters."
};

function validatePost(tform, subjectVal, minLength, maxLength)
{
	return validatemessage(tform.message.value, subjectVal, minLength, maxLength, false, tform);
}

// #############################################################################

// #############################################################################
// function to initialize the editor
function webeditor_load()
{
	if (editor_loaded)
	{
		// editor is already loaded, don't try to load it again, as that would be bad m'kay.
		return;
	}

	if (!is_ie4 && !is_ns4)
	{
		// make all toolbar elements unselectable
		set_unselectable(getInstance("controlbar"));
		if (getInstance("smiliebox"))
		{
			set_unselectable(getInstance("smiliebox"));
		}

		// init buttons
		divs = getInstance("controlbar").getElementsByTagName("div");
		for (var i  = 0; i < divs.length; i++)
		{
			elm = divs[i];
			switch (elm.className)
			{
				case "imagebutton":
				{
					elm.onmouseover = elm.onmouseout = elm.onmouseup = elm.onmousedown = button_eventhandler;
				}
				break;
			}
		}
	}

	currentform = document.forms.vbform;
	
}

// #############################################################################
// function to handle incoming events from buttons (part 1)
function button_eventhandler(e, elm)
{
	if (is_v4)
	{ //its ie4 and it doens't support try / catch or even changing style of a button
		//return false;
	}

	e = getEvent(e);

	switch (e.type)
	{
		case "mousedown":
		{
			format_control(elm ? elm : this, "button", "down");
		}
		break;

		case "mouseover":
		case "mouseup":
		{
			format_control(elm ? elm : this, "button", "hover");
		}
		break;

		default:
		{
			format_control(elm ? elm : this, "button", "normal");
		}
	}
}

// #############################################################################
// function used to check that the value in the array we're using is valid
function is_array(myarray, key)
{
	if ((myarray[key] == "undefined") || (myarray[key] == "") || (myarray[key] == null))
	{
		return false;
	}
	else
	{
		return true;
	}
}

// #############################################################################
// emulation of PHP's sizeof function
function getarraysize(myarray)
{
	for (i = 0; i < myarray.length; i++)
	{
		if (!is_array(myarray, i))
		{
			return i;
		}
	}
	return myarray.length;
}

// #############################################################################
// emulation of PHP's array_push function
function array_push(thearray, value)
{
	var thearraysize = getarraysize(thearray);
	thearray[thearraysize] = value;
	return thearray[thearraysize];
}

// #############################################################################
// emulation of PHP's array_pop function
function array_pop(thearray)
{
	var thearraysize = getarraysize(thearray);
	var retval = thearray[thearraysize - 1];
	delete thearray[thearraysize - 1];
	return retval;
}

// #############################################################################
function setmode(modevalue)
{
	closeall(currentform);
	if (modevalue == 1)
	{
		normalmode = false;
	}
	else
	{
		normalmode = true;
	}
	document.cookie = "vbcodemode=" + modevalue + "; path=/; expires=Wed, 1 Jan 2020 00:00:00 GMT;";
}

// #############################################################################

function getSelText()
{
    var txt = '';
     if (window.getSelection)
    {
        txt = window.getSelection();
             }
    else if (document.getSelection)
    {
        txt = document.getSelection();
            }
    else if (document.selection)
    {
        txt = document.selection.createRange().text;
    }
    else return;
    return txt;
}


function getActiveText()
{
	
	
	if (!is_ie || (is_ie && !document.selection))
	{ 
	
	
		return false;
	}


	var sel = getSelText();
	
	selected_data = sel;
	
	return true;
}

// #############################################################################
function AddText(NewCode)
{
	var obj=document.getElementById("ctl00_ContentPlaceHolderBody_TextArea");
	
		
	
	if (obj.value!=" ")
	{
		
		var caretPos = document.selection.createRange();
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? NewCode + ' ' : NewCode;
	    
	}
	
	else
	{
	
		obj.value += NewCode;
		
	}
	obj.focus();
	getActiveText();
	PostMessage = "";
}

// #############################################################################
function vbcode(vbcode, prompttext)
{
	if (typeof currentform != "object" && typeof must_click_message != "undefined")
	{ // QR check
	
		alert(must_click_message);
		return false;
	}
	

	// lets call this when they try and use vbcode rather than on change
//var selected_data =	getActiveText();
	//alert(selected_data)
	getActiveText();

    if (selected_data=="")	
    {
        alert("Select Text:")
    }
    else 
    {
	      ////  if (selected_data)

        	
	       //// { // its IE to the rescue
        	

        	
		        if (selected_data.substring(0, vbcode.length + 2 ) == "[" + vbcode + "]" && selected_data.substring(selected_data.length - vbcode.length - 3, selected_data.length) == "[/" + vbcode + "]")
		        {
			        PostMessage = selected_data.substring(vbcode.length + 2, selected_data.length - vbcode.length - 3);
		        }
		        else
		        {
			        PostMessage = "[" + vbcode + "]" + selected_data + "[/" + vbcode + "]";
        			
		        }
		        AddText(PostMessage);
	     ////   }
    }
//else if (selected_data=="")	
//    {
//        alert("Select Text:")
//    }


//	else if (currentform.message.selectionEnd && (currentform.message.selectionEnd - currentform.message.selectionStart > 0))
//	{ 
//	
//		var start_selection = currentform.message.selectionStart;
//		var end_selection = currentform.message.selectionEnd;
//		
//		if (end_selection <= 2)
//		{
//			end_selection = currentform.message.textLength;
//		}

//		// fetch everything from start of text area to selection start
//		var start = (currentform.message.value).substring(0, start_selection);
//		// fetch everything from start of selection to end of selection
//		var middle = (currentform.message.value).substring(start_selection, end_selection);
//		// fetch everything from end of selection to end of text area
//		var end = (currentform.message.value).substring(end_selection, currentform.message.textLength);

//		if (middle.substring(0, vbcode.length + 2 ) == "[" + vbcode + "]" && middle.substring(middle.length - vbcode.length - 3, middle.length) == "[/" + vbcode + "]")
//		{
//			middle = middle.substring(vbcode.length + 2, middle.length - vbcode.length - 3);
//		}
//		else
//		{
//			middle = "[" + vbcode + "]" + middle + "[/" + vbcode + "]";
//		}

//		currentform.message.value = start + middle + end;
//	}
//	else
//	{
//		if (!normalmode)
//		{
//			var donotinsert = false;
//			var thetag = 0;
//			for (i = 0; i < arr_mykeys.length; i++)
//			{
//				if (arr_mykeys[i] == vbcode)
//				{
//					donotinsert = true;
//					thetag = i;
//				}
//			}

//			if (!donotinsert)
//			{
//				array_push(arr_mykeys, vbcode);
//				PostMessage = "[" + vbcode + "]";
//				AddText(PostMessage);
//			}
//			else
//			{ // its already open
//				var closedtag = "";
//				while (arr_mykeys[thetag])
//				{
//					closedtag = array_pop(arr_mykeys);
//					PostMessage = "[/" + closedtag + "]";
//					AddText(PostMessage);
//				}
//			}
//		}
//		else
//		{
//		
//			inserttext = prompt(vbphrase["enter_text_to_be_formatted"] + "\n[" + vbcode + "]xxx[/" + vbcode + "]", prompttext);
//			if ((inserttext != null) && (inserttext != ""))
//			{
//				PostMessage = "[" + vbcode + "]" + inserttext + "[/" + vbcode + "] ";
//			}
//			AddText(PostMessage);
//		}
//	}
//	currentform.message.focus();
//	return false;
}

// #############################################################################
function fontformat(thevalue, thetype)
{
	getActiveText();

    if (selected_data=="")	
    {
        alert("Select Text:")
    }
    else
    {
    
	    ////    if (selected_data)
	      ////  { // its IE to the rescue
		        PostMessage = "[" + thetype + "=" + thevalue + "]" + selected_data + "[/" + thetype + "]";
		        AddText(PostMessage);
	      ////  }
	}
//	if (selected_data=="")	
//    {
//        alert("Select Text:")
//    }
//	else if (currentform.message.selectionEnd && (currentform.message.selectionEnd - currentform.message.selectionStart > 0))
//	{ // its mozilla and we'll need to re-write entire text
//		var start_selection = currentform.message.selectionStart;
//		var end_selection = currentform.message.selectionEnd;
//		if (end_selection <= 2)
//		{
//			end_selection = currentform.message.textLength;
//		}

//		// fetch everything from start of text area to selection start
//		var start = (currentform.message.value).substring(0, start_selection);
//		// fetch everything from start of selection to end of selection
//		var middle = (currentform.message.value).substring(start_selection, end_selection);
//		// fetch everything from end of selection to end of text area
//		var end = (currentform.message.value).substring(end_selection, currentform.message.textLength);

//		middle = "[" + thetype + "=" + thevalue + "]" + middle + "[/" + thetype + "]";

//		currentform.message.value = start + middle + end;
//	}
//	else
//	{
//		if (!normalmode)
//		{
//			var donotinsert = false;
//			var thetag = 0;
//			for (i = 0; i < arr_mykeys.length; i++)
//			{
//				if (arr_mykeys[i] == thetype)
//				{
//					donotinsert = true;
//					thetag = i;
//				}
//			}

//			if (!donotinsert)
//			{
//				array_push(arr_mykeys, thetype);
//				PostMessage = "[" + thetype + "=" + thevalue + "]";
//				AddText(PostMessage);
//			}
//			else
//			{ // its already open
//				var closedtag = "";
//				while (arr_mykeys[thetag])
//				{
//					closedtag = array_pop(arr_mykeys);
//					PostMessage = "[/" + closedtag + "]";
//					AddText(PostMessage);
//				}
//			}
//		}
//		else
//		{
//			inserttext = prompt(vbphrase["enter_text_to_be_formatted"] + "\n[" + thetype + "=" + thevalue + "]xxx[/" + thetype + "]");
//			if ((inserttext != null) && (inserttext != ""))
//			{
//				PostMessage = "[" + thetype + "=" + thevalue + "]" + inserttext + "[/" + thetype + "]";
//				AddText(PostMessage);
//			}
//		}
//		
//	}
//	

//	currentform.sizeselect.selectedIndex = 0;
//	currentform.fontselect.selectedIndex = 0;
//	currentform.colorselect.selectedIndex = 0;
//	currentform.message.focus();
//	return false;
}

// #############################################################################
function namedlink(thetype)
{
	var extraspace = "";

	getActiveText();
	if (selected_data)
	{
		var dtext = selected_data;
	}
	else
	{
		var dtext = "";
		extraspace = " ";
	}
	
	linktext = prompt(vbphrase["enter_link_text"], dtext);
	
	var prompttext, prompt_contents;
	if (thetype == "URL")
	{
		prompt_text = vbphrase["enter_link_url"];
		prompt_contents = "http://";
	}
	else
	{
		prompt_text = vbphrase["enter_email_link"];
		prompt_contents = "";
	}
	var linkurl = prompt(prompt_text, prompt_contents);
	if ((linkurl != null) && (linkurl != ""))
	{
		if ((linktext != null) && (linktext != ""))
		{
			PostMessage = "[" + thetype + "=" + linkurl + "]" + linktext + "[/" + thetype + "]" + extraspace;
			AddText(PostMessage);
		}
		else
		{
			PostMessage = "[" + thetype + "]" + linkurl + "[/" + thetype + "]" + extraspace;
			AddText(PostMessage);
		}
	}
}

// #############################################################################
function dolist()
{
	var listtype = prompt(vbphrase["enter_list_type"], "");

	if ((listtype == "a") || (listtype == "1") || (listtype == "i"))
	{
		thelist = "[list=" + listtype + "]\n";
	}
	else
	{
		thelist = "[list]\n";
	}
	var listentry = "initial";
	while ((listentry != "") && (listentry != null))
	{
		listentry = prompt(vbphrase["enter_list_item"], "");
		if ((listentry != "") && (listentry != null))
		{
			thelist = thelist + "[*]" + listentry + "\n";
		}
	}
	PostMessage = thelist + "[/list]";
	if (!selected_data)
	{
		PostMessage = PostMessage + " ";
	}
	AddText(PostMessage);
}

// #############################################################################
function smilie(thesmilie)
{
	getActiveText();
	var AddSmilie = " " + thesmilie + " ";
	AddText(AddSmilie);
}

// define a few variables that are required
var isnochars = 0;

// #############################################################################
// lets define the browser we have instead of multiple calls throughout the file
var browsertype = navigator.userAgent.toLowerCase();
var is_opera  = (browsertype.indexOf('opera') != -1);
var is_saf    = ((browsertype.indexOf('safari') != -1) || (navigator.vendor == "Apple Computer, Inc."));
var is_webtv  = (browsertype.indexOf('webtv') != -1);
var is_ie     = ((browsertype.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
var is_ie4    = ((is_ie) && (browsertype.indexOf("msie 4.") != -1));
var is_moz    = ((navigator.product == 'Gecko') && (!is_saf));
var is_kon    = (browsertype.indexOf('konqueror') != -1);
var is_ns     = ((browsertype.indexOf('compatible') == -1) && (browsertype.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_saf));
var is_ns4    = ((is_ns) && (parseInt(navigator.appVersion) == 4));

// catch possible bugs with WebTV and other older browsers
var is_regexp = (window.RegExp) ? true : false;

// #############################################################################
// let's find out what DOM functions we can use
var vbDOMtype = '';
if (document.getElementById)
{
	vbDOMtype = "std";
}
else if (document.all)
{
	vbDOMtype = "ie4";
}
else if (document.layers)
{
	vbDOMtype = "ns4";
}

// make an array to store cached locations of objects called by fetch_object
var vBobjects = new Array();

// #############################################################################
// function to emulate document.getElementById
function getInstance(idname, forcefetch)
{
	if (forcefetch || typeof(vBobjects[idname]) == "undefined")
	{
		switch (vbDOMtype)
		{
			case "std":
			{
				vBobjects[idname] = document.getElementById(idname);
			}
			break;

			case "ie4":
			{
				vBobjects[idname] = document.all[idname];
			}
			break;

			case "ns4":
			{
				vBobjects[idname] = document.layers[idname];
			}
			break;
		}
	}
	return vBobjects[idname];
}

// #############################################################################
// function to handle the different event models of different browsers
// and prevent event bubbling
function getEvent(eventSource)
{
	if (!eventSource || is_ie)
	{
		window.event.returnValue = false;
		window.event.cancelBubble = true;
		return window.event;
	}
	else
	{
		eventSource.stopPropagation();
		eventSource.preventDefault();
		return eventSource;
	}
}

// #############################################################################
// #############################################################################
// function to do a single-line conditional ternary
function ternary (criteria, doval, noval)
{
	return criteria ? doval : noval;
}

// #############################################################################
// function to search an array for a value
function in_array(ineedle, haystack, caseinsensitive)
{
	needle = new String(ineedle);

	if (caseinsensitive)
	{
		needle = needle.toLowerCase();
		for (i in haystack)
		{
			if (haystack[i].toLowerCase() == needle)
			{
				return i;
			}
		}
	}
	else
	{
		for (i in haystack)
		{
			if (haystack[i] == needle)
			{
				return i;
			}
		}
	}
	return -1;
}

function js_toggle_all(formobj, formtype, option, exclude, setto)
{
	for (var i =0; i < formobj.elements.length; i++)
	{
		var elm = formobj.elements[i];
		if (elm.type == formtype && in_array(elm.name, exclude, false) == -1)
		{
			switch (formtype)
			{
				case "radio":
					if (elm.value == option) // option == '' evaluates true when option = 0
					{
						elm.checked = setto;
					}
				break;
				case "select-one":
					elm.selectedIndex = setto;
				break;
				default:
					elm.checked = setto;
				break;
			}
		}
	}
}



// #############################################################################
// function to check message length before form submission
function validatemessage(messageText, subjectText, minLength, maxLength, ishtml, tForm)
{
	// bypass Safari and Konqueror browsers with Javascript problems
	if (is_kon || is_saf || is_webtv)
	{
		return true;
	}

	// attempt to get a code-stripped version of the text
	var strippedMessage = stripcode(messageText, ishtml, isnochars);

	// COMMENTED BY KISHORE
	// check for completed subject
	if (subjectText.length < 1)
	{
	//	alert(vbphrase["must_enter_subject"]);
	//	return false;
	}
	// check for minimum message length
	// COMMENTED BY KISHORE
	//else 
	if (strippedMessage.length < minLength)
	{
		alert(buildphrase(vbphrase["message_too_short"], minLength));
		return false;
	}
	//shiva added
	
	if (strippedMessage.length > maxLength)
	{
		alert(buildphrase(vbphrase["message_too_big"], maxLength));
		return false;
	}
	//shiva closed
	// everything seems okay
	else
	{
		//alert("Everything OK");
		//window.opener.frmMain.pol.value=vbform.message.value;
		window.opener.addClientString(vbform.message.value);
		
		window.close();
		return true;
	}
}

// #############################################################################
// function to trim quotes and vbcode tags
function stripcode(str, ishtml, stripquotes)
{
	if (!is_regexp)
	{
		return str;
	}

	if (stripquotes)
	{
		var quote1 = new RegExp("(\\[QUOTE\\])(.*)(\\[\\/QUOTE\\])", "gi");
		var quote2 = new RegExp("(\\[QUOTE=(&quot;|\"|\\'|)(.*)\\1\\])(.*)(\\[\\/QUOTE\\])", "gi");

		while(str.match(quote1))
		{
			str = str.replace(quote1, '');
		}

		while(str.match(quote2))
		{
			str = str.replace(quote2, '');
		}
	}

	if (ishtml)
	{
		var html1 = new RegExp("<(\\w+)[^>]*>", "gi");
		var html2 = new RegExp("<\\/\\w+>", "gi");

		str = str.replace(html1, '');
		str = str.replace(html2, '');

		var html3 = new RegExp("&nbsp;");
		str = str.replace(html3, '');
	}
	else
	{
		var bbcode1 = new RegExp("\\[(\\w+)[^\\]]*\\]", "gi");
		var bbcode2 = new RegExp("\\[\\/(\\w+)\\]", "gi");

		str = str.replace(bbcode1, '');
		str = str.replace(bbcode2, '');
	}
	return str;
}

// #############################################################################
// emulation of the PHP version of vBulletin's buildphrase() sprintf wrapper
function buildphrase()
{
	if (!arguments || arguments.length < 1 || !is_regexp)
	{
		return false;
	}

	var args = arguments;
	var str = args[0];

	for (var i = 1; i < args.length; i++)
	{
		re = new RegExp("%" + i + "\\$s", "gi");
		str = str.replace(re, args[i]);
	}
	return str;
}

function returnfalse()
{
	return false;
}


var arr_colors = new Array();
arr_colors = {
	"#000000" : "Black",
	"#A0522D" : "Sienna",
	"#556B2F" : "DarkOliveGreen",
	"#006400" : "DarkGreen",
	"#483D8B" : "DarkSlateBlue",
	"#000080" : "Navy",
	"#4B0082" : "Indigo",
	"#2F4F4F" : "DarkSlateGray",
	"#8B0000" : "DarkRed",
	"#FF8C00" : "DarkOrange",
	"#808000" : "Olive",
	"#008000" : "Green",
	"#008080" : "Teal",
	"#0000FF" : "Blue",
	"#708090" : "SlateGray",
	"#696969" : "DimGray",
	"#FF0000" : "Red",
	"#F4A460" : "SandyBrown",
	"#9ACD32" : "YellowGreen",
	"#2E8B57" : "SeaGreen",
	"#48D1CC" : "MediumTurquoise",
	"#4169E1" : "RoyalBlue",
	"#800080" : "Purple",
	"#808080" : "Gray",
	"#FF00FF" : "Magenta",
	"#FFA500" : "Orange",
	"#FFFF00" : "Yellow",
	"#00FF00" : "Lime",
	"#00FFFF" : "Cyan",
	"#00BFFF" : "DeepSkyBlue",
	"#9932CC" : "DarkOrchid",
	"#C0C0C0" : "Silver",
	"#FFC0CB" : "Pink",
	"#F5DEB3" : "Wheat",
	"#FFFACD" : "LemonChiffon",
	"#98FB98" : "PaleGreen",
	"#AFEEEE" : "PaleTurquoise",
	"#ADD8E6" : "LightBlue",
	"#DDA0DD" : "Plum",
	"#FFFFFF" : "White"
};

// variable to prevent init being called twice
var editor_loaded = false;

// initialize some arrays
var popupcontrols = new Array();
//var colorindex = new Array();
var fontoptions = new Array("Arial", "Arial Black", "Arial Narrow", "Book Antiqua", "Century Gothic", "Comic Sans MS", "Courier New", "Fixedsys", "Franklin Gothic Medium", "Garamond", "Georgia", "Impact", "Lucida Console", "Lucida Sans Unicode", "Microsoft Sans Serif", "Palatino Linotype", "System", "Tahoma", "Times New Roman", "Trebuchet MS", "Verdana");
var sizeoptions = new Array(1, 2, 3, 4, 5, 6, 7);
var buttonstatus = new Array();

// default values for URL / Image prompts
var linkurl = "http://";

if ((navigator.appVersion.indexOf("MSIE 4.") != "-1" && is_ie) || (parseInt(navigator.appVersion) == 4 && is_ns))
{ // the v4 browsers dont support try / catch
	var is_v4 = true;
}

// #############################################################################
// function to change the appearence of a control element
function format_control(elm, elmtype, controlstate)
{
	// if we do not *need* to change the control state, then don't
	if (controlstate == elm.controlstate)
	{
		return;
	}
	
	// construct the name of the appropriate array key from the istyles array
	istyle = "pi_" + elmtype + "_" + controlstate;

	// set element background, color, padding and border
	elm.style.background = istyles[istyle][0];
	elm.style.color = istyles[istyle][1];
	if (elmtype != "menu")
	{
		elm.style.padding = istyles[istyle][2];
	}
	elm.style.border = istyles[istyle][3];
	
	// set the element controlstate variable
	elm.controlstate = controlstate;
	
	// handle some special cases for popup elements
	if (in_array(elm.cmd, popupcontrols) != -1)
	{
		tds = elm.getElementsByTagName("td");
		for (var i = 0; i < tds.length; i++)
		{
			switch (tds[i].className)
			{
				// set the right-border for popup_feedback class elements
				case "popup_feedback":
				{
					tds[i].style.borderRight = ternary(controlstate == "normal", istyles["pi_menu_normal"][3], istyles[istyle][3]);
				}
				break;
				
				// set the border colour for popup_pickbutton class elements
				case "popup_pickbutton":
				{
					tds[i].style.borderColor = ternary(controlstate == "normal", istyles["pi_menu_normal"][0], istyles[istyle][0]);
				}
				break;
				
				// set the left-padding and left-border for alt_pickbutton elements
				case "alt_pickbutton":
				{
					if (buttonstatus[elm.cmd])
					{	
						tds[i].style.paddingLeft = istyles["pi_button_normal"][2];
						tds[i].style.borderLeft = istyles["pi_button_normal"][3];
					}
					else
					{
						tds[i].style.paddingLeft = istyles[istyle][2];
						tds[i].style.borderLeft = istyles[istyle][3];
					}
				}
			}
		}
	}
}

// #############################################################################
// function to set 'unselectable' for an element and all its child nodes
function set_unselectable(elm)
{
	if (is_ie4)
	{
		return;
	}
	else if (elm.tagName)
	{
		if (elm.hasChildNodes())
		{
			for (var i = 0; i < elm.childNodes.length; i++)
			{
				set_unselectable(elm.childNodes[i]);
			}
		}
		elm.unselectable = true;
	}
}

// #############################################################################

function populateListBox(propertytype)
{
	switch (propertytype)
	{
		case "fontname":
		{
			for (key in fontoptions)
			{
				document.writeln('<option value="' + fontoptions[key] + '">' + fontoptions[key] + '</option>');
			}
		}break;
		case "fontsize":
		{
			for (key in sizeoptions)
			{
				document.writeln('<option value="' + sizeoptions[key] + '">' + sizeoptions[key] + '</option>');
			}
		}break;
		case "color":
		{
			for (key in arr_colors)
			{
				document.writeln('<option value="' + arr_colors[key] + '" style="background-color:' + arr_colors[key] + ';">' + arr_colors[key].replace(/([a-z]{1})([A-Z]{1})/g, "$1 $2") + '</option>');
			}
		}
	}
}