var justshownmenu=false;

function showdropdownmenu() {
	dropdownmenu.style.left=arguments[0];
	dropdownmenu.style.top=arguments[1];
	var html='';
	for(var i=2;i<arguments.length;i+=2) {
		html+='<div><a href="'+arguments[i+1]+'">'+arguments[i]+'</a></div>';
	}
	dropdownmenu.innerHTML=html;
	dropdownmenu.style.display='block';
	justshownmenu=true;
	setTimeout('notjustshownmenu()',1000);
}

function notjustshownmenu() {
	justshownmenu=false;
}

function cleardropdownmenu() {
	//if(!justshownmenu) 
	forcecleardropdownmenu();
}

function forcecleardropdownmenu() {
	dropdownmenu.style.display='none';
	dropdownmenu.innerHTML='';
}

function niceTagName(o) {
	if(o.htmlText!=undefined) {
		return 'Insert Element';
	}
	if(o.tagName==undefined) alert('no tagname');
	var tagname=o.tagName.toUpperCase();
	if(tagname=='INPUT') tagname+=':'+o.type;
	if(tagname=='IMG' && o.src.indexOf('/compose/images/composebutton.gif')>-1) {
		return o.title;
	}
	for(var i=0;i<HTMLELEMENTS.length;i++) {
		if(HTMLELEMENTS[i][0]==tagname) return HTMLELEMENTS[i][1];
	}
	return tagname;
}

function toggleexpand(item) {
	var expand=document.getElementById(item+'_expand');
	var group=document.getElementById(item+'_group');
	if(group==null) {
		expand.src='/compose/images/spacer.gif';
		expand.width='16';
		expand.height='16';
	} else {
		if(group.style.display=='none') {
			group.style.display='block';
			expand.src='/compose/images/minus.gif';
			document.cookie=item+'=1';
		} else {
			group.style.display='none';
			expand.src='/compose/images/plus.gif';
			document.cookie=item+'=0';
		}
	}
}

function isFormatObject(o) {
	if(o==null) return false;
	if(o.tagName==undefined) return false;
	for(var i=0;i<FORMATTING_HTMLELEMENTS.length;i++) {
		if(FORMATTING_HTMLELEMENTS[i]==o.tagName) return true;
	}
	return false;
}

var FORMATTING_HTMLELEMENTS=['B','STRONG','U','I','S','BIG','SMALL','FONT','SPAN'];

var HTMLELEMENTS=[
	['TABLE','Table'],
	['TBODY','Table Body'],
	['TR','Table Row'],
	['TD','Table Cell'],
	['TH','Table Heading Cell'],
	
	['FORM','Form'],
	['INPUT:text','Form Text Field'],
	['INPUT:password','Form Password Field'],
	['INPUT:radio','Form Radio Option'],
	['INPUT:checkbox','Form Checkbox'],
	['INPUT:submit','Form Submit Button'],
	['INPUT:image','Form Submit Image'],
	['INPUT:reset','Form Clear'],
	['INPUT:file','Form File Browse'],
	['SELECT','Form Drop Down'],
	['OPTION','Form Drop Down Option'],
	['TEXTAREA','Form Multi-Line Field'],
	
	['BUTTON','Button (Non-Form)'],
	
	['P','Paragraph'],
	['CENTER','Centralise'],
	['DIV','Line'],
	['SPAN','Section'],
	
	['IMG','Image'],
	
	['BODY','Page'],
	['A','Link'],
	
	['B','Bold'],
	['STRONG','Bold'],
	['I','Italic'],
	['U','Underline'],
	['S','Strike'],
	['SUB','Subscript'],
	['SUP','Superscript'],
	['BIG','Big Font'],
	['SMALL','Small Font'],
	['FONT','Font Specification'],
	
	['UL','Unordered List'],
	['OL','Ordered List'],
	['LI','List Item'],
	['HR','Horizontal Rule'],
	
	['H1','Heading 1'],
	['H2','Heading 2'],
	['H3','Heading 3'],
	['H4','Heading 4'],
	['H5','Heading 5'],
	['H6','Heading 6']
];


