$(document).ready( function() 
{  
    $("img.chim").click(function() 
    {
        tourid = this.alt
        var inputs = [];
        inputs.push('id' + '=' + tourid);
        inputs.push('idd' + '=' + 'tour');
        $.ajax( 
        {
            data :inputs.join('&'),
            dataType: 'JSON',
            type: 'POST',
            url :'nn/includes/aj_tr_to.php',       
            timeout :20000, 
            error : function() {
                console.log("Failed to retrieve data.")
            },
            success : function(r) 
            {                
                var obj = JSON.parse(r, function(key, value)
                {
                    var d;
                    d = value; 
                    if (d == null)
                        d = "";
                    switch (key)
                    {
                        case 'id':
                        case 'thumbnail':                 
                        case 'image':                          
                        case 'title':                                 
                        case 'text': 
                    }    
                    return d;        
                });              
/*
                var OBJ = obj.tour[0];
                $("#theimage").attr("src",OBJ['image']);
                $("#thetitle").html(OBJ['title']);
                $("#thetext").html(OBJ['text']);
*/               
                var OBJ = obj.tour;
                $("#theimage").attr("src",OBJ[2]);
                $("#thetitle").html(OBJ[3]);
                $("#thetext").html(OBJ[4]);
                
            }
         })            
    })    
 
});

