jQuery.noConflict();

jQuery(document).ready(function() {
    jQuery.postJSON = function(url, data, callback) {
        jQuery.post(url, data, callback, "json");
    };

    var $jtemplates = jQuery.createTemplateURL("/js/jquery/templates/nicovideo_info.txt", null, {});
    var api_url;
    if (location.href.match("clip\.dev\.livedoor\.com")) {
        api_url = "http://clip.dev.livedoor.com/internal_api/nicovideo_info";
    }
    else {
        api_url = "http://clip.livedoor.com/internal_api/nicovideo_info";
    }
    var data = {
        url : location.href.replace(/http:\/\/clip\.(dev\.)?livedoor\.com\/page\//, "") || "http://www.livedoor.com/"
    };
    var callback = function (json) {
        jQuery('#nicovideo_info').html($jtemplates.get(json, null, window));        
    };

    jQuery.postJSON(api_url, data, callback);
//    jQuery('#nicovideo_info_button').click(function() {
//        jQuery('#nicovideo_info').slideToggle('slow', function() {
//            jQuery.postJSON(api_url, data, callback);
//        });
//    });
});
