	function clickPublish(q){
		p=document.getElementById('publish');
		if(q.checked){
			p.style.visibility='visible';
			today=new Date();
			m=today.getMonth()+1;
			if(m<10)
				m='0'+m;
			d=today.getDate();
			if(d<10)
				d='0'+d;
			document.forms.weblogForm.publish_date.value=d+"-"+m+"-"+today.getFullYear();
		}else{
			p.style.visibility='hidden';
			document.forms.weblogForm.publish_date.value='00-00-0000';
		}
	}
	
	function clickArchive(q){
		p=document.getElementById('archive');
		if(q.checked){
			p.style.visibility='visible';
			today=new Date();
			m=today.getMonth()+1;
			if(m<10)
				m='0'+m;
			d=today.getDate();
			if(d<10)
				d='0'+d;
			document.forms.weblogForm.archive_date.value=d+"-"+m+"-"+today.getFullYear();
		}else{
			p.style.visibility='hidden';
			document.forms.weblogForm.archive_date.value='00-00-0000';
		}
	}

	function updateWeblog(){
		document.forms['weblogForm'].submit();
	}


	function selectImage(path,img){
		p=document.getElementById('weblogImage');
		p.src=path+'_thumbs/'+img;
		document.forms.weblogForm.image_url.value=path+img;
		
	}


	tinyMCE.init({
		editor_selector : "editor_body",
		mode : "textareas",
		theme : "advanced",
		plugins : "spellchecker,style,table,save,advhr,advimage,advlink,media,searchreplace,contextmenu,paste,filemanager",
		theme_advanced_buttons1_add : "print,forecolor,backcolor,fontsizeselect",
		theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator",
		theme_advanced_buttons3_add_before : "tablecontrols,separator",
		theme_advanced_buttons3_add : "spellchecker,media",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_default_background_color : "#000000",
		theme_advanced_default_text_color : "#fff",
		content_css: "/css/editorarea.css",		
		external_link_list_url : "artistlist.php",
		theme_advanced_styles : "Afbeelding links=leftimage;Afbeelding rechts=rightimage",
		external_link_list_url : "artistlist.php",
	    plugin_insertdate_dateFormat : "%d-%m-%Y",
	    plugin_insertdate_timeFormat : "%H:%M:%S",
		extended_valid_elements : "hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],p[lang]",
		theme_advanced_resize_horizontal : false,
		theme_advanced_resizing : true,
		apply_source_formatting : true,
		spellchecker_languages : "+Dutch=nl,English=en"
	});






//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){

	//LOADING POPUP
	//Click the button event!
	$("#button").click(function(event){
		mcFileManager.browse({oninsert : customInsert});
	});
				
	
});

function customInsert(data) { 
	$("#image_url").val(data.files[0].url);
	$("#weblogImage").attr('src',data.files[0].url);
} 
