function pageSection(action, page_id, section_id){
	if(action == 'delete'){
		procede = confirm('Are you sure you want to delete this section?\nThis action cannot be undone.');
	}else{
		procede = true;
	}
	if(procede == true){
		new Ajax.Updater('page_sections', root+'scripts/php/ajax_updates.php', {evalScripts: true, postBody:'action='+action+'&page_id='+page_id+'&section_id='+section_id, onComplete:function(){
			//window.location.reload();
		}});
	}
	return false;
}

function initialStart(section_ids){
	
	if(section_ids.length>0){
		for(i=0; i<section_ids.length; i++){
			if(section_ids[i] != ''){
				new Ajax.InPlaceEditor('content_title_'+section_ids[i], root+'scripts/php/ajax_updates.php?action=update_section&section=title&id='+section_ids[i], {evalScripts: true, formClassName:'sec_headline', okControl:false, cancelControl:false, submitOnBlur:true, cols:75});
				
				new Ajax.InPlaceRichEditor($('content_body_'+section_ids[i]), root+'scripts/php/ajax_updates.php?action=update_section&section=contents&id='+section_ids[i],{tinymceToElementSize: true, okText:'Save'}, tinymce_options);
			}
		}
	}
	
	Sortable.create('page_sections', {scroll:window, onUpdate:function(){
	
		poststring = Sortable.serialize('page_sections');
		new Ajax.Updater('loading', root+'scripts/php/ajax_updates.php', {onCreate:function(){
			$('loading').innerHTML = 'Saving Order...';
			appearLoader();
		}, postBody:'action=update_order&'+poststring, onComplete:function(){
			setTimeout('fadeLoader()', 1000);
		} });
	
	}, handle:'rearrange' /*, scroll:'window'*/});
	
}

function launchImageEditor(section_id){

	$image_editor = window.open(root+'image_editor.php?id='+section_id, 'image_editor','status=0,toolbar=0,location=0,menubar=0,scrolling=1');
	if(!$image_editor){
		alert('It appears that you have popups disabled. You will need to allow popups to edit these images.');
	}
	return false;

}

function fadeLoader(){
	new Effect.Morph('loading', { style: {color: '#ffffff'}});
}

function appearLoader(){
	new Effect.Morph('loading', { style: {color: '#4D4D4D'}});
}