function block(){
  if (document.getElementById('tbl_form').style.display == 'none') {
    document.getElementById('tbl_btn_add').style.display = 'none';
    document.getElementById('tbl_form').style.display = 'block';
  }
  else {
    document.getElementById('tbl_form').style.display = 'none';
    document.getElementById('tbl_btn_add').style.display = 'block';
  }
}

function go(uri) {
  location.href = uri;
}

function FormName(obj) { 
    do { 
        obj=obj.parentNode; 
    } while(obj.tagName!="FORM"); 
    return obj.name; 
    return false; 
} 

function BBCode(form, name, code) {
  uri = 'format.php?form=' +form+ '&name=' +name+ '&code=' +code;
  if (code == "URL" || code == "WEB" || code == "COLOR") { window.open(uri,"","width=450,height=140,top=90"); }
  else if (code == 'emoticons') { window.open(uri,"","width=450,height=140,top=90"); }
  else { window.open(uri,"","width=450,height=70,top=90"); }
}

function BBCodeADD(form, name, code, text, text1, text2) {
  /* SI LLEGA EL NOMBRE DEL FORMULARIO */
  if (form != "") {
    
    if (code == "B") { texto = '[b]' + text + '[/b]'; }
    else if (code == "I") { texto = '[i]' + text + '[/i]'; }
    else if (code == "U") { texto = '[u]' + text + '[/u]'; }
    else if (code == "L") { texto = '[left]' + text + '[/left]'; }
    else if (code == "C") { texto = '[center]' + text + '[/center]'; }
    else if (code == "R") { texto = '[right]' + text + '[/right]'; }
    else if (code == "J") { texto = '[justify]' + text + '[/justify]'; }
    else if (code == "MAIL") { texto = '[mail]' + text + '[/mail]'; }
    else if (code == "URL") { texto = '[url=' + text1 + ']' + text + '[/url]'; }
    else if (code == "WEB") { texto = '[web=' + text1 + ']' + text + '[/web]'; }
    else if (code == "COLOR") { texto = '[color=' + text1 + ']' + text + '[/color]'; }
    else if (code == "IMG") { texto = '[img]' + text + '[/img]'; }
    else if (code == "emoticons") { texto = ' ' + text + ' '; }
    
    if (text != "" && code != "URL" && code != "WEB" && code != "IMG" && code != "COLOR") { document.forms[form][name].value = document.forms[form][name].value + texto; }
    
    else if (code == "IMG") { 
      if (text != "") { document.forms[form][name].value = document.forms[form][name].value + texto; }
    }
    else if (code == "URL") { 
      if (text != "" && text1 != "") { document.forms[form][name].value = document.forms[form][name].value + texto; }
    }
    else if (code == "COLOR") { 
      if (text != "" && text1 != "") { document.forms[form][name].value = document.forms[form][name].value + texto; }
    }
    document.forms[form][name].focus();
  }
  
  /* SI NO LLEGA EL NOMBRE DEL FORMULARIO */
  else { alert("Se produjo un error, recarge la pagina"); }
}
function mnu_bbcode_over(element){ 
        var el = document.getElementById(element); 
                el.className='bbcode_icons_over';  
} 
function mnu_bbcode_out(element){ 
        var el = document.getElementById(element); 
                el.className='bbcode_icons';    
}

function EvalForm(form) {
  if (document.forms[form].title.value != "") {
    if (document.forms[form].post.value != "") {
      return true;
    }
    else {
      alert("Ingrese el Mensaje"); document.forms[form].post.focus();
      return false;
    }
  }
  else {
    alert("Ingrese el Titulo"); document.forms[form].title.focus();
    return false;
  }
}

function Preview(form,type){
  if (EvalForm(form)) {
    document.forms[form].action = 'preview.php?type=' + type;	
    document.forms[form].target = 'preview';
    window.open('preview.php','preview','toolbar=1,location=1,status=1,menubar=0,scrollbars=1,resizable=0,menu=0,width=650,height=200');
    document.forms[form].onsubmit = 'return true';
  }
}


function SendForm(form,uri){
  if (EvalForm(form)) {
    document.forms[form].action = uri;
    document.forms[form].target = '';
    document.forms[form].onsubmit = 'return true';
  }
}
function DisableForm(form,name) { document.forms[form][name].disabled = true; }

function ConfirmAction(uri){ 
    if (confirm('¿Esta seguro de querer llevar acabo esta acción?')){ 
       location.href = uri;
    } 
}

function quote(text) {
  document.forms['addPost'].post = document.forms['addPost'].post + document.getElementById(text).value; 
}

function close_aviso_pmsg() {
  document.getElementById('aviso_new_priv').style.display='none';
  pmsg('url');
}

function pmsg(url) {
  window.open('../pmsg/index.php','','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,menu=0,width=730, height=350, left=20, top=20, scrollbars=YES');
}
function pmsgSend(nick) {
  window.open('../pmsg/index.php?mod=new&nick=' + nick,'','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,menu=0,width=730, height=350, left=20, top=20, scrollbars=YES');
}
function url(url) {
  window.open(url); return false;
}
