// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

// JSON parser
document.writeln('<scr'+'ipt type="text/javascript" language="javascript" src="/javascripts/json2.js"></scr'+'ipt>');

// AJAX support
document.writeln('<scr'+'ipt type="text/javascript" language="javascript" src="/javascripts/jax.js"></scr'+'ipt>');

// TinyMCE support
document.writeln('<scr'+'ipt type="text/javascript" language="javascript" src="/javascripts/tiny_mce/tiny_mce.js"></scr'+'ipt>');


var icons = new Array();
/* Widget Icons - video/widgets.js */
icons.push('/images/template/Icon_Text.gif');
icons.push('/images/template/Icon_Text_Off.gif');
icons.push('/images/template/Icon_Comment.gif');
icons.push('/images/template/Icon_Comment_Off.gif');
icons.push('/images/template/Icon_Image.gif');
icons.push('/images/template/Icon_Image_Off.gif');
icons.push('/images/template/Icon_Link.gif');
icons.push('/images/template/Icon_Link_Off.gif');
icons.push('/images/template/Icon_Quote.gif');
icons.push('/images/template/Icon_Quote_Off.gif');
/* QuickPlay Icons - video/player.js */
icons.push('/images/template/Pause.gif');
icons.push('/images/template/Pause_On.gif');
icons.push('/images/template/Play.gif');
icons.push('/images/template/Play_On.gif');
icons.push('/images/template/Back.gif');
icons.push('/images/template/Back_On.gif');
icons.push('/images/template/Forward.gif');
icons.push('/images/template/Forward_On.gif');
icons.push('/images/template/Forward_Off.gif');

function preloadImages(imgArray){
	if ( typeof imgArray != 'object' || ! imgArray.length ) { return; }
	for( var i=0; i<imgArray.length; i++ ){
		var image = new Image();
		image.src = imgArray[i];
	}
	return;
}

preloadImages(icons);





//Event.addBehavior({ 
//	'#login_form': function() { 
//		this.hide(); 
//		}
//	})
//Event.addBehavior( { 
//	'#login_popup': function() { 
//		this.hide(); 
//		}
//	} )


// tinyMCE - pass id of textarea
function toggleTextEditor(id) {
	if ( id == null || typeof id == 'undefined' ) {
		return;	
	}
	var targetNode = document.getElementById( id );
	if ( targetNode == null 
	|| typeof targetNode == 'undefined' 
	|| targetNode.type != 'textarea' ) {
		alert("No such node or node is not a textarea: 'id'");
		return;
	}

	tinyMCE.init({
		mode : "none",
		theme : "advanced",
		theme_advanced_buttons1 : "bold,italic,fontsizeselect,separator,justifyleft,justifycenter,justifyright,image,media,link,unlink,separator,code",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_toolbar_location : "bottom",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "",
		font_size_style_values : "10pt,12pt,14pt,18pt,24pt,",
		extended_valid_elements : "a[name|href|target|title],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],object[width|height|classid|codebase],param[name|value],embed[src|type|width|height|flashvars|wmode]",
    	relative_urls : false, 
    	remove_script_host : true,
		plugins : "media"
		});	
		//theme_advanced_buttons1 : "bold,italic,fontsizeselect,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,link,unlink,separator,code",
		//plugins : "flash,print,paste"

	tinyMCE.execCommand('mceAddControl', false, id);
}

