var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
  try {
  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
 } catch (e) {
  try {
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  } catch (E) {
   xmlhttp=false
  }
 }
@else
 xmlhttp=false
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 try {
  xmlhttp = new XMLHttpRequest();
 } catch (e) {
  xmlhttp=false
 }
}
function markAllForRemove() {
	for (var i=0; i< document.comentarios.length; i++) {
		if (document.comentarios[i].name == "borrar_comentario[]") {
			document.comentarios[i].checked = true;
		}
	}
}
function markAllForApprove() {
	for (var i=0; i< document.comentarios.length; i++) {
		if (document.comentarios[i].name == "publicar_comentario[]") {
			document.comentarios[i].checked = true;
		}
	}
}
function toggle(id) {
	if (document.getElementById(id).style.display == 'block') {
		document.getElementById(id).style.display = 'none'
	} else {
		document.getElementById(id).style.display = 'block'
	}
}
function toggletags(id) {
	var d = document.getElementById(id);
		for (var i = 1; i<=10; i++) {
			if (document.getElementById('divtag'+i)) { document.getElementById('divtag'+i).style.display='none'; }
		}
	if (d) {d.style.display='block';}
}

function mostrar(id) {
	document.getElementById(id).style.display = 'block'
}
function borrarimg(nombre) {
	document.getElementById(nombre+'imgbg').value = '';
	document.getElementById('imgactual'+nombre).style.display = 'none'
}
function previsualizar(id1, id2){
 		var NewText = document.getElementById(id1).value;
 		splitText = NewText.split(/\n/).join("<br />");
 		var DivElement = document.getElementById(id2);
 		DivElement.innerHTML = splitText;
}
function addcat(lang) {
	  frm=document.getElementById('newpostform')
	  url="/"+lang+"/admin/nuevo/"+frm.elements['newcategory'].value+"/"+frm.elements['id_blog'].value
	  brandnew=frm.elements['newcategory'].value
	  frm.elements['newcategory'].value=''
	  xmlhttp.open("GET",url,true)
	  xmlhttp.onreadystatechange=function() {
	   if (xmlhttp.readyState==4) {
		if (xmlhttp.responseText==0) {
		chkbx = '<div id="prohibido"><p>Category already exits!</p></div>'
		} else {
		chkbx = '<input type="checkbox" name="categ[]" id="b" value="'+xmlhttp.responseText+'" checked ><label for="b">'
		chkbx += brandnew + '</label> <br />'
		}
		document.getElementById('addcat').innerHTML+= chkbx
	   }
	  }
	  xmlhttp.setRequestHeader('Accept','message/x-formresult')
	  xmlhttp.send(null)
	  return false
}

function cargando(id) {
	document.getElementById('compdis'+id).innerHTML = '';
}

function compdis(formulario, id, lang) {
	  document.getElementById('compdis'+id).innerHTML = '';
	  frm=document.getElementById(formulario)
	  if (id=="login") id2="login";
	  if (id=="nomblog") id2="nomblog";
	  if (id=="nombre") id2="nomblog";
	  url="/ajax/ajax.php?lang="+lang+"&id1=compdis&id2="+id2+"&id3="+frm.elements[id].value
	  xmlhttp.open("GET",url,true)
	  xmlhttp.onreadystatechange=function() {
	   if (xmlhttp.readyState==4) {
		chkbx = xmlhttp.responseText;
		document.getElementById('compdis'+id2).innerHTML+= chkbx;
		document.getElementById('carg'+id2).style.display = 'none';
	   }
	  }
	  xmlhttp.setRequestHeader('Accept','message/x-formresult')
	  xmlhttp.send(null)
	  return false
}
function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) {
		field.value = field.value.substring(0, maxlimit);
	}
	else {
		obj = document.getElementById(countfield);
        obj.childNodes[0].data = maxlimit - field.value.length;
	}
}
function peview_post(a) {
	var titulo = window.opener.document.newpostform.titulo.value;
	var texto = window.opener.document.newpostform.texto.value;
	document.getElementById('titulo').innerHTML+= titulo;
	document.form_text.text.value = texto;
	if (a) {
	document.form_text.submit();
	}
//	document.getElementById('texto').innerHTML+= texto;
}
function hide(idToHide) {
					document.getElementById(idToHide).style.display='none';
				}
function show(idToShow) {
					document.getElementById(idToShow).style.display='block';
				}