// SPJS - Javascript Wrapper
// Main Site Version - Prototype

// Get Element
function spjs_get(id) {
  return $(id);
}

// Check If Element Exist
function spjs_has(id) {
  if($(id) == null) {
    return false;
  }
  return true;
}

// Html Modification
function spjs_create_div(html) {
  var elem = document.createElement('div');
  elem.innerHTML = html;
  return elem;
}

function spjs_set_html(id, html) {
  var elem = spjs_get(id);
  elem.innerHTML = html;
}

function spjs_append_html(parent, html) {
  $(parent).innerHTML += html;
}

function spjs_append_child(parent, child) {
  $(parent).appendChild(child);
}

// Set / Get Value for Element
function spjs_get_value(id) {
  var elem = spjs_get(id);
  return elem.value;
}

function spjs_set_value(id, value) {
  spjs_get(id).value = value;
}

// Set Style
function spjs_set_style(id, style_tag) {
  spjs_get(id).setStyle(style_tag);
}

// Show / Hide Element
function spjs_show(id) {
  var elem = spjs_get(id);
  elem.show();
}

function spjs_hide(id) {
  var elem = spjs_get(id);
  elem.hide();
}

function spjs_show_fadein(id) {
  spjs_get(id).appear({duration: 0.25});
}

function spjs_show_fadeout(id) {
  spjs_get(id).fade({duration: 0.25});
}

// Enable / Disable Form Element
function spjs_enable(id) {
  var elem = spjs_get(id);
  elem.disabled = false;
}

function spjs_disable(id) {
  var elem = spjs_get(id);
  elem.disabled = true;
}

// Classes
function spjs_addclass(id, classname) {
  var elem = spjs_get(id);
  elem.addClassName(classname);
}

function spjs_removeclass(id, classname) {
  var elem = spjs_get(id);
  if(elem.hasClassName(classname))
    elem.removeClassName(classname);
}




