$(document).ready(function () {
  // hide all ULs inside LI.drawer except the first one
  $('LI.drawer UL').hide(); 

  // apply the open class
  $('LI.drawer UL:first').addClass('open');

  $('H2.drawer-handle').click(function () {
    // hide the currently visible drawer contents
    $('LI.drawer UL:visible').hide();

    // remove the open class from the currently open drawer
    $('H2.open').removeClass('open');

    // show the associated drawer content to 'this' (this is the current H2 element)
    // since the drawer content is the next element after the clicked H2, we find
    // it and show it using this:
    $(this).next().show();

    // set a class indicating on the H2 that the drawer is open
    $(this).addClass('open');
  });
});
function new_opinion(){
	params='bueno='+$('#opinion_bueno').val()+'&malo='+$('#opinion_malo').val()+'&puntuacion='+$('#opinion_puntuacion').val()+'&descripcion='+$('#opinion_descripcion').val();
	$("#new_opinion").load("<%=@juego.urlstring%>/opinion?"+params);
}

function borrar_ele(id){
    $('#'+id).slideToggle();
}
function keyValidate(e){
    var code;
    if(document.all)code=event.keyCode;
    else code=e.keyCode;
    if(code==13){
      $('#btnbuscar').click();
      return false;
    }
    else return true
  }

function OpenClose(id,effect)
{
	switch(effect)
	{
		case 'fade':
		case 'slow':
			id = "#"+id;$(id).css("display") == "none"?$(id).fadeIn("slow"):$(id).fadeOut();
		break;
		
		case 'none':
		case '':
			id = "#"+id;$(id).css("display") == "none"?$(id).show():$(id).hide();
		break;
	}
	
}

function ver_mas(id,types,obj) {
	 if($("#"+id).height() > 186)
	      $("#"+id).height("186px");
	else
	     $("#"+id).height("auto");
	  
	  texto= $(obj).text() == "Ver menos"?'Ver más':'Ver menos';    
	  $(obj).text(texto)
}

function tinyurl() {
	busca = $('#busca').val();
	plataforma_url = genero_url = subparams = "";
	if($('#plataforma') && $('#plataforma').val() != "")
		plataforma_url = "plataforma="+$('#plataforma').val();
	if($('#generos') && $('#generos').val() != "")
		genero_url = "genero="+$('#generos').val();

	if(plataforma_url != "" && genero_url != "")
		subparams = "?"+plataforma_url+"&"+genero_url;
	else if(plataforma_url == "" && genero_url != "")
		subparams = "?"+genero_url;
	else if(plataforma_url != "" && genero_url == "")
		subparams = "?"+plataforma_url;

	window.location="/juegos/" + busca + subparams
	return false;
}

function tinyurl_plataforma(pla){
    window.location='/plataforma/'+pla+'/'+ $('#busca').val();
    return false
}

function tinyurl_grupo() {

	window.location="/grupos/" + $('#busca').val();
	return false;
}

function tinyurl_usuario() {

	window.location="/jugones/" + $('#busca').val();
	return false;
}

function ComprobarBlancos(id){
    
    if ($('#'+id).val() != "")
        return true;
    else
        return false;
}
function change_link(id) {
	$("#"+id).text('Añadiendo...');
}
function reloadpage(request) {
  if (request == 'reload') {
      jQuery(document).trigger('close.facebox')
      window.location.reload();
  }
}


jQuery(document).ready(function($) {
  $('a[rel*=facebox]').facebox()
})

//$(".avatarm").attr('onmouseover','')
