function AppendCharacter (formfield,ChrToAppend)
{
	var word='';

	formfield.focus();
	if (document.selection) 
	{
		document.selection.createRange().text=ChrToAppend;
	}
	else
	{
		var startP = formfield.selectionStart;
		word = formfield.value.substring(0,startP);
		word += ChrToAppend;
		word += formfield.value.substring(startP,formfield.value.length);
		formfield.value=word;
		formfield.selectionStart=startP;
		formfield.selectionEnd=startP;
	}

} 

    function ShowMenu(n)
    {
      var menu, arrowImg
	  menu = document.getElementById("d" + n);
      
	  // Determine if the menu is currently showing.
      if (menu.style.display == 'block')
      {
        // If it is showing, hide the menu and update the twisty image.
        menu.style.display = 'none'
		arrowImg = document.images["i" + n]
        arrowImg.src = "images/section_closed.gif"
      }
      else
      {
        // Hide all layers first.
		
	  	  var divs = document.getElementsByTagName("div")

      	for (i = 0; i < divs.length; i++)
			if (divs[i].id.indexOf('d0') >= 0)
          	divs[i].style.display = 'none'
        // Reset the images.
        for (j = 0; j < document.images.length; j++)
          if (document.images[j].src.indexOf("menu_open") > 0)
            document.images[j].src = "images/section_closed.gif"
        
        // Show the menus and update their twisty images.
        i = 2
        while (n.length >= i)
        {		
		menu = document.getElementById("d" + n.substring(0, i));              
          arrowImg = eval("document.images['i" + n.substring(0, i) + "']")
          menu.style.display = "block"
          arrowImg.src = "images/section_open.gif"
          i += 2
        }
      }
    }
function additem(fieldremove,fieldadd) 
{
//var newitem=prompt("Add New List Item","");
var addbox = eval(fieldadd);
var add = 1;
var i;
for(i=0;i<addbox.length;i++)
{
	if(addbox.options[i].value == fieldremove.value)
	{
	 add = 0
	}
}
if( add == 1)
{
addbox[addbox.length] = new Option(fieldremove.text,fieldremove.value);
}
}
function deleteitem(fieldname) 
{
selectedfield = eval(fieldname+".selectedIndex");
newfieldname = eval(fieldname);
//alert(selectedfield);
if (selectedfield > 0)
{
	newfieldname.options[selectedfield]=null;
	newfieldname.selectedIndex = 0;
}
}

function addcategories(categoryname,fieldname)
				{
					var catlist = "";
					var i;
					for(i=0;i<categoryname.length;i++)
					{
						catlist = catlist + categoryname.options[i].value + ",";
					}
					fieldname.value= catlist;	
				}
function setlocations(locationname,locations_names,locations_values)
	{
		var locationvaluelist = "";
		var locationnamelist = "";
		var i;
		for(i=0;i<locationname.length;i++)
		{
			locationvaluelist = locationvaluelist + locationname.options[i].value + "*";
			locationnamelist = locationnamelist + locationname.options[i].text + "*";
		}
			locations_values.value= locationvaluelist;
			locations_names.value= locationnamelist;
			//alert(locations_values.value);	
	}
	
	function windowOpener(url,width,height,target,isfullscreen,top,left) 
      {
       browserName = navigator.appName;
       browserVer = navigator.appVersion.substring(0,1);
       if (width==null) {width=600;}
       if (height==null) {height=400;}
       if (top==null) {top=40;}
       if (left==null) {left=50;}
       if (browserName != "Netscape" || browserVer != 2)
       {
controlWindow=window.open(url,target,"toolbar=no,height="+height+",width="+width+",top="+top+",left="+left+",location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,fullscreen="+isfullscreen);
       }
      }
	  function countchars(field,field_size,startcount)
				{
				//alert("hi");
					field_size.value = startcount.value - field.value.length;
					if (field.value.length > startcount.value)
					{
						field.value = field.value.substring(0, startcount.value);
						field_size.value = 0;
					}	
				}
		function changelisting_textchars()
		{
		//alert(theform.pending_listingtypeid.options[theform.pending_listingtypeid.selectedIndex].value);
				if(theform.pending_listingtypeid.options[theform.pending_listingtypeid.selectedIndex].value == 2)
				{
					theform.listing_charamount.value = 200;
					countchars(theform.listing_text,theform.listing_textchars,theform.listing_charamount);
				}
				else if(theform.pending_listingtypeid.options[theform.pending_listingtypeid.selectedIndex].value == 3 || theform.pending_listingtypeid.options[theform.pending_listingtypeid.selectedIndex].value == 4 || theform.pending_listingtypeid.options[theform.pending_listingtypeid.selectedIndex].value == 5)
				{
					theform.listing_charamount.value = 500;
					countchars(theform.listing_text,theform.listing_textchars,theform.listing_charamount);
				}
				else if(theform.pending_listingtypeid.options[theform.pending_listingtypeid.selectedIndex].value == 1)
				{
					theform.listing_charamount.value = 0;
					countchars(theform.listing_text,theform.listing_textchars,theform.listing_charamount);
				}
		}
		function changelisting_textchars2()
		{
		//alert(theform.pending_listingtypeid.options[theform.pending_listingtypeid.selectedIndex].value);
				if(theform.pending_listingtypeid.value == 2)
				{
					theform.listing_charamount.value = 200;
					countchars(theform.listing_text,theform.listing_textchars,theform.listing_charamount);
				}
				else if(theform.pending_listingtypeid.value == 3 || theform.pending_listingtypeid.value == 4 || theform.pending_listingtypeid.value == 5)
				{
					theform.listing_charamount.value = 500;
					countchars(theform.listing_text,theform.listing_textchars,theform.listing_charamount);
				}
				else if(theform.pending_listingtypeid.value == 1)
				{
					theform.listing_charamount.value = 0;
					countchars(theform.listing_text,theform.listing_textchars,theform.listing_charamount);
				}
		}
