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 confirmDel(id, type)
{
 if (type == '1')
 {
 if (confirm("Are you sure you want to delete this administrator?"))
 document.location.href= "manage_admins.php?action=remove&id="+ id;
 }
 else if (type == '2')
 {
 if (confirm("Are you sure you want to delete this provider?"))
 document.location.href= "manage_providers.php?action=remove&id="+ id;
 }
 else if (type == '3')
 {
 if (confirm("Are you sure you want to delete this download?"))
 document.location.href= "manage_downloads.php?action=remove&id="+ id;
 }
 else if (type == '4')
 {
 if (confirm("Are you sure you want to remove this message?"))
 document.location.href= "manage_messages.php?action=remove&id="+ id;
 }
 else if (type == '5')
 {
 if (confirm("Are you sure you want to remove this commercial?"))
 document.location.href="manage_commercials.php?action=remove&id="+id;
 }
 else if (type == '6')
 {
 if (confirm("Are you sure you want to remove this broadband plan?"))
 document.location.href="manage_broadband.php?action=remove&id="+id;
 }
 else if (type == '7')
 {
 if (confirm("Are you sure you want to remove this VOIP plan?"))
 document.location.href="manage_voip.php?action=remove&id="+id;
 }
 else if (type == '8')
 {
 if (confirm("Are you sure you want to remove this question?"))
 document.location.href="manage_faq.php?action=remove&id="+id;
 }
 else if (type == '9')
 {
 if (confirm("Are you sure you want to remove this newsletter?"))
 document.location.href="manage_newsletter.php?action=remove&id="+id;
 }
 else if (type == '10')
 {
 if (confirm("Are you sure you want to remove this broadband plan?"))
 document.location.href="provider_manage_broad.php?action=remove&id="+id;
 }
 else if (type == '11')
 {
 if (confirm("Are you sure you want to remove this VOIP plan?"))
 document.location.href="provider_manage_voip.php?action=remove&id="+id;
 }
 else if (type == '12')
 {
 if (confirm("Are you sure you want to remove this Page?"))
 document.location.href="pages.php?action=remove&id="+id;
 }else if (type == '13'){
 if (confirm("Are you sure you want to remove this Script?"))
 document.location.href="getScripts.php?action=remove&id="+id;
 }
} 

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="728" height="90">';
	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);
}