// JavaScript Document

/*FOROS**********************************************************************************/

function foros_expandirRama(id,id_base,logic,forum_exception){

	forum_exception = defecto(forum_exception, '', true);
	goAJAX('rama_'+id,'ajax.php','gear=getArbolForo&rama='+id+'&solorama=true&logic='+logic+'&id_base='+id_base+'&forum_exception='+forum_exception,'document.getElementById(\'rama_'+id+'\').innerHTML = respuesta;','','0','0');
	document.getElementById('li_'+id).className = "open";
}

function foros_moveTo(id_from,logic,width,height,forum_exception){
	width = defecto(width, 500, true);
	height = defecto(height, 340, true);
	forum_exception = defecto(forum_exception, '', true);
	strCargando = "<div style='padding:10px;'>Cargando...</div>";
	var urlwin='ajax.php?gear=getArbolForo&id='+id_from+'&logic='+logic+'&id_base='+id_from+'&forum_exception='+forum_exception;
	showWin(urlwin,'Seleccione Foro',width,height);
	strCargando = "cargando...";
}

function foros_moveNow(id, forum_id_destiny,logic){

goAJAX(id,'ajax.php','gear=moveToForo&id='+id+'&forum_id_destiny='+forum_id_destiny+'&logic='+logic,'if(respuesta=="Actualizado"){document.location.href="foros-nueva-ubicacion-'+forum_id_destiny+'-1.fx";}else{alert(respuesta);}','','0','0');

}

var foros_validez_data = false;

function foros_validarRegistroForo(){

foros_validez_data = true;

foros_limpiarTodo();

foros_validaEntrada("titulo");

foros_validaEntrada("cant_temas");

foros_validaEntrada("descripcion");

return foros_validez_data;

}

function foros_validarRegistroTema(){

foros_validez_data = true;

foros_limpiarTodo();

foros_validaEntrada("titulo");

foros_validaEntrada("contenido");

return foros_validez_data;

}

function foros_limpiarTodo(){

var elements = document.getElementsByTagName("span");

for(var i=0;i<elements.length;i++){

if(isDefined(elements.item(i))){

if(elements.item(i).className=="iconoerror")

elements.item(i).style.visibility="";

}

}

}

function foros_validaEntrada(name){

if(document.getElementById(name).value==""){

document.getElementById('icon_' + name).style.visibility="visible";

foros_validez_data = false;

}

}

function foros_suscribirse(id,tipo,valor){

goAJAX(id,'ajax.php','gear=foros/suscribirse&id='+id+'&tipo='+tipo+'&valor='+valor,'document.getElementById(\'opcionesSuscripcion\').innerHTML = respuesta;','','0','0');

}

function foros_mostrarConfig(enl){

if(document.getElementById('configuraciones').style.display == "none"){

document.getElementById('configuraciones').style.display = "block";

enl.innerHTML = "Ocultar configuraci&oacute;n";

}else{

document.getElementById('configuraciones').style.display = "none";

enl.innerHTML = "Mostrar configuraci&oacute;n";

}

}

function foros_change_type_ilk(direction){

if(direction){

document.getElementById('type_ilk').style.display = "block";

}else{

document.getElementById('type_ilk').style.display = "none";

}

}

/*POSTs Foros*/

function foros_getTTDR(id){

if(isDefined(document.getElementById(id))){

if(!isDefined($(id).prototip)){

new Tip($(id), 'Responder al usuario',{

style: 'darkgrey',

stem: 'bottomMiddle',

hook: {tip: 'bottomMiddle', mouse: false},

    offset: { x: 50, y: 0},

closeButton: false,

showOn: 'mousemove',

hideOthers: true,

radius:3,

border:3,

hideAfter:1,

hideOn: false,

width:113

});

}

}

}

function foros_getTTDOk(id){

if(isDefined(document.getElementById(id))){

if(!isDefined($(id).prototip)){

new Tip($(id), 'Votar a favor',{

style: 'darkgrey',

stem: 'bottomMiddle',

hook: {tip: 'bottomMiddle', mouse: false},

    offset: { x: 12, y: 0},

closeButton: false,

showOn: 'mousemove',

hideOthers: true,

radius:3,

border:3,

hideAfter:1,

hideOn: false,

width:78

});

}

}

}

function foros_getTTDKo(id){

if(isDefined(document.getElementById(id))){

if(!isDefined($(id).prototip)){

new Tip($(id), 'Votar en contra',{

style: 'darkgrey',

stem: 'bottomMiddle',

hook: {tip: 'bottomMiddle', mouse: false},

    offset: { x: 12, y: 0},

closeButton: false,

showOn: 'mousemove',

hideOthers: true,

radius:3,

border:3,

hideAfter:1,

hideOn: false,

width:88

});

}

}

}

function foros_getOptionsReport(id){

if(isDefined(document.getElementById('linkReport'+id))){

if(!isDefined($('linkReport'+id).prototip)){

content = "<a href=\"#\" onclick=\"foros_reportComment('" + id +"',0);return false;\" class=\"linkWhite\">Spam</a><a href=\"#\" onclick=\"foros_reportComment('" + id +"',1);return false;\" class=\"linkWhite\">Inapropiado</a><a href=\"#\" onclick=\"foros_reportComment('" + id + "',2);return false;\" class=\"linkWhite\">Ofensivo</a>";

new Tip($('linkReport'+id), content,{

style: 'darkgrey',

stem: 'bottomMiddle',

hook: {tip: 'bottomMiddle', mouse: false},

    offset: { x: 12, y: 0},

closeButton: false,

showOn: 'mousemove',

hideOthers: true,

radius:3,

border:3,

hideAfter:1,

hideOn: false,

width:150

});

}

}

}


function foros_crearTooltips(id){

foros_getTTDR('linkResponse'+id);

foros_getTTDOk('rateY'+id);

foros_getTTDKo('rateN'+id);

foros_getOptionsReport(id);

}

function foros_enviarComments(tema_id){

Tips.hideAll();

goAJAX('comment','ajax.php','gear=foros/saveMensaje&tema_id='+tema_id+'&mensaje='+document.getElementById('mensaje').value,'document.getElementById(\'resultBody\').innerHTML = respuesta;document.getElementById(\'mensaje\').value=\'\';','','0','0');

return false;

}

function foros_getCommentsPag(pagcomment,tema_id){

Tips.hideAll();

goAJAX('comment','ajax.php','gear=foros/getListaMensajesPag&tema_id='+tema_id+'&pagcomment=' + pagcomment,'document.getElementById(\'resultBody\').innerHTML = respuesta;','','0','0');

return false;

}

function foros_rateComment(id, val, tema_id){

Tips.hideAll();

goAJAX('comment','ajax.php','gear=foros/rateMensaje&tema_id='+tema_id+'&mensaje_id=' + id + '&value=' + val,'document.getElementById(\'rateComment'+id+'\').innerHTML = \'\';document.getElementById(\'valoracion'+id+'\').innerHTML = respuesta;','','0','0');

return false;

}

function foros_cerrarForms(){

elements = document.getElementsByTagName('div');

total = elements.length;

for(i=0;i<total;i++){

if(isDefined(elements.item(i))){

if(elements.item(i).className == "operacionM"){

elements.item(i).innerHTML = "";

}

}

}

}

function foros_responseTo(id,nivel,tema_id){

foros_cerrarForms();

Tips.hideAll();

document.getElementById('operacionM'+id).innerHTML = foros_getFormMini(id,tema_id);

content = '<div onmouseover="getPosFocus(\'mensaje'+ id +'\');"><form id="puEditITagLink_Form'+ id +'"><p>URL:</p><p><input type="text" id="urlIncludeLink'+ id +'" name="url" value="http://" style="width:250px;" /></p><p>Texto del enlace:</p><p><input type="text" id="textoIncludeLink'+ id +'" name="texto" value="" style="width:250px;" /></p><p style="padding-top:10px;"><input type="button" name="enviar" value="Aceptar" onClick="okIncludeLink(\'mensaje'+ id +'\',\'puEditITagLink_'+ id +'\',\''+ id +'\');$(\'puEditITagLink_Form'+ id +'\').reset();">&nbsp;&nbsp;&nbsp;<input type="button" name="cancelar" value="Cancelar" onClick="cancelIncludeLink(\'puEditITagLink_'+ id +'\');$(\'puEditITagLink_Form'+ id +'\').reset();"></p></form></div>';

puEditITagLinkTT('mensaje'+ id,$('puEditITagLink_'+ id),content);

if(nivel>=2){

content = '<div onmouseover="getPosFocus(\'mensaje'+ id +'\');"><form id="puEditITagImg_Form'+ id +'"><p>URL de la imagen:</p><p><input type="text" id="urlIncludeImg'+ id +'" name="img" value="http://" style="width:250px;" /></p><p id="optDisplayImg'+ id +'" style="padding-top:4px;" align="right"><a href="#" onclick="displaySizeImg(\''+ id +'\');return false;">Configurar tama&ntilde;o</a></p><span id="displayImg'+ id +'" style="display:none;"><p>Ancho:</p><p><input type="text" id="widthIncludeImg'+ id +'" name="texto" value="" style="width:250px;" /></p><p>Alto:</p><p><input type="text" id="heightIncludeImg'+ id +'" name="texto" value="" style="width:250px;" /></p></span><p style="padding-top:10px;"><input type="button" name="enviar" value="Aceptar" onClick="okIncludeImg(\'mensaje'+ id +'\',\'puEditITagImg_'+ id +'\',\''+ id +'\');">&nbsp;&nbsp;&nbsp;<input type="button" name="cancelar" value="Cancelar" onClick="cancelIncludeImg(\'puEditITagImg_'+ id +'\');$(\'puEditITagImg_Form'+ id +'\').reset();"></p></form></div>';

}else{

content = '<div onmouseover="getPosFocus(\'mensaje'+ id +'\');"><form id="puEditITagImg_Form'+ id +'"><p>URL de la imagen:</p><p><input type="text" id="urlIncludeImg'+ id +'" name="img" value="http://" style="width:250px;" /></p><p id="optDisplayImg'+ id +'" style="display:none;padding-top:4px;" align="right"><a href="#" onclick="displaySizeImg(\''+ id +'\');return false;">Configurar tama&ntilde;o</a></p><span id="displayImg'+ id +'" style="display:none;"><p>Ancho:</p><p><input type="text" id="widthIncludeImg'+ id +'" name="texto" value="" style="width:250px;" /></p><p>Alto:</p><p><input type="text" id="heightIncludeImg'+ id +'" name="texto" value="" style="width:250px;" /></p></span><p style="padding-top:10px;"><input type="button" name="enviar" value="Aceptar" onClick="okIncludeImg(\'mensaje'+ id +'\',\'puEditITagImg_'+ id +'\',\''+ id +'\');">&nbsp;&nbsp;&nbsp;<input type="button" name="cancelar" value="Cancelar" onClick="cancelIncludeImg(\'puEditITagImg_'+ id +'\');$(\'puEditITagImg_Form'+ id +'\').reset();"></p></form></div>';

}

puEditITagImgTT('mensaje'+ id,$('puEditITagImg_'+ id),content);

url = document.location.href;

urls = url.split("#");

document.location.href = urls[0] + "#respuesta"+id;

}

function foros_cancelTo(id){

Tips.hideAll();

document.getElementById('operacionM'+id).innerHTML = "";

}

function foros_responseComments(id,tema_id){

Tips.hideAll();

goAJAX('comment','ajax.php','gear=foros/saveMensaje&tema_id='+tema_id+'&mensaje_id='+ id +'&mensaje='+document.getElementById('mensaje' + id).value,'document.getElementById(\'resultBody\').innerHTML = respuesta;','','0','0');

return false;

}

function foros_getFormMini(id,tema_id){

return '<div class="miniFormRespuesta"><form method="post" action="." class="editor" enctype="multipart/form-data"><div id="dejarMsgAviso" style="display:none;" class="msg_amarillo"></div><div class="botonera"><div class="colores"> <a href="" class="btn_c00" onclick="return puEditITagColor(\'mensaje'+id+'\',\'e46add\');"></a> <a href="" class="btn_c01" onclick="return puEditITagColor(\'mensaje'+id+'\',\'865bc2\');"></a> <a href="" class="btn_c02" onclick="return puEditITagColor(\'mensaje'+id+'\',\'5785c2\');"></a> <a href="" class="btn_c03" onclick="return puEditITagColor(\'mensaje'+id+'\',\'4094bf\');"></a> <a href="" class="btn_c04" onclick="return puEditITagColor(\'mensaje'+id+'\',\'70b250\');"></a> <a href="" class="btn_c05" onclick="return puEditITagColor(\'mensaje'+id+'\',\'efd41c\');"></a> <a href="" class="btn_c06" onclick="return puEditITagColor(\'mensaje'+id+'\',\'f7bd58\');"></a> <a href="" class="btn_c07" onclick="return puEditITagColor(\'mensaje'+id+'\',\'ed5757\');"></a> </div>   <div class="botones"><a href="" class="btn_negrita" onclick="return puEditITag(\'mensaje'+id+'\',\'[b]\',\'[/b]\');"></a> <a href="" class="btn_cursiva" onclick="return puEditITag(\'mensaje'+id+'\',\'[em]\',\'[/em]\');"></a> <a href="" class="btn_link" onclick="return false;" id="puEditITagLink_'+id+'"></a> <a href="" class="btn_cita" onclick="return puEditITag(\'mensaje'+id+'\',\'[blockquote]\',\'[/blockquote]\');"></a><a href="" class="btn_img" onclick="return false;" id="puEditITagImg_'+id+'"></a></div></div> <input type="hidden" id="posImensaje'+id+'" value="-1" />   <input type="hidden" id="posFmensaje'+id+'" value="-1" /><div class="txt"><textarea class="textarea" name="mensaje'+id+'" id="mensaje'+id+'" onmouseover="rebootPos(\'mensaje'+id+'\');"></textarea></div>    <div class="btnsComment">    <div class="btnAddComment"><a href="#" onclick="if($(\'mensaje'+id+'\').value!=\'\'){foros_responseComments(\''+id+'\',\''+tema_id+'\');}return false;">Enviar respuesta</a></div> <div class="btnCancelComment"><a href="#" onclick="foros_cancelTo(\''+id+'\');return false;">Cancelar</a></div>    </div></form></div><br /><br />';

}

function foros_deleteComment(mensaje_id){

Tips.hideAll();

if(confirm('Confirme la operaci\u00f3n de borrado. No podra deshacer esta acci\u00f3n')){

goAJAX('mensaje','ajax.php','gear=foros/deleteMensaje&mensaje_id='+ mensaje_id,'document.getElementById(\'resultBody\').innerHTML = respuesta;','','0','0');

return false;

}

}

function foros_reportComment(id, type){

Tips.hideAll();

goAJAX('comment','ajax.php','gear=foros/reportMensaje&mensaje_id=' + id + '&type=' + type+'&tema_id=tema_id','if(respuesta!=\'\'){document.getElementById(\'resultBody\').innerHTML = respuesta;}','','0','0');

return false;

}

function foros_cambiarViewMore(orientacion, id, count){

if(orientacion){

    document.getElementById('responses' + id).className = 'responseListHidden';

if(count>1){

if(count<10)

plural = "s&nbsp;";

else

plural = "s";

}else

plural = "&nbsp;&nbsp;&nbsp;";

        document.getElementById('viewmore' + id).innerHTML = '<a href="#" onclick="foros_cambiarViewMore(false,\''+id+'\',\''+count+'\');return false;" class="btnViewAll">'+count+' Respuesta'+plural+' <span class="blue">Ver</span></a>';

   }else{

    document.getElementById('responses' + id).className = 'responseList';

        document.getElementById('viewmore' + id).innerHTML = '<a href="#" onclick="foros_cambiarViewMore(true,\''+id+'\',\''+count+'\');return false;" class="btnHiddenAll">Ocultar</a>';

   }

}

/*POSTs Foros*/
function foros_getAvatar(id,content){
	if(isDefined(document.getElementById('avatar'+id))){
		if(!isDefined($('avatar'+id).prototip)){
			new Tip($('avatar'+id), content,{
				style: 'darkgrey',
				stem: 'bottomMiddle',
				hook: { tip: 'bottomMiddle', mouse: false },
				offset: { x: 35, y: 0},
				closeButton: false,
				showOn: 'mousemove',
				hideOthers: true,
				radius:5,
				border:5,
				hideOn: false,
				width: 100,
				hideAfter:1
			});
		}
	}
}

/*FOROS**********************************************************************************/
