Event.observe(window,"load",function(){
	
	$('entry_content_wrapper').style.position = "relative";
	$('entry_more_wrapper').style.position = "absolute";
	$('entry_content_wrapper').style.visibility = "visible";
	
	Event.observe($('entry_content_switch'),"click",function(){
		$('entry_content_wrapper').style.position = "relative";
		$('entry_content_wrapper').style.visibility = "visible";
		
		$('entry_more_wrapper').style.position = "absolute";
		$('entry_more_wrapper').style.visibility = "hidden";
		
		$('entry_content_switch').setAttribute("class","content_tab_active");
		$('entry_content_switch').className = "content_tab_active";
		
		$('entry_more_switch').setAttribute("class","content_tab_inactive");
		$('entry_more_switch').className = "content_tab_inactive";
		
	});


	Event.observe($('entry_more_switch'),"click",function(){
		$('entry_more_wrapper').style.position = "relative";
				
		$('entry_content_wrapper').style.position = "absolute";
		$('entry_content_wrapper').style.visibility = "hidden";
		
		$('entry_more_switch').setAttribute("class","content_tab_active");
		$('entry_more_switch').className = "content_tab_active";
		
		$('entry_content_switch').setAttribute("class","content_tab_inactive");
		$('entry_content_switch').className = "content_tab_inactive";
		
		//safari rendering is too slow.
		$('entry_more_wrapper').style.visibility = "visible";
	});
	
	//toggle label
	$$('#labels input[type="checkbox"]').each(function(ele){
		toggle_labelmemo(ele.value,ele.checked);
	});
	
},false);


function applyTemplate(){
	var template = document.getElementById("list_templates").value;
	
	if(template.length == 0){
		return;
	}
	
	var post = "id=" + template;
	
	var callback = function(oResponse) {
			var result = eval('('+oResponse.responseText+')');
			
			$("style").value = result['templates']['style'];
						
			$('entry_content').value = result['templates']['content'];
			$('entry_more').value = result['templates']['more'];
	};
	
	var myAjax = new Ajax.Request(
		templateAjaxURL, 
		{
			method: 'post', 
			parameters: post, 
			onComplete: callback
		});
}
