HtmlContentEditor = {
mode: "specific_textareas",
plugins: "spellchecker,taoquote,csscleanup,media,pagebreak",
theme: "advanced",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align : "left",
theme_advanced_buttons1: "styleselect,fontsizeselect,bold,italic,underline,strikethrough,separator,undo,redo,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,forecolor",
theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,image,media,separator,code,anchor,html,link,unlink,spellchecker,separator,blockquote,taoquote,|,removeformat,csscleanup,|,pagebreak",
theme_advanced_buttons3: "",
pagebreak_separator: "<!-- page_split -->",
convert_urls: false,
theme_advanced_statusbar_location: "bottom",
theme_advanced_path: false,
theme_advanced_resize_horizontal: false,
theme_advanced_resizing: true,
theme_advanced_styles : "Normal Paragraph=tinymce_paragraph;Left Align Paragraph Image=tinymce_image_left;Main News Text=tinymce_main_news;Main News Image=tinymce_main_image_left;Continue Reading Link=tinymce_continue_link;Homepage Story=story;Homepage Story Date=story_date;Homepage Story Tags=story_tags",
cleanup_on_startup: true,
convert_fonts_to_spans : true,
apply_source_formatting: true,
extended_valid_elements: "script[type],object[width|height|classid|codebase|name|align],param[name|value],embed[src|type|wmode|width|height|id|align]",
width: "100%",
height: 580,
relative_urls: false,
content_css : "/css/styles-sept2008-tiny.css",
media_use_script : true,
media_strict: false
};

UserFacing = {
mode: "specific_textareas",
theme: "simple",
convert_urls: false, 
cleanup_on_startup: true,
convert_fonts_to_spans : true,
apply_source_formatting: true,
width: "100%",
relative_urls: true
};

Tiny.addConfig('HtmlContent',HtmlContentEditor);
Tiny.addConfig('UserFacing',UserFacing);

//adds classes to the input depending on the type
jQuery(document).ready(function(){
    jQuery('#left-column input[type="text"]').addClass('text');
    jQuery('#left-column input[type="button"]').addClass('btn');
	jQuery('#left-column input[type="radio"]').addClass('radio');
});

interface={
	text_focus:{
		init:function() {interface.text_focus.attachFocus($$("input.focus)"));},
		attachFocus:function(sfEls){
			for (var i=0; i<sfEls.length; i++) {
				sfEls[i].onfocus=function() {interface.text_focus.OnFocus(this,this.defaultValue);}
			}
		},
		OnFocus:function(txtInput,str){
			if(txtInput.hasFocus){return;}
			txtInput.hasFocus=true;
			if(str=='Password'&&txtInput.value==str){
				txtInput=interface.text_focus.swapInputType(txtInput,str);
			}
			if(txtInput.value==str)txtInput.value='';
			txtInput.className+=" sffocus";
			txtInput.onblur = function(){
				if(txtInput.value==''){
					if(txtInput.type=='password')txtInput=interface.text_focus.swapInputType(txtInput,str);
					txtInput.value=str;
				}
				$(txtInput).removeClassName("sffocus");
				txtInput.hasFocus=false;
			}
		},
		swapInputType:function(txtInput,str){
			var newInput = document.createElement('input');
			if(txtInput.type=='password')newInput.type='text';
			else newInput.type='password';
			newInput.name = txtInput.name;
			newInput.value = txtInput.value;
			newInput.id = txtInput.id;
			newInput.className = txtInput.className;
			objParent=txtInput.parentNode;
			objParent.replaceChild(newInput,txtInput);
			newInput.onfocus = function (){txtInputOnFocus(newInput,str)};
			newInput.hasFocus=false;
			window.newInput = newInput;
			newInput.onblur = function(){
				if(newInput.value==''){
					if(newInput.type=='password')newInput=swapInputType(newInput,str);
					newInput.value=str;
				}
				newInput.hasFocus=false;
			}
			setTimeout("newInput.hasFocus=true;newInput.focus();",1);
			return newInput;
		}
	}	
}

document.observe("dom:loaded",
	function(){
		interface.text_focus.init();
	}
);

var ssi = {
		openRegistration: function(content) {
			registrationFrameHtml = '<iframe src="'+content+'" width="100%" height="100%"><p>Your browser does not support iframes.</p></iframe>';
			swc.popup.create(registrationFrameHtml, {modal: 'true', width: '650px', className: 'registration', resizable: 'false'});
		},
		
		openLogin: function(content) {
			swc.popup.create(content, {modal: 'true', width: '560px', className: 'login', resizable: 'false'});
		}
	};


    
/**
 * This script contains embed functions for common plugins. This scripts are complety free to use for any purpose.
 */

function writeFlash(p) {
	writeEmbed(
		'D27CDB6E-AE6D-11cf-96B8-444553540000',
		'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
		'application/x-shockwave-flash',
		p
	);
}

function writeShockWave(p) {
	writeEmbed(
	'166B1BCA-3F9C-11CF-8075-444553540000',
	'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0',
	'application/x-director',
		p
	);
}

function writeQuickTime(p) {
	writeEmbed(
		'02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
		'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0',
		'video/quicktime',
		p
	);
}

function writeRealMedia(p) {
	writeEmbed(
		'CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA',
		'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
		'audio/x-pn-realaudio-plugin',
		p
	);
}

function writeWindowsMedia(p) {
	p.url = p.src;
	writeEmbed(
		'6BF52A52-394A-11D3-B153-00C04F79FAA6',
		'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701',
		'application/x-mplayer2',
		p
	);
}

function writeEmbed(cls, cb, mt, p) {
	var h = '', n;

	h += '<object classid="clsid:' + cls + '" codebase="' + cb + '"';
	h += typeof(p.id) != "undefined" ? 'id="' + p.id + '"' : '';
	h += typeof(p.name) != "undefined" ? 'name="' + p.name + '"' : '';
	h += typeof(p.width) != "undefined" ? 'width="' + p.width + '"' : '';
	h += typeof(p.height) != "undefined" ? 'height="' + p.height + '"' : '';
	h += typeof(p.align) != "undefined" ? 'align="' + p.align + '"' : '';
	h += '>';

	for (n in p)
		h += '<param name="' + n + '" value="' + p[n] + '">';

	h += '<embed type="' + mt + '"';

	for (n in p)
		h += n + '="' + p[n] + '" ';

	h += '></embed></object>';

	document.write(h);
}

