//Add new content
function edit_div(location,database) {
  if (database == "") {
    window.location = location;
    return;
  }
  else if (database != "owners") {
    page = "edit";
  }                    
  else {
    page = "owners_edit";
  }
window.location = page + ".php?content_name=" + location + "&database=" + database;
}

//onload event to go to chosen target
document.observe("dom:loaded", function() {
target_scroll();
});

function target_scroll(pushed_var) {
margin = 20;
  if (!pushed_var) {
    url = window.location;
    url = url.toString(); 
    target_id = url.split('target=');
    target_id = target_id[1];
  }
  else {
    target_id = pushed_var;
  }
    if (target_id) {
      co_ords = $(target_id).viewportOffset();
      window.scrollBy(0,co_ords[1] - margin);
    }
} 

//saves the owners edit page by comparing image srcs
function save_owners() {
  upload = $('file_upload').value;
  orig = $('img_src').src;
  orig = orig.split('/');

  if (upload && orig[orig.length-1] != "nopicture.png") {
    alert('Please upload your image before saving.')
  } 
  else {
    $('save').submit();
  }
}

function add() {
content = $('tinymce').innerHTML;
alert(content);
}  
