function $(id) {
  if ($type(id) == 'object') {
    return id;
  }
  return document.getElementById(id);
}

function $new(elem,text) {
  if (elem == 'text') {
    return document.createTextNode(text);
  }
  else {
    return document.createElement(elem.toLowerCase());
  }
}

function $type(val) {
  var type = typeof val;
  return type.toLowerCase();
}

function submitForm(id) { 
  var form = $(id);
  if (form) {
    form.submit();
  }
}

function trim(s) {
  return s.replace(/^\s+|\s+$/g,"");
}

function gen_add(){
	var r = Math.floor(Math.random()*100);
	var tag = '<iframe src="http://www.s2d6.com/x/?x=i&amp;z=i&amp;v=' + add_number + '&amp;r=' + r + '&amp;k=' + add_position + '" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" width="468" height="60">';
	tag += '<ilayer src="http://www.s2d6.com/x/?x=i&amp;z=i&amp;v=' + add_number + '&amp;r=' + r + '&amp;k=' + add_position + '" z-index="0" width="' + add_width + '" height="' + add_height + '">';
	tag += '<a href="http://www.s2d6.com/x/?x=c&amp;z=s&amp;v=' + add_number + '&amp;r=' + r + '&amp;k=' + add_position + '" target="_blank">';
	tag += '<img src="http://www.s2d6.com/x/?x=i&amp;z=s&amp;v=' + add_number + '&amp;r=' + r + '" border="0" alt="Click here">';
	tag += '</a>';
	tag += '</ilayer>';
	tag += '</iframe>';
	document.write(tag);
}
