$(function(){ $.ajax({ url: '/includes/sociala_media/ajax/facebook.asp', cache: false, dataType: "html", async: true, success: function(data) { $("#facebook .content").html(data); }, error: function() { $("#facebook .content .information").html("Begäran gjorde timeout"); } }); $.ajax({ url: '/includes/sociala_media/ajax/flickr.asp', cache: false, dataType: "html", async: true, success: function(data) { $("#flickr .content").html(data); makeFlickrLinks(); }, error: function() { $("#flickr .content .information").html("Begäran gjorde timeout"); } }); $.ajax({ url: '/includes/sociala_media/ajax/youtube.asp', cache: false, dataType: "html", async: true, success: function(data) { $("#youtube .content").html(data); makeYoutubeLinks(); }, error: function() { $("#youtube .content .information").html("Begäran gjorde timeout"); } }); $.ajax({ url: '/includes/sociala_media/ajax/bloggar.asp', cache: false, dataType: "html", async: true, success: function(data) { $("#bloggar .content").html(data); }, error: function() { $("#bloggar .content .information").html("Begäran gjorde timeout"); } }); makeYoutubeLinks(); makeFlickrLinks(); makeSMNavigation(); }); function makeYoutubeLinks() { $(".lightbox_youtube").colorbox({ inline: false, iframe:true, fixedWidth:"640px", fixedHeight:"480px" }); } function makeFlickrLinks() { $('.flickrlink').each(function(i){ $(this).colorbox({ inline: true, href: ".userdata:eq(" + i + ")", initialWidth: "320", initialHeight: "280", opacity: 0.9, speed: 400, transition: "elastic", rel: "flickr", current: "{current} av {total}", next: "Nästa", previous: "Förra", close: "Stäng" }); }); } function makeSMNavigation() { $(".btn_prev").click(function() { var target = "#" + $(this).parent().parent().attr("id"); $(target + " .content .data:first").hide(); var movePost = $(target + " .content .data:last"); $(target + " .content .data:last").remove(); $(movePost).prependTo($(target + " .content")); $(target + " .content .data:first").show(); makeFlickrLinks(); makeYoutubeLinks(); return false; }); $(".btn_next").click(function() { var target = "#" + $(this).parent().parent().attr("id"); var movePost = $(target + " .content .data:first"); $(target + " .content .data:first").remove(); $(movePost).appendTo($(target + " .content")); $(target + " .content .data:last").hide(); $(target + " .content .data:first").show(); makeFlickrLinks(); makeYoutubeLinks(); return false; }); }