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

var number_of_images = 1;
var number_of_files = 1;

function add_blog_image () {
	number_of_images += 1;
	to_add = 'Image: <br /> <input id="image_' + number_of_images + '_uploaded_data" name="image_' + number_of_images + '[uploaded_data]" type="file" size="30"><br />';
	$("blogs_images").insert(to_add);
	document.forms[0].number_of_images.value = number_of_images;
}

function add_blog_file () {
	number_of_files += 1;
	to_add = 'File: <br /> <input id="file_' + number_of_files + '_uploaded_data" name="file_' + number_of_files + '[uploaded_data]" type="file" size="30"><br />';
	$("blogs_files").insert(to_add);
	document.forms[0].number_of_files.value = number_of_files;
}


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

function toggleEditor(id) {
	if (!tinyMCE.get(id))
		tinyMCE.execCommand('mceAddControl', false, id);
	else
		tinyMCE.execCommand('mceRemoveControl', false, id);
}

function removeEditor(id) {
	if (tinyMCE.getInstanceById(id))
	{
	    tinyMCE.execCommand('mceFocus', false, id);                    
	    tinyMCE.execCommand('mceRemoveControl', false, id);
	}
}

function update_main_image(title, t_id, image, description, imageL) {
	content = '<a rel="lightbox" title="' + title + '" href="' + imageL + '"><img src="' + image + '" alt="' + title + '" /><br /><strong>' + title + '</strong>' + description + '</a>';
	$('rf_bigpic').innerHTML = content;
	myLightWindow = null;
	lightwindowInit();
}

function add_image_field_about_section () {
	number_of_images += 1;
	to_add = 'Image: <br /> <input id="image_' + number_of_images + '_uploaded_data" name="image_' + number_of_images + '[uploaded_data]" type="file" size="3"><br />';
	$("section_images").insert(to_add);
	document.forms[0].number_of_images.value = number_of_images;
}
