// JavaScript Document
/*gear comments*********************************************************************************/
function gcomments_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 gcomments_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 gcomments_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 gcomments_getOptionsReport(id, gear, id_gear){
	if(isDefined(document.getElementById('linkReport'+id))){
		if(!isDefined($('linkReport'+id).prototip)){
			content = "<a href=\"#\" onclick=\"gcomments_reportComment('" + id +"',0,'" + gear +"','" + id_gear +"');return false;\" class=\"linkWhite\">Spam</a><a href=\"#\" onclick=\"gcomments_reportComment('" + id +"',1,'" + gear +"','" + id_gear +"');return false;\" class=\"linkWhite\">Inapropiado</a><a href=\"#\" onclick=\"gcomments_reportComment('" + id + "',2,'" + gear +"','" + id_gear +"');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 gcomments_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
			});
		}
	}
}

function gcomments_crearTooltips(id, gear, id_gear){
	gcomments_getTTDR('linkResponse'+id);
	gcomments_getTTDOk('rateY'+id);
	gcomments_getTTDKo('rateN'+id);
	gcomments_getOptionsReport(id, gear, id_gear);
}

function gcomments_enviarComments(gear,id_gear){
	Tips.hideAll();
	goAJAX('comment','ajax.php','gearAbsolute=gears/common/comment/saveComment.php&gear='+gear+'&ajax=true&id_gear='+id_gear+'&comment='+document.getElementById('comment').value,'document.getElementById(\'resultBody\').innerHTML = respuesta;','','0','0');
	return false;
}

function gcomments_getCommentsPag(pagcomment,gear,id_gear){
	Tips.hideAll();
	goAJAX('comment','ajax.php','gearAbsolute=gears/common/comment/getCommentPag.php&gear='+gear+'&ajax=true&id_gear='+id_gear+'&pagcomment=' + pagcomment,'document.getElementById(\'resultBody\').innerHTML = respuesta;','','0','0');
	return false;
}

function gcomments_rateComment(id, val){
	Tips.hideAll();
	goAJAX('comment','ajax.php','gearAbsolute=gears/common/comment/rateComment.php&comment_id=' + id + '&val=' + val,'document.getElementById(\'rateComment'+id+'\').innerHTML = \'\';document.getElementById(\'valoracion'+id+'\').innerHTML = respuesta;','','0','0');
	return false;
}

function gcomments_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 gcomments_responseTo(id,gear,id_gear){
	gcomments_cerrarForms();
	Tips.hideAll();
	document.getElementById('operacionM'+id).innerHTML = gcomments_getFormMini(id,gear,id_gear);
	content = '<div onmouseover="getPosFocus(\'comment'+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(\'comment'+ 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('comment'+ id,$('puEditITagLink_'+ id),content);
	url = document.location.href;
	urls = url.split("#");
	document.location.href = urls[0] + "#respuesta" + id;
}
function gcomments_cancelTo(id){
	Tips.hideAll();
	document.getElementById('operacionM'+id).innerHTML = "";
}
function gcomments_responseComments(id, gear, id_gear){
	Tips.hideAll();
	goAJAX('comment','ajax.php','gearAbsolute=gears/common/comment/saveComment.php&gear='+gear+'&ajax=true&id_gear='+id_gear+'&comment_id='+ id +'&comment='+document.getElementById('comment' + id).value,'document.getElementById(\'resultBody\').innerHTML = respuesta;','','0','0');
	return false;
}
function gcomments_getFormMini(id,gear,id_gear){
	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(\'comment'+id+'\',\'e46add\');"></a> <a href="" class="btn_c01" onclick="return puEditITagColor(\'comment'+id+'\',\'865bc2\');"></a> <a href="" class="btn_c02" onclick="return puEditITagColor(\'comment'+id+'\',\'5785c2\');"></a> <a href="" class="btn_c03" onclick="return puEditITagColor(\'comment'+id+'\',\'4094bf\');"></a> <a href="" class="btn_c04" onclick="return puEditITagColor(\'comment'+id+'\',\'70b250\');"></a> <a href="" class="btn_c05" onclick="return puEditITagColor(\'comment'+id+'\',\'efd41c\');"></a> <a href="" class="btn_c06" onclick="return puEditITagColor(\'comment'+id+'\',\'f7bd58\');"></a> <a href="" class="btn_c07" onclick="return puEditITagColor(\'comment'+id+'\',\'ed5757\');"></a> </div>   <a name="respuesta'+ id +'"></a>  <div class="botones"> <a href="" class="btn_negrita" onclick="return puEditITag(\'comment'+id+'\',\'[b]\',\'[/b]\');"></a> <a href="" class="btn_cursiva" onclick="return puEditITag(\'comment'+id+'\',\'[em]\',\'[/em]\');"></a> <a href="" class="btn_link" onclick="return false;" id="puEditITagLink_'+id+'"></a> <a href="" class="btn_cita" onclick="return puEditITag(\'comment'+id+'\',\'[blockquote]\',\'[/blockquote]\');"></a></div></div> <input type="hidden" id="posIcomment'+id+'" value="-1" /><input type="hidden" id="posFcomment'+id+'" value="-1" /><div class="txt"><textarea class="textarea" name="comment'+id+'" id="comment'+id+'" onmouseover="rebootPos(\'comment'+id+'\');"></textarea></div>    <div class="btnsComment">    <div class="btnAddComment"><a href="#" onclick="if($(\'comment'+id+'\').value!=\'\'){gcomments_responseComments(\''+id+'\',\''+gear+'\',\''+id_gear+'\');}return false;">Enviar respuesta</a></div> <div class="btnCancelComment"><a href="#" onclick="gcomments_cancelTo(\''+id+'\');return false;">Cancelar</a></div>    </div></form></div><br /><br />';
}
function gcomments_reportComment(id, type, gear, id_gear){
	Tips.hideAll();
	goAJAX('comment','ajax.php','gearAbsolute=gears/common/comment/reportComment.php&comment_id=' + id + '&type=' + type+'&gear='+gear+'&id_gear='+id_gear,'if(respuesta!=\'\'){document.getElementById(\'resultBody\').innerHTML = respuesta;}','','0','0');
	return false;
}
function gcomments_cambiarViewMore(orientacion, id, count){
	Tips.hideAll();
	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="gcomments_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="gcomments_cambiarViewMore(true,\''+id+'\',\''+count+'\');return false;" class="btnHiddenAll">Ocultar</a>';
	}
}
/*gear comments*********************************************************************************/