function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind("click", function() {
        carousel.startAuto(0);
    });
    carousel.buttonPrev.bind("click", function() {
        carousel.startAuto(0);
    });
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

function showrecentposts(json) {
    var numposts=10;
    var numchars=260;
    // start a loop
    // in this loop we get the entry from the feed and parse it
    for (var i = 0; i < numposts; i++) {
        // get entry i from feed

        var entry = json.feed.entry[i];
        // get the posttitle
        try {
            var posttitle = entry.title.$t;
        } catch(TypeError) {
            continue;
        }
        // get the post url
        // check all links for the link with rel = alternate
        var posturl;
        if (i == json.feed.entry.length)
            break;
        for (var k = 0; k < entry.link.length; k++) {
            if (entry.link[k].rel == 'alternate') {
                posturl = entry.link[k].href;
                break;
            }
    }
    // get the postdate, take only the first 10 characters
    var postdate = entry.published.$t.substring(0, 10);
    // get the post author
    var postauthor = entry.author[0].name.$t;
    // get the postcontent
    // if the Blogger-feed is set to FULL, then the content is in the content-field
    // if the Blogger-feed is set to SHORT, then the content is in the summary-field
    if ("content" in entry) {
        var postcontent = entry.content.$t;}
    else
        if ("summary" in entry) {
            var postcontent = entry.summary.$t;
        } else
            var postcontent = "";
    // strip off all html-tags
    var re = /<\S[^>]*>/g; 
    postcontent = postcontent.replace(re, "");
    // reduce postcontent to numchar characters
    if (postcontent.length > numchars) postcontent = postcontent.substring(0,numchars) + "...";
    // display the results
    $("#mycarousel").append('<li><span class="btitle"><a href="' + posturl + '">' + posttitle + '</a></span>' +
                            '<span class="bcontent">' + postcontent + '</span>' +
                            '<span class="banchor"><a href="' + posturl + '">Leer más...</a></span></li>');
/*    document.write('Entry #' + i + '<br>');
    document.write('Post title    : '+ posttitle + '<br>');
    document.write('Post url      : '+ posturl + '<br>');
    document.write('Post author   : '+ postauthor + '<br>');
    document.write('Postdate      : '+ postdate + '<br>');
    document.write('Postcontent   : '+ postcontent + '<br>');
    document.write('<br>'); */
    }
}

$(document).ready(function() {
    $(".tweet").tweet({
        join_text: "auto",
        username: "GeomobileSpain",
        avatar_size: null,
        count: 10,
        auto_join_text_default: "",
        auto_join_text_ed: "we",
        auto_join_text_ing: "we were",
        auto_join_text_reply: "we replied",
        auto_join_text_url: "we were checking out",
        loading_text: "loading tweets..."
    });
    /*
    $("#mycarousel").jcarousel({
        auto: 7,
        wrap: "last",
        scroll: 1,
        buttonNextHTML: null,
        buttonPrevHTML: null,
        initCallback: mycarousel_initCallback
    });*/
    $(".eq-media").equalHeights();
    $(".eq-intro").equalHeights();
    $(".eq-who").equalHeights();
    $(".eq-jobs").equalHeights();
    $(".eq-contact").equalHeights();
});


