﻿var diCanPost = true;
var diServer = "http://dis.cuss.it";

function diPost(reply) {
    if (diCanPost) {
        diCanPost = false;
        var nickname = $("#txtdiNickname").attr("value");
        var email = $("#txtdiEmail").attr("value");
        var web = $("#txtdiURL").attr("value");
        var msgbody = $("#txtdiBody").attr("value");
        if (reply) {
            msgbody = $("#txtdiReplyBody").attr("value");
            email = $("#txtdiREmail").attr("value");
            nickname = $("#txtdiRNickname").attr("value");
            web = $("#txtdiRURL").attr("value");           
        }
        if ((msgbody != '') && (msgbody != 'Enter text right here!')) {
            if (nickname != '') {
                if(typeof(pageTracker) != "undefined")
                    pageTracker._trackEvent("Comments", "Post", $("#txtdiNickname").attr("value"));
                var notify = false;
                if (($('#di-ealert').is(':checked')) || ($('#di-eralert').is(':checked')))
                    if (email != '') {
                    notify = true;
                } else {
                    alert('Email required for notifications');
                    diCanPost = true;
                    return false;
                }
                diStatusBox("<h3>Posting message...</h3>");            
                $.ajax({
                    type: 'GET',
                    url: diServer + "/Threads.mvc/PostMsg?callback=?",
                    data: { 'WID': widgetID, 'diTI': $("#diTI").attr("value"), 'diIdent': $("#diIdent").attr("value"), 'txtdiNickname': nickname, 'txtdiEmail': email, 'txtdiURL': web, 'diMug': $("#diMug").attr("value"), 'txtdiBody': msgbody.replace(/\'/g, "&apos;"), 'diRT': $("#diRT").attr("value"), 'diNotify': notify },
                    dataType: 'json',
                    jsonp: 'diPostSuccess',
                    success: diPostSuccess
                });
            } else {
                alert('Name required to post');
                diCanPost = true;
            }
        } else {
            alert('Message has no content');
            diCanPost = true;
        }
    }
}
//var diFacebox;
function diStatusBox(msg) {
    jQuery.facebox(msg);
    $("#facebox").find(".footer").hide();
}

function diPostSuccess(data, textStatus) {
    diInject();
}

function diInject() {
    $.ajax({
        type: 'GET',
        url: diServer + "/Threads.mvc/GetThreadJSON?callback=?",
        data: { 'ThreadID': '', 'Logout': 0, 'WidgetID': widgetID },
        dataType: 'json',
        jsonp: 'cb',
        success: cb
    });
}

function diInjectReply(replyid) {
    if (typeof ($("#direp")) != "undefined")
        $("#direp").remove();
    var dianon = true;
    if (typeof ($("#di-anon")) != "undefined")
        dianon = false;
    $.ajax({
        type: 'GET',
        url: diServer + "/Threads.mvc/ReplyForm?callback=?",
        data: { 'ThreadID': '', 'ReplyID': replyid, 'WidgetID': widgetID, 'Anon': dianon, 'Ident': $("#diIdent").attr("value") },
        dataType: 'json',
        jsonp: 'diReply',
        success: diReply
    });
}

function diReply(data, textStatus) {
    var dimrep = "#dim_" + $("#diRT").attr("value");
    $(dimrep).append($(data[0].widget));
    $("#direp").show("slow");
    $("#direp").find(".diOAuth").text("Replying to: " + $(dimrep).find(".diAuth").text()); //Reply to:
    $("#txtdiRNickname").val($("#txtdiNickname").val());
    $("#txtdiREmail").val($("#txtdiEmail").val());
    $("#txtdiRURL").val($("#txtdiURL").val());
    $('#txtdiReplyBody').focus();
}

function diCancelRep() {
    if (typeof ($("#direp")) != "undefined") {
        $("#direp").remove();
        $("#diRT").val("");
    }
}

function cb(data, textStatus) {
    $("#diThr").html(data[0].widget);
    diCanPost = true;
    if ($("#di_Social").parent().find(".diAuth").text() == $("#txtdiNickname").attr("value")) {
        $("#di_Social").html("<div style='height:16px;padding:2px;font-weight:bold;font-size:12px;padding:2px;border:1px solid gray;background-color:#fff'>" +
        "<span style='margin-right:10px'><script>function tw_click() {u=location.href;t=document.title;window.open('http://twitter.com/home?status=Comment added to '+encodeURIComponent(u) + '&source=Dis.cuss.it','sharer','toolbar=0,status=0,width=726,height=436');return false;}</script><style> html .tw_share_link { margin:4px; padding:0 0 0 20px; height:20px; background:url(" + diServer + "/content/i/twitter_16.png) no-repeat top left; }</style><a href=\"http://twitter.com/home?status=Comment added to " + location.href + "&source=Dis.cuss.it\" onclick=\"return tw_click()\" target=\"_blank\" class=\"tw_share_link\">Tweet this</a></span>" +
        "<span style='margin-right:10px'><script>function ff_click() {u=location.href;t=document.title;window.open('http://friendfeed.com/?link='+encodeURIComponent(u),'sharer','toolbar=0,status=0,width=726,height=436');return false;}</script><style> html .ff_share_link { margin:4px; padding:0 0 0 20px; height:20px; background:url(" + diServer + "/content/i/friendfeed_16.png) no-repeat top left; }</style><a href=\"http://friendfeed.com/?link=" + location.href + "\" onclick=\"return ff_click()\" target=\"_blank\" class=\"ff_share_link\">Post to Friendfeed</a></span>" +
        "<span style='margin-right:10px'><script>function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}</script><style> html .fb_share_link { margin:4px; padding:0 0 0 20px; height:20px; background:url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top left; }</style><a href=\"http://www.facebook.com/share.php?u=" + location.href + "\" onclick=\"return fbs_click()\" target=\"_blank\" class=\"fb_share_link\">Share on Facebook</a></span>" +
        "</div>");
    }
    jQuery(document).trigger('close.facebox');
    if (typeof (diLoaded) != "undefined")
        diLoaded();        
        
    var e=$("#diEmb").val();

    $(".diBody").lnks();
    $(".diLnk").embMedia({
        img: Boolean(Number(e.substr(0,1))),
        vid: Boolean(Number(e.substr(1,1))),
        mus: Boolean(Number(e.substr(2,1))),
        doc: Boolean(Number(e.substr(3,1)))
    });
    
    if (!$("#dilnkback").length)
        $("#diThr").append("<a id=\"dilnkback\" href=\"http://dis.cuss.it\"><img border=\"0\" src=\"http://dis.cuss.it/Content/i/cp.gif\" alt=\"Comments powered by Dis.cuss.It\" /></a>");
}
function diLogout() {
    $.ajax({
        type: 'GET',
        url: diServer + "/Threads.mvc/GetThreadJSON?callback=?",
        data: { 'ThreadID': '', 'Logout': 1, 'WidgetID': widgetID },
        dataType: 'json',
        jsonp: 'cb',
        success: cb
    });
}

function di_usepasswd() {
    $("#di_rpx").hide();
    $("#di_up").show();
    $("#di_BoxUsr").focus();
}

function di_3rdparty() {
    $("#di_up").hide();
    $("#di_rpx").show();
}

function diLogin() {
    $.facebox("<div id='di_rpx' style='height:290px;'>" +
                "<label style=\"text-align:center;display:block;width:360px;margin:10px auto;background:#fff;\">Please authenticate with one of the following services, or sign-in with a <a href='Javascript:di_usepasswd()'>username and password</a>.</label>" +
                "<iframe src=\"https://dis-cuss-it.rpxnow.com/openid/embed?token_url=" + encodeURI(diServer + "/Threads.mvc/userdetails?TID=" + $("#diTI").attr("value")) + "\" scrolling=\"no\" frameBorder=\"no\" style=\"width:360px;height:240px;\"></iframe></div>" +
                "<div id='di_up' style='display:none; height:290px'>" +
                    "<iframe src='"+diServer+"/threads.mvc/login?RetUrl="+window.location+"' scrolling=\"no\" frameBorder=\"no\" style=\"width:360px;height:240px;\"></iframe>" +
                    "<div style='margin:20px 0'><a href='Javascript:di_3rdparty()'>Authenticate with 3rd party</a></div>" + 
                "</div>");
}

function whySignin() {
    jQuery.facebox("<h3>Why Sign-In</h3><ul><li>Instant profile</li><li>Track your replies and responses with ease</li><li>Cross post comments with your social networks</li></ul>");
}

function diReplyTo(replyid) {
    $("#diRT").val(replyid);
    diInjectReply(replyid)
}

function diSetText() {
    if ($('#txtdiBody').attr("value") == '')
        $('#txtdiBody').html('Enter text right here!').css({ color: "rgb(204, 204, 204)" });
    if (typeof ($("#direp")) != "undefined") {
        if ($('#txtdiReplyBody').attr("value") == '')
            $('#txtdiReplyBody').html('Enter text right here!').css({ color: "rgb(204, 204, 204)" });
    }      
}

function diClearText() {
    if ($('#txtdiBody').attr("value") == 'Enter text right here!') {
        $('#txtdiBody').html('');
        $('#txtdiBody').css({ color: "Black" });
    }
    if (typeof ($("#direp")) != "undefined") {
        if ($('#txtdiReplyBody').attr("value") == 'Enter text right here!') {
            $('#txtdiReplyBody').html('');
            $('#txtdiReplyBody').css({ color: "Black" });
        }
    }
}

function showloading() {
    $("#diThr").html("<div id='diLoading'>Loading comments...<br/><img src='" + diServer + "/content/i/processingbar.gif' alt='loading'></div>");
}

$(document).ready(function() {
    showloading();
    diInject();
});

/*
* Facebox (for jQuery)
* version: 1.2 (05/05/2008)
* @requires jQuery v1.2 or later
*
* Examples at http://famspam.com/facebox/
*
* Licensed under the MIT:
*   http://www.opensource.org/licenses/mit-license.php
*
* Copyright 2007, 2008 Chris Wanstrath [ chris@ozmm.org ]
*
* Usage:
*  
*  jQuery(document).ready(function() {
*    jQuery('a[rel*=facebox]').facebox() 
*  })
*
*  <a href="#terms" rel="facebox">Terms</a>
*    Loads the #terms div in the box
*
*  <a href="terms.html" rel="facebox">Terms</a>
*    Loads the terms.html page in the box
*
*  <a href="terms.png" rel="facebox">Terms</a>
*    Loads the terms.png image in the box
*
*
*  You can also use it programmatically:
* 
*    jQuery.facebox('some html')
*
*  The above will open a facebox with "some html" as the content.
*    
*    jQuery.facebox(function($) { 
*      $.get('blah.html', function(data) { $.facebox(data) })
*    })
*
*  The above will show a loading screen before the passed function is called,
*  allowing for a better ajaxy experience.
*
*  The facebox function can also display an ajax page or image:
*  
*    jQuery.facebox({ ajax: 'remote.html' })
*    jQuery.facebox({ image: 'dude.jpg' })
*
*  Want to close the facebox?  Trigger the 'close.facebox' document event:
*
*    jQuery(document).trigger('close.facebox')
*
*  Facebox also has a bunch of other hooks:
*
*    loading.facebox
*    beforeReveal.facebox
*    reveal.facebox (aliased as 'afterReveal.facebox')
*    init.facebox
*
*  Simply bind a function to any of these hooks:
*
*   $(document).bind('reveal.facebox', function() { ...stuff to do after the facebox and contents are revealed... })
*
*/
(function($) {
    $.facebox = function(data, klass) {
        $.facebox.loading()

        if (data.ajax) fillFaceboxFromAjax(data.ajax)
        else if (data.image) fillFaceboxFromImage(data.image)
        else if (data.div) fillFaceboxFromHref(data.div)
        else if ($.isFunction(data)) data.call($)
        else $.facebox.reveal(data, klass)
    }

    /*
    * Public, $.facebox methods
    */

    $.extend($.facebox, {
        settings: {
            opacity: 0,
            overlay: true,
            loadingImage: 'http://dis.cuss.it/Content/facebox/loading.gif',
            closeImage: 'http://dis.cuss.it/Content/facebox/closelabel.gif',
            imageTypes: ['png', 'jpg', 'jpeg', 'gif'],
            faceboxHtml: '\
    <div id="facebox" style="display:none;"> \
      <div class="popup"> \
        <table> \
          <tbody> \
            <tr> \
              <td class="tl"/><td class="b"/><td class="tr"/> \
            </tr> \
            <tr> \
              <td class="b"/> \
              <td class="body"> \
                <div class="content"> \
                </div> \
                <div class="footer"> \
                  <a href="#" class="close"> \
                    <img src="http://dis.cuss.it/Content/facebox/closelabel.gif" title="close" class="close_image" /> \
                  </a> \
                </div> \
              </td> \
              <td class="b"/> \
            </tr> \
            <tr> \
              <td class="bl"/><td class="b"/><td class="br"/> \
            </tr> \
          </tbody> \
        </table> \
      </div> \
    </div>'
        },

        loading: function() {
            init()
            if ($('#facebox .loading').length == 1) return true
            showOverlay()

            $('#facebox .content').empty()
            $('#facebox .body').children().hide().end().
        append('<div class="loading"><img src="' + $.facebox.settings.loadingImage + '"/></div>')

            $('#facebox').css({
                top: getPageScroll()[1] + (getPageHeight() / 10),
                left: 385.5
            }).show()

            $(document).bind('keydown.facebox', function(e) {
                if (e.keyCode == 27) $.facebox.close()
                return true
            })
            $(document).trigger('loading.facebox')
        },

        reveal: function(data, klass) {
            $(document).trigger('beforeReveal.facebox')
            if (klass) $('#facebox .content').addClass(klass)
            $('#facebox .content').append(data)
            $('#facebox .loading').remove()
            $('#facebox .body').children().fadeIn('normal')
            $('#facebox').css('left', $(window).width() / 2 - ($('#facebox table').width() / 2))
            $(document).trigger('reveal.facebox').trigger('afterReveal.facebox')
        },

        close: function() {
            $(document).trigger('close.facebox')
            return false
        }
    })

    /*
    * Public, $.fn methods
    */

    $.fn.facebox = function(settings) {
        init(settings)

        function clickHandler() {
            $.facebox.loading(true)

            // support for rel="facebox.inline_popup" syntax, to add a class
            // also supports deprecated "facebox[.inline_popup]" syntax
            var klass = this.rel.match(/facebox\[?\.(\w+)\]?/)
            if (klass) klass = klass[1]

            fillFaceboxFromHref(this.href, klass)
            return false
        }

        return this.click(clickHandler)
    }

    /*
    * Private methods
    */

    // called one time to setup facebox on this page
    function init(settings) {
        if ($.facebox.settings.inited) return true
        else $.facebox.settings.inited = true

        $(document).trigger('init.facebox')
        makeCompatible()

        var imageTypes = $.facebox.settings.imageTypes.join('|')
        $.facebox.settings.imageTypesRegexp = new RegExp('\.' + imageTypes + '$', 'i')

        if (settings) $.extend($.facebox.settings, settings)
        $('body').append($.facebox.settings.faceboxHtml)

        var preload = [new Image(), new Image()]
        preload[0].src = $.facebox.settings.closeImage
        preload[1].src = $.facebox.settings.loadingImage

        $('#facebox').find('.b:first, .bl, .br, .tl, .tr').each(function() {
            preload.push(new Image())
            preload.slice(-1).src = $(this).css('background-image').replace(/url\((.+)\)/, '$1')
        })

        $('#facebox .close').click($.facebox.close)
        $('#facebox .close_image').attr('src', $.facebox.settings.closeImage)
    }

    // getPageScroll() by quirksmode.com
    function getPageScroll() {
        var xScroll, yScroll;
        if (self.pageYOffset) {
            yScroll = self.pageYOffset;
            xScroll = self.pageXOffset;
        } else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
            yScroll = document.documentElement.scrollTop;
            xScroll = document.documentElement.scrollLeft;
        } else if (document.body) {// all other Explorers
            yScroll = document.body.scrollTop;
            xScroll = document.body.scrollLeft;
        }
        return new Array(xScroll, yScroll)
    }

    // Adapted from getPageSize() by quirksmode.com
    function getPageHeight() {
        var windowHeight
        if (self.innerHeight) {	// all except Explorer
            windowHeight = self.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
            windowHeight = document.documentElement.clientHeight;
        } else if (document.body) { // other Explorers
            windowHeight = document.body.clientHeight;
        }
        return windowHeight
    }

    // Backwards compatibility
    function makeCompatible() {
        var $s = $.facebox.settings

        $s.loadingImage = $s.loading_image || $s.loadingImage
        $s.closeImage = $s.close_image || $s.closeImage
        $s.imageTypes = $s.image_types || $s.imageTypes
        $s.faceboxHtml = $s.facebox_html || $s.faceboxHtml
    }

    // Figures out what you want to display and displays it
    // formats are:
    //     div: #id
    //   image: blah.extension
    //    ajax: anything else
    function fillFaceboxFromHref(href, klass) {
        // div
        if (href.match(/#/)) {
            var url = window.location.href.split('#')[0]
            var target = href.replace(url, '')
            $.facebox.reveal($(target).clone().show(), klass)

            // image
        } else if (href.match($.facebox.settings.imageTypesRegexp)) {
            fillFaceboxFromImage(href, klass)
            // ajax
        } else {
            fillFaceboxFromAjax(href, klass)
        }
    }

    function fillFaceboxFromImage(href, klass) {
        var image = new Image()
        image.onload = function() {
            $.facebox.reveal('<div class="image"><img src="' + image.src + '" /></div>', klass)
        }
        image.src = href
    }

    function fillFaceboxFromAjax(href, klass) {
        $.get(href, function(data) { $.facebox.reveal(data, klass) })
    }

    function skipOverlay() {
        return $.facebox.settings.overlay == false || $.facebox.settings.opacity === null
    }

    function showOverlay() {
        if (skipOverlay()) return

        if ($('facebox_overlay').length == 0)
            $("body").append('<div id="facebox_overlay" class="facebox_hide"></div>')

        $('#facebox_overlay').hide().addClass("facebox_overlayBG")
      .css('opacity', $.facebox.settings.opacity)
      .click(function() { $(document).trigger('close.facebox') })
      .fadeIn(200)
        return false
    }

    function hideOverlay() {
        if (skipOverlay()) return

        $('#facebox_overlay').fadeOut(200, function() {
            $("#facebox_overlay").removeClass("facebox_overlayBG")
            $("#facebox_overlay").addClass("facebox_hide")
            $("#facebox_overlay").remove()
        })

        return false
    }

    /*
    * Bindings
    */

    $(document).bind('close.facebox', function() {
        $(document).unbind('keydown.facebox')
        $('#facebox').fadeOut(function() {
            $('#facebox .content').removeClass().addClass('content')
            hideOverlay()
            $('#facebox .loading').remove()
        })
    })

})(jQuery);

// jquery plugin to turn url's into links
(function($) {  
    $.fn.lnks = function() {  
        var r = /((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi;
        this.each(function() {  
            $(this).html(  
                $(this).html().replace(r,'<a class=\"diLnk\" target=\"_blank\" href=\"$1\">$1</a>')
            );
        });  
        return $(this);  
    }
})(jQuery);

jQuery(document).ready(function($) {
    $('a[rel*=facebox]').facebox()
});

/*jquery.embedmedia*/
(function($) {  
    $.fn.embMedia = function(o) {  
        var opt = {  
            img: true,
            vid: true,
            mus: true,
            doc: true
        };  
        var options = $.extend(opt, o);
        this.each(function() {
            var h=$(this).attr("href");
            switch(lnkType(h))
            {
                case "image":
                    if(opt.img){
                        $.ajax({
                            type: 'GET',
                            url: diServer +"/embed.mvc/thumb",
                            data: {'url': h, 'widgetID': widgetID},
                            dataType: 'json',
                            jsonp: 'diThumb'
                        });
                    }
                    break;
                case "youtube":
                    if(opt.vid)
                        $(this).replaceWith("<embed src='http://www.youtube.com/v/"+h.substr(h.indexOf("?v=")+3,h.length)+"&rel=1' type='application/x-shockwave-flash' wmode='transparent' width='425' height='355'></embed>");
                    break;
                case "metacafe":
                    if(opt.vid)
                        $(this).replaceWith("<embed src=\"http://www.metacafe.com/fplayer/"+h.substr(30, h.length)+".swf\" width=\"425\" height=\"355\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\"></embed>");
                    break;
                case "seesmic":
                    if(opt.vid){
                        var l;
                        if (h.indexOf("http://seesmic.com/")!=-1)
                            l=h.substr(26, h.length);
                        else
                            l=h.substr(29, h.length);
                        $(this).replaceWith("<object width='425' height='355'><param name='movie' value='http://seesmic.com/embeds/wrapper.swf'/><param name='bgcolor' value='#666666'/><param name='allowFullScreen' value='true'/><param name='allowScriptAccess' value='always'/><param name='flashVars' value='video="+l+"&amp;version=threadedplayer'/><embed src='http://seesmic.com/embeds/wrapper.swf' type='application/x-shockwave-flash' flashVars='video="+l+"&amp;version=threadedplayer' allowFullScreen='true' bgcolor='#666666' allowScriptAccess='always' width='425' height='355'></embed></object>");
                    }
                    break;
                case "vimeo":
                    if(opt.vid){
                        var l;
                        if(h.indexOf("http://vimeo.com/")!=-1)
                            l=h.substr(17, h.length);
                        else
                            l=h.substr(21, h.length);
                        $(this).replaceWith("<object width='425' height='355'><param name='allowfullscreen' value='true' /><param name='allowscriptaccess' value='always' /><param name='movie' value='http://vimeo.com/moogaloop.swf?clip_id="+l+"&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1' /><embed src='http://vimeo.com/moogaloop.swf?clip_id="+l+"&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1' type='application/x-shockwave-flash' allowfullscreen='true' allowscriptaccess='always' width='425' height='355'></embed></object>");
                    }
                    break;
                case "audioboo":
                    if(opt.mus)
                        $(this).replaceWith("<object data=\"http://boos.audioboo.fm/player_mp3.swf\" height=\"104\" type=\"application/x-shockwave-flash\" width=\"390\"><param name=\"movie\" value=\"http://boos.audioboo.fm/player_mp3.swf\" /><param name=\"FlashVars\" value=\"mp3="+h+".mp3\" /><param name=\"wmode\" value=\"transparent\" /><a href=\""+h+".mp3\">Listen!</a></object>");
                    break;
                case "mp3":
                    if(opt.mus)
                        $(this).replaceWith("<object type=\"application/x-shockwave-flash\" data=\""+diServer+"/Content/MP3player.swf\" height=\"24\" width=\"290\"><param name=\"movie\" value=\""+diServer + "/Content/MP3player.swf\"><param name=\"FlashVars\" value=\"soundFile="+h+"\"><param name=\"quality\" value=\"high\"><param name='menu' value='false'><param name=\"wmode\" value=\"transparent\"></object>");
                    break;
                case "ebay":
                    if(opt.doc){
                        var t=ETLD(h);
                        var i=EID(h);
                        if (t == ".co.uk" || t == ".com" || t == ".de")
                            $(this).replaceWith("<object height=\"300\" width=\"355\"><embed src=\"http://togo.ebay" + t + "/togo/togo.swf\" type=\"application/x-shockwave-flash\" flashvars=\"base=http://togo.ebay" + t + "/togo/&amp;lang=en-gb&amp;mode=normal&amp;itemid=" + i + "&amp;query=" + "ploping" + "\" height=\"300\" width=\"355\"></object>");       
                    }
                    break;
            }
        });  
        return $(this);  
    } 
})(jQuery);

function lnkType(s){   
    var p=new Array();
    p[0] = ".jpg"
    p[1] = ".gif"
    p[2] = ".png"
    p[3] = ".jpeg"
    for (i=0;i<p.length;i++){
        if (s.length-p[i].length==s.indexOf(p[i]))
            return "image";
    }
    if (s.indexOf("youtube.com/watch?v=")!=-1)
        return "youtube";
    if (s.indexOf("http://www.metacafe.com/watch/")!=-1)
        return "metacafe";
    if (s.indexOf("http://www.vimeo.com/")!=-1 || s.indexOf("http://vimeo.com/")!=-1)
        return "vimeo";        
    if (s.length - 4 == s.indexOf(".mp3"))
        return "mp3";
    if (s.indexOf("http://audioboo.fm/boos/")!=-1)
        return "audioboo";
    if (s.indexOf("http://cgi.ebay.")!=-1)
        return "ebay";
    if (s.indexOf("http://seesmic.com/videos/")!=-1 || s.indexOf("http://www.seesmic.com/video/")!=-1)
        return "seesmic";
}
function diThumb(r){
    $(".diLnk:contains('"+r.url+"')").html(unescape(r.html));
}
function ETLD(l){
    var s = l.toString().indexOf("cgi.ebay.",0) + 8;
    var e = l.toString().indexOf("/",s);
    return l.toString().substring(s, e);
}
function EID(l){
    var s = l.toString().toLowerCase().indexOf("w0qqitemz",0) + 9;
    if (s == 8) { s = l.toString().toLowerCase().indexOf("&item=",0) + 6 };
    return l.toString().substring(s, s + 12); 
}

/*jquery.embedmedia end*/

/*seesmic*/

function seesmicShow(e){
    $(e).replaceWith("<embed id='sobject' height='270' width='300' flashvars='version=wprecorder&title=undefined&recState=comment&inreplyto=&blog_id=http://dis.cuss.it&allowAnonymous=0&blog_name=dis.cuss.it' allowscriptaccess='always' quality='high' bgcolor='#000000' name='sobject' style='' src='http://seesmic.com/embeds/wrapper.swf' type='application/x-shockwave-flash' />");
}

function videoFromRecorder(videoUri, title, url_thumbnail, recState, hasTitle){
    if($('cb_error').checked){
        seesmic.player.setError('Please fill the name and email in the html page!')
        return
    }    
    diStatusBox("<h3>Posting message...</h3>");
    $.ajax({
        type: 'GET',
        url: diServer + "/Threads.mvc/PostMsg?callback=?",
        data: { 'WID': widgetID, 'diTI': $("#diTI").attr("value"), 'diIdent': $("#diIdent").attr("value"), 'txtdiNickname': $("#txtdiNickname").attr("value"), 'txtdiEmail': $("#txtdiEmail").attr("value"), 'txtdiURL': $("#txtdiURL").attr("value"), 'diMug': $("#diMug").attr("value"), 'txtdiBody': videoUri, 'diRT': $("#diRT").attr("value"), 'diNotify': false },
        dataType: 'json',
        jsonp: 'diPostSuccess',
        success: diPostSuccess
    });
    return;
}

/*seesmic end*/