$(document).ready(function() {   
       
    //Menu
    $("#acordeon-productos").css("display", "");
    
    var index = $.cookie("accordion");
    var active;
    if (index !== undefined) {
            active = $("#accordion").find("h3:eq(" + index + ")");
    } 
    
    if(document.getElementById("accordion")) 
    {    
    /*        
        $("#accordion").accordion({ 
            //animated: false,
            header: "h3",     
            autoHeight: false,  
            collapsible: false,
            active: active, 
            //event: "mouseover",
            change: function(event, ui) {
                var index = $(this).find("h3").index ( ui.newHeader[0] );
                $.cookie("accordion", index);
            }  
        });   */           
    }  
    
     $(".arbol-categorias").treeview({
        collapsed: true,
        persist: "cookie",
        cookieId: "navigationtree"
    }); 
       
});


function CambiarClase(clase)
{
    $('body').attr('className', clase);              
}

function VentanaSoporte()
{
    window.open('Soporte.php?noheaders=ok', 'ventanasoporte', ' width=640, height=480, resizable=yes, scrollbars=yes, menubar=no, toolbar=no, directories=no, location=no, status=yes')
}

function RegistrarUsuario()
{
    var nombre = $("#nombreusuario").val()
    var correo = $("#emailusuario").val()
    
    $("#mensaje-registro").html("Enviando...")
    
    if(nombre.length <= 0)
    {
        alert("Debe escribir un nombre")
        return false;
    }
    
    if(correo.length <= 0)
    {
        alert("Debe escribir un correo electrónico")
        return false;
    }
   
    
    $.ajax({
        type: "POST",
        url: "Contacto.php",
        data: "op=RegistroAjax&noheaders=all&nombre="+nombre+"&correo="+correo,
        success: function(datos){
           $("#nombreusuario").val("")
           $("#emailusuario").val("")
           alert( "Se enviaron los datos con éxito, gracias!");                   
           $("#mensaje-registro").html("Se han registrado tus datos")
        }
    });
    
    return false;
}

function RegistrarUsuarioChat()
{
    var nombre = $("#nombreusuario").val()
    var correo = $("#emailusuario").val()
    
    $("#mensaje-registro").html("Enviando...")
    
    if(nombre.length <= 0)
    {
        alert("Debe escribir un nombre")
        return false;
    }
    
    if(correo.length <= 0)
    {
        alert("Debe escribir un correo electrónico")
        return false;
    }
   
    
    $.ajax({
        type: "POST",
        url: "Contacto.php",
        data: "op=RegistroAjax&noheaders=all&nombre="+nombre+"&correo="+correo,
        success: function(datos){
           $("#nombreusuario").val("")
           $("#emailusuario").val("")
           $("#form-soporte").submit()                   
           $("#mensaje-registro").html("Se han registrado tus datos")
        }
    });
    
    return true;
}

function Ventanachat(idregistro)
	{
	var myLeft = (screen.width-600)/2;
	var myTop = (screen.height-500)/2;
	window.open("Soporte.php?idregistro="+idregistro,"ventanachat", ' resizable=yes, scrollbars=yes, menubar=yes, toolbar=no, directories=no, location=no, status=no, left='+myLeft+', top='+myTop+' , width=600, height=500');
	return;			
	}


