function display(id){
  if (document.getElementById(id).style.display == 'none') { document.getElementById(id).style.display = 'block'; }
  else { document.getElementById(id).style.display = 'none'; }
}

function img(view,pais) {
  window.open('http://www.hagomiscompras.com/img.php?view='+view+'&country='+pais,'img','width=100, height=100, left=10, top=10, scrollbars=0, resize=0');
}

function url(url) {
  open(url,'','toolbar = 1, location = 1, directories = 1, status = 1, menubar = 1, scrollbars = 1, resizable = 1');
}

function changeorder(url) {
	if (url != '') { location.href = url; }
}
/* ##############################
               BBCODE       
   ############################## */
   
function FormName(obj) { 
    do { 
        obj=obj.parentNode; 
    } while(obj.tagName!="FORM"); 
    return obj.name; 
    return false; 
} 

function BBCode(form, name, code) {
  uri = 'extra/format.php?form=' +form+ '&name=' +name+ '&code=' +code;
  if (code == "URL" || code == "WEB") { window.open(uri,"","width=450,height=173,top=90"); }
  else if (code == "IMG") { window.open(uri,"","width=450,height=250,top=90"); }
  else if (code == "COLOR") { window.open(uri,"","width=450,height=120,top=90"); }
  else { window.open(uri,"","width=450,height=115,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="' + text1 + '" align="' + text2 + ']' + text + '[/img]'; }
    
    if (text != "" && code != "URL" && code != "IMG" && code != "WEB" && code != "COLOR") { 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 == "WEB") { 
      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; }
    }
    else if (code == "IMG") { 
      if (text != "" && text1 != "" && text2 != "") { 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 ConfirmDelete(form){ 
    if (confirm('Esta acción eliminara todos los items seleccionados: ¿esta seguro que desea eliminarlos?')){ 
       document.forms[form].submit() 
    } 
} 

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 SendForm(form,uri,evalform){
  if (evalform) {
    document.forms[form].action = uri;
    document.forms[form].target = '';
    document.forms[form].onsubmit = 'return true';
  }
}


function ChangeClass(id,newclass){
    var el = document.getElementById(id); 
    el.className=newclass;
}


function validDownload() {
	if (document.forms[0]['mirror'].value != "") {
		if (document.forms[0]['verifycode'].value != "") {
			return true;
		}
		else {
			alert("Debe ingresar el codigo de seguridad"); document.forms[0]['verifycode'].focus(); return false;
		}
	}
	else {
		alert("Seleccione un servidor"); return false;
	}
}