function delComment(id){
	$(id).remove();
}
function add_vote(id,idbutton,v){
	nums = v.split('|');
	$(id).innerHTML = nums[0];
	$(idbutton).writeAttribute("onclick", 'javascript:alert(\'Gracias por votar.\');');
	$(idbutton).innerHTML = 'Votado';
}
function goURL(url){
		document.location=url;
	}
function addrow(datas){
	var trFirst = $('first');
	new Insertion.Before('first','<tr id="first" style="display:none;" onclick="javascript:goURL(\''+datas['spy']['relation_url']+'\')"><td class="hora">'+datas['spy']['created']+'</td><td>'+datas['spy']['template']+'</td><td class="texto">'+datas['spy']['value']+'</td><td class="usuario">'+datas['User']['username']+'</td></tr>');
	trFirst.id='';
	new Effect.Appear('first',{ duration: 1.5 });

	trLast = $('last');
	trLast.previous('tr').id="last";
	trLast.fade({ duration: 1.5 });
	$('last_spy_id').value=datas['spy']['id'];
}
function getData(){
	if(key < spy.length){
		addrow(spy[key]);
		key++;
	}
	else{
		new Ajax.Request("/2009/spy/getlinespy/"+$('last_spy_id').value, {
			onSuccess: function(transport) {
				aux = transport.responseText.split("|");
				spy = eval(aux[0]);
				key=0;
				if(spy.length > 0)
					getData();
			}
		});
	}
		
}	
function del_post(id,response){
	$(id).remove();
}
function submit_message(){
	
  var theList = $$('.op');
  theList.each(function(element, index){
	if(element.checked){
		v = $('mids').value;
		v = v + element.value+',';	
		$('mids').value = v;
	}
	});
}

function blinds(id){
	if($(id).style.display == "none")
		$(id).show();
	else
		$(id).hide();
}

function reportar_abuso(url){
	if(confirm('¡Atención!\n\nSi se marca como inapropiado de forma injustificada se corre el riesgo de perder tu propio nick.\n\nSólo se deben marcar posts con insultos claros, graves y directos.\n\n¿Seguro que quieres marcar el mensaje como inapropiado?'))
		new Ajax.Request(url, {asynchronous:true, evalScripts:true, onComplete:function(request, json) {alert(request.responseText);}});
	else 
		return false;

}

function vote_radio(webroot,castingid) {
	var selection = document.votes.opcion;
	for (i=0; i<selection.length; i++){
		if (selection[i].checked == true)
		id = selection[i].value;
	}
new Ajax.Request(webroot+'casting/add_vote_average/'+castingid+'/'+id, {asynchronous:true, evalScripts:true, onComplete:function(request, json) {add_vote("score_total","vote_button",request.responseText)}});   
	}

function changeActive(stat) {
	if(stat == 'open') {
		$('cola_open').addClassName("active")
		$('cola_close').removeClassName("active");
	} else {
		$('cola_close').addClassName("active")
		$('cola_open').removeClassName("active");
	}
} 
