/* -------------------------------------------- 
* Tweetmix Widget Script
*
* Created by @Ventus80
*
* copyright (c) userstorylab 
-----------------------------------------------*/

var twm_conflict = false;
var twm = "";

var twm_url = "http://tweetmix.net";
//var twm_url = "http://192.168.1.211";

document.getElementsByClassName = function(cl) {
    var retnode = [];
    var myclass = new RegExp('\\b'+cl+'\\b');
    var elem = this.getElementsByTagName('*');

    var len = elem.length;
    
    for (var i = 0; i < len; i++) {
        var classes = elem[i].className;
        if (myclass.test(classes)) retnode.push(elem[i]);
    }

    return retnode;
};

function escap(str){
    var return_value = encodeURIComponent(str);
    return_value = return_value.replace(/\'/g, '\\\'');
    return_value = return_value.replace(/\"/g, '\\\"');

    return return_value;
}

function checkTweetmixWidgetHeight(){

    var tmxwgLists = document.getElementsByClassName('tmx_list');
    var tmxwg_bds = document.getElementsByClassName('tmxwg_bd');
    var tweetmix_widget_wraps = document.getElementsByClassName('tweetmix_widget_wrap');

    var len = tmxwg_bds.length;

    for (var i = 0; i < len; i++) {
        var tmxwg_bd_h = tmxwg_bds[i].offsetHeight;
        var tmxwg_list_h = tmxwgLists[i].offsetHeight;
        
        if(tmxwg_list_h < tmxwg_bd_h ){
            tmxwg_bds[i].style.height = '100%';
            tweetmix_widget_wraps[i].style.height = '100%';
            
        }
    }
    
}

function dummyEmpty(){
    var dummy = document.getElementsByClassName('dummy');

    var len = dummy.length;
    for (var i = 0; i < len; i++) {
        dummy[i].innerHTML = "";
    }
}

function JSONtoString(object) {
    var results = [];
    for (var property in object) {
        if(property =='target_url' || property =='widget_title' || property =='default_msg'){
            var value = encodeURIComponent(object[property]);
        }else{
            var value = object[property];
        }
        if (value){
            results.push(property.toString() + '=' + value);
        }

    }

    return '?'+results.join('&');
}

function widget_retweet(screen_name, contents){
    var url = twm_url+"/widget/auth/retweet/";

    //url = url + "?msg=" + encodeURIComponent(("RT @"+screen_name+" "+ contents));
    url = url + "?msg=" + "RT @"+screen_name+" "+ contents;
    url = url + "&status_id=0";
    
    var status = "width=660,";
    status = status + "height=400,";
    status = status + "location=no,";
    status = status + "directories=no,";
    status = status + "menubar=no,";
    status = status + "status=no,";
    status = status + "toolbar=no, scrollbars=no, menubar=no,";
    status = status + "resizable=no";

     window.open(url, "tweetmix_retweet", status);
     //alert(contents);
}

function widget_tweets(contents){
    var url = twm_url+"/widget/auth/retweet/";

    //url = url + "?msg=" + encodeURIComponent(contents);
    url = url + "?msg=" + contents;
    url = url + "&status_id=0";

    var status = "width=660,";
    status = status + "height=400,";
    status = status + "location=no,";
    status = status + "directories=no,";
    status = status + "menubar=no,";
    status = status + "status=no,";
    status = status + "toolbar=no, scrollbars=no, menubar=no,";
    status = status + "resizable=no";

     window.open(url, "tweetmix_tweets", status);
     //alert(contents);
}

function widget_reply(screen_name, tid_status){
    var url = twm_url+"/widget/auth/reply/";
    
    url = url + "?msg=" + "@"+screen_name+" ";
    url = url + "&status_id="+tid_status;
    
    var status = "width=660,";
    status = status + "height=400,";
    status = status + "location=no,";
    status = status + "directories=no,";
    status = status + "menubar=no,";
    status = status + "status=no,";
    status = status + "toolbar=no, scrollbars=no, menubar=no,";
    status = status + "resizable=no";
    
    window.open(url, "tweetmix_reply", status);
    //alert("@"+screen_name +" / "+ tid_status)
}

var Widget_render = function(json_widget, add_obj_id){

    var url = twm_url;
        
    var str_json_widget = JSONtoString(json_widget);

    var widget_no = Math.floor(Math.random() * 10000000000) + 1;
        
    document.write('<div id="tweetmix_widget_'+widget_no+'"></div>');
    var script_div=document.getElementById('tweetmix_widget_'+widget_no);
    var parentNodeEl=script_div.parentNode;
        
    var scriptElement = document.createElement('script');
        
    scriptElement.type = 'text/javascript';
    
    if(typeof add_obj_id=='undefined'){
        scriptElement.src = url+'/widget/script/'+widget_no+'/'+str_json_widget;

    }else{
        scriptElement.src = url+'/widget/script/'+widget_no+'/'+add_obj_id+'/'+str_json_widget;
        
    }
    
    parentNodeEl.insertBefore(scriptElement, script_div);

};

var Widget = function(json_data, number){
    
    this.version = "0.1.6.0";
    this.tw_url = twm_url;
    this.tt_url = "http://twitter.com";
    this.widget_no = number;
    this.id                     = json_data.id;
    this.widget_type            = json_data.widget_type;
    
    var egloos_filter = /egloos/i;
    var normalize = /^[0-9]/gi;
    
    //not egloos
    if(egloos_filter.test(json_data.target_url) == false){
        this.target_url             = json_data.target_url;
        
    }else{
        //egloos
        var str_url = location.href;
        var array_url = str_url.split('/');
        
        if(normalize.test(array_url[3]) == true){
            this.target_url = str_url;
            this.widget_type = 1;
            
        }else{
            var unit_url = array_url[0]+'/'+array_url[1]+'/'+array_url[2];
            this.target_url = unit_url;
            this.widget_type = 0;
        }
    
    }
    
    this.width                  = json_data.width;
    this.height                 = json_data.height;
    this.color_upper_back       = json_data.color_upper_back;
    this.color_upper_text       = json_data.color_upper_text;
    this.color_tweet_back       = json_data.color_tweet_back;
    this.color_text             = json_data.color_text;
    this.color_link             = json_data.color_link;
    this.max_messages           = json_data.max_messages;
    this.is_show_avatar         = json_data.is_show_avatar;
    this.is_show_original_url   = json_data.is_show_original_url;
    this.is_refresh_always      = json_data.is_refresh_always;
    //this.is_show_ads            = json_data.is_show_ads;
    this.is_show_ads            = 1;
    this.color_border           = json_data.color_border;
    this.widget_title           = json_data.widget_title;
    this.refresh_count          = 0;
    
    if(typeof json_data.btn_type != "undefined"){
        this.btn_type               = json_data.btn_type;

    }else{        
        this.btn_type               = 0;

    }

    if(this.btn_type == 1){
        this.btn_type_class = "tmx_btn_both";
        
    }else{
        this.btn_type_class = "tmx_btn_icon";
        
    }
    
    if(typeof json_data.default_msg == "undefined" 
        || json_data.default_msg == ""
        || json_data.default_msg ==  null)
    {
        this.default_msg            = document.title;

    }else{
        this.default_msg            = document.title +" "+json_data.default_msg;
        
    }

    this.url_extend = "/widget/show/"+this.widget_no+"/";
    this.css_url = "/tmxWidget/style/tmixwdg.css";

    this.url = this.tw_url+this.url_extend;
    
    this.str_add_obj_id = "";
    this.tmp_div = "";
    
    this.last_id = "";
    this.last_date = "";
    this.jsonWidget = "";
    this.jsonRefreshWidget = "";
    this.widget_div = "";
    this.parentNodeEl = ""
    this.scriptElement = "";
    
    this.tweetmix_widget_div_wrap="";
    this.tweetmix_widget_div = "";
    this.tmxwg_box = "";
    this.tmxwg_hd = "";
    this.tmxwg_bd = "";
    this.tmxwg_ft = "";
};

Widget.prototype.widgetRefresh = function(_i) {
    var d=_i;
    _i.widget_refresh = setInterval(function(){
        d.getRefreshData(d);
    } ,10000);
};

Widget.prototype.getRefreshData = function(_i){

    if(typeof _i.last_id !='undefined' || _i.last_id !=""){

        var url = twm_url;
        url =  url +'/widget/refresh/' + _i.widget_no;
        url =  url + '?target_url=' + _i.target_url;
        url =  url + '&widget_type=' + _i.widget_type;
        url =  url + '&last_id=' + _i.last_id;
        url =  url + '&last_date=' + _i.last_date;
        
        _i.getJsonScriptRefreshData(url,_i.pushRefreshData, _i);
        
    }
};

Widget.prototype.pushRefreshData= function(_i){
    var tweets = _i.jsonRefreshWidget;
    //var tweets =[{"0":"3446225","id":"3446225","1":"2010-08-13 15:26:49","date_tweeted":"about 2 hour 5 minutes ago","2":"RT @yanolja_twt : [\uad11\ubcf5\uc808 \uc774\ubca4\ud2b8(~8\/15)] \uc57c\ub180\uc790\ub97c \ud314\ub85c\uc6b0~ \ud558\uc2dc\uace0, \ud558\ub298\uc744 \ud5a5\ud574 \uc21c\uad6d \uc120\uc5f4\ub4e4\uaed8 \uac10\uc0ac\ud558\ub2e4\uace0 \uc678\uccd0\uc8fc\uc138\uc694~ \ud55c \ubd84\uaed8 \ud5ec\ub85c\ud0a4\ud2f0 \uce58\uce74\uce58\uce74\uc138\ud2b8\ub97c~ 3\ubd84\uaed8 \uc57c\ub180\uc790 \ud48d\uc120 500\uac1c\ub97c \ub4dc\ub9bd\ub2c8\ub2e4^^ http:\/\/twitpic.com","contents":"RT @<a href='http:\/\/twitter.com\/yanolja_twt' target='_blank'>yanolja_twt<\/a> : [\uad11\ubcf5\uc808 \uc774\ubca4\ud2b8(~8\/15)] \uc57c\ub180\uc790\ub97c \ud314\ub85c\uc6b0~ \ud558\uc2dc\uace0, \ud558\ub298\uc744 \ud5a5\ud574 \uc21c\uad6d \uc120\uc5f4\ub4e4\uaed8 \uac10\uc0ac\ud558\ub2e4\uace0 \uc678\uccd0\uc8fc\uc138\uc694~ \ud55c \ubd84\uaed8 \ud5ec\ub85c\ud0a4\ud2f0 \uce58\uce74\uce58\uce74\uc138\ud2b8\ub97c~ 3\ubd84\uaed8 \uc57c\ub180\uc790 \ud48d\uc120 500\uac1c\ub97c \ub4dc\ub9bd\ub2c8\ub2e4^^ <a href='http:\/\/twitpic.com' target='_blank'>http:\/\/twitpic.com<\/a>","3":"<a href='http:\/\/www.samsungmobile.com' rel='nofollow'>Samsung Mobile<\/a>","source":"<a href='http:\/\/www.samsungmobile.com' rel='nofollow'>Samsung Mobile<\/a>","4":"21042136484","tid_status":"21042136484","5":"133694700","tid_user":"133694700","6":"tjdud82","screen_name":"tjdud82","7":"http:\/\/a1.twimg.com\/profile_images\/1063491449\/SNC00624_normal.jpg","photo_url":"http:\/\/a1.twimg.com\/profile_images\/1063491449\/SNC00624_normal.jpg","8":"133694700","tid_userid":"133694700","original_contents":"RT @yanolja_twt : [\uad11\ubcf5\uc808 \uc774\ubca4\ud2b8(~8\/15)] \uc57c\ub180\uc790\ub97c \ud314\ub85c\uc6b0~ \ud558\uc2dc\uace0, \ud558\ub298\uc744 \ud5a5\ud574 \uc21c\uad6d \uc120\uc5f4\ub4e4\uaed8 \uac10\uc0ac\ud558\ub2e4\uace0 \uc678\uccd0\uc8fc\uc138\uc694~ \ud55c \ubd84\uaed8 \ud5ec\ub85c\ud0a4\ud2f0 \uce58\uce74\uce58\uce74\uc138\ud2b8\ub97c~ 3\ubd84\uaed8 \uc57c\ub180\uc790 \ud48d\uc120 500\uac1c\ub97c \ub4dc\ub9bd\ub2c8\ub2e4^^ http:\/\/twitpic.com","original_date":"2010-08-13 15:26:49"},{"0":"3415698","id":"3415698","1":"2010-08-13 13:09:25","date_tweeted":"about 4 hour 22 minutes ago","2":"\ud558\ub098\ub3c4\uc548\ub0a8\uae30\uace0 \ub2e4\uba39\uc5c8\ub2e4 \uc2f8\uadf8\ub9ac...\uc744\ubc00\ub300\uc5d0\uc11c...http:\/\/twitpic.com\/******","contents":"\ud558\ub098\ub3c4\uc548\ub0a8\uae30\uace0 \ub2e4\uba39\uc5c8\ub2e4 \uc2f8\uadf8\ub9ac...\uc744\ubc00\ub300\uc5d0\uc11c...<a href='http:\/\/twitpic.com\/' target='_blank'>http:\/\/twitpic.com\/<\/a>******","3":"<a href='http:\/\/seesmic.com\/seesmic_mobile\/android\/' rel='nofollow'>Seesmic for Android<\/a>","source":"<a href='http:\/\/seesmic.com\/seesmic_mobile\/android\/' rel='nofollow'>Seesmic for Android<\/a>","4":"21034237978","tid_status":"21034237978","5":"162690094","tid_user":"162690094","6":"seephoto108","screen_name":"seephoto108","7":"http:\/\/a3.twimg.com\/profile_images\/1049689927\/goldgon_normal.jpg","photo_url":"http:\/\/a3.twimg.com\/profile_images\/1049689927\/goldgon_normal.jpg","8":"162690094","tid_userid":"162690094","original_contents":"\ud558\ub098\ub3c4\uc548\ub0a8\uae30\uace0 \ub2e4\uba39\uc5c8\ub2e4 \uc2f8\uadf8\ub9ac...\uc744\ubc00\ub300\uc5d0\uc11c...http:\/\/twitpic.com\/******","original_date":"2010-08-13 13:09:25"},{"0":"3383529","id":"3383529","1":"2010-08-13 09:50:16","date_tweeted":"about 7 hour 41 minutes ago","2":"RT @WitchWendy2: RT @SoGentle : \ubbf8\ucce4\ub124\uc694. \ud55c\ub450\ubc88\ub3c4 \uc544\ub2c8\uace0 RT @energygirlz: \ub18d\uc2ec \uc300\uc0c8\uc6b0\uae61\uc5d0\uc11c \ubc8c\ub808\ubb34\ub354\uae30\uac00 \ub098\uc654\ub294\ub370 \ub18d\uc2ec\uc740 \ubc30\uc9f8;;\uc778\ud130\ub137\uc5d0 \uc62c\ub9ac\ub4e0 \uace0\ubc1c\uc744 \ud558\ub4e0 \ub9d8\ub300\ub85c \ud558\ub77c\ub294\ub370..\ub18d\uc2ec \uc9c4\uc2ec \ubbf8\uce5c\uac70\uc784? \ubb34\ud55c\uc54c\ud2f0 http:\/\/twitpic.com\/","contents":"RT @<a href='http:\/\/twitter.com\/WitchWendy2' target='_blank'>WitchWendy2<\/a>: RT @<a href='http:\/\/twitter.com\/SoGentle' target='_blank'>SoGentle<\/a> : \ubbf8\ucce4\ub124\uc694. \ud55c\ub450\ubc88\ub3c4 \uc544\ub2c8\uace0 RT @<a href='http:\/\/twitter.com\/energygirlz' target='_blank'>energygirlz<\/a>: \ub18d\uc2ec \uc300\uc0c8\uc6b0\uae61\uc5d0\uc11c \ubc8c\ub808\ubb34\ub354\uae30\uac00 \ub098\uc654\ub294\ub370 \ub18d\uc2ec\uc740 \ubc30\uc9f8;;\uc778\ud130\ub137\uc5d0 \uc62c\ub9ac\ub4e0 \uace0\ubc1c\uc744 \ud558\ub4e0 \ub9d8\ub300\ub85c \ud558\ub77c\ub294\ub370..\ub18d\uc2ec \uc9c4\uc2ec \ubbf8\uce5c\uac70\uc784? \ubb34\ud55c\uc54c\ud2f0 <a href='http:\/\/twitpic.com\/' target='_blank'>http:\/\/twitpic.com\/<\/a>","3":"<a href='http:\/\/www.samsungmobile.com' rel='nofollow'>Samsung Mobile<\/a>","source":"<a href='http:\/\/www.samsungmobile.com' rel='nofollow'>Samsung Mobile<\/a>","4":"21020299323","tid_status":"21020299323","5":"110050230","tid_user":"110050230","6":"clicksn","screen_name":"clicksn","7":"http:\/\/a2.twimg.com\/profile_images\/883350638\/IMG00007-20100125-1806_normal.jpg","photo_url":"http:\/\/a2.twimg.com\/profile_images\/883350638\/IMG00007-20100125-1806_normal.jpg","8":"110050230","tid_userid":"110050230","original_contents":"RT @WitchWendy2: RT @SoGentle : \ubbf8\ucce4\ub124\uc694. \ud55c\ub450\ubc88\ub3c4 \uc544\ub2c8\uace0 RT @energygirlz: \ub18d\uc2ec \uc300\uc0c8\uc6b0\uae61\uc5d0\uc11c \ubc8c\ub808\ubb34\ub354\uae30\uac00 \ub098\uc654\ub294\ub370 \ub18d\uc2ec\uc740 \ubc30\uc9f8;;\uc778\ud130\ub137\uc5d0 \uc62c\ub9ac\ub4e0 \uace0\ubc1c\uc744 \ud558\ub4e0 \ub9d8\ub300\ub85c \ud558\ub77c\ub294\ub370..\ub18d\uc2ec \uc9c4\uc2ec \ubbf8\uce5c\uac70\uc784? \ubb34\ud55c\uc54c\ud2f0 http:\/\/twitpic.com\/","original_date":"2010-08-13 09:50:16"},{"0":"3383218","id":"3383218","1":"2010-08-13 09:48:16","date_tweeted":"about 7 hour 43 minutes ago","2":"RT @SoGentle : \ubbf8\ucce4\ub124\uc694. \ud55c\ub450\ubc88\ub3c4 \uc544\ub2c8\uace0 RT @energygirlz: \ub18d\uc2ec \uc300\uc0c8\uc6b0\uae61\uc5d0\uc11c \ubc8c\ub808\ubb34\ub354\uae30\uac00 \ub098\uc654\ub294\ub370 \ub18d\uc2ec\uc740 \ubc30\uc9f8;;\uc778\ud130\ub137\uc5d0 \uc62c\ub9ac\ub4e0 \uace0\ubc1c\uc744 \ud558\ub4e0 \ub9d8\ub300\ub85c \ud558\ub77c\ub294\ub370..\ub18d\uc2ec \uc9c4\uc2ec \ubbf8\uce5c\uac70\uc784? \ubb34\ud55c\uc54c\ud2f0 http:\/\/twitpic.com\/","contents":"RT @<a href='http:\/\/twitter.com\/SoGentle' target='_blank'>SoGentle<\/a> : \ubbf8\ucce4\ub124\uc694. \ud55c\ub450\ubc88\ub3c4 \uc544\ub2c8\uace0 RT @<a href='http:\/\/twitter.com\/energygirlz' target='_blank'>energygirlz<\/a>: \ub18d\uc2ec \uc300\uc0c8\uc6b0\uae61\uc5d0\uc11c \ubc8c\ub808\ubb34\ub354\uae30\uac00 \ub098\uc654\ub294\ub370 \ub18d\uc2ec\uc740 \ubc30\uc9f8;;\uc778\ud130\ub137\uc5d0 \uc62c\ub9ac\ub4e0 \uace0\ubc1c\uc744 \ud558\ub4e0 \ub9d8\ub300\ub85c \ud558\ub77c\ub294\ub370..\ub18d\uc2ec \uc9c4\uc2ec \ubbf8\uce5c\uac70\uc784? \ubb34\ud55c\uc54c\ud2f0 <a href='http:\/\/twitpic.com\/' target='_blank'>http:\/\/twitpic.com\/<\/a>","3":"<a href='http:\/\/www.samsungmobile.com' rel='nofollow'>Samsung Mobile<\/a>","source":"<a href='http:\/\/www.samsungmobile.com' rel='nofollow'>Samsung Mobile<\/a>","4":"21020163250","tid_status":"21020163250","5":"59784180","tid_user":"59784180","6":"WitchWendy2","screen_name":"WitchWendy2","7":"http:\/\/a2.twimg.com\/profile_images\/834897978\/___normal.jpg","photo_url":"http:\/\/a2.twimg.com\/profile_images\/834897978\/___normal.jpg","8":"59784180","tid_userid":"59784180","original_contents":"RT @SoGentle : \ubbf8\ucce4\ub124\uc694. \ud55c\ub450\ubc88\ub3c4 \uc544\ub2c8\uace0 RT @energygirlz: \ub18d\uc2ec \uc300\uc0c8\uc6b0\uae61\uc5d0\uc11c \ubc8c\ub808\ubb34\ub354\uae30\uac00 \ub098\uc654\ub294\ub370 \ub18d\uc2ec\uc740 \ubc30\uc9f8;;\uc778\ud130\ub137\uc5d0 \uc62c\ub9ac\ub4e0 \uace0\ubc1c\uc744 \ud558\ub4e0 \ub9d8\ub300\ub85c \ud558\ub77c\ub294\ub370..\ub18d\uc2ec \uc9c4\uc2ec \ubbf8\uce5c\uac70\uc784? \ubb34\ud55c\uc54c\ud2f0 http:\/\/twitpic.com\/","original_date":"2010-08-13 09:48:16"},{"0":"3355375","id":"3355375","1":"2010-08-13 00:29:13","date_tweeted":"about 17 hour 2 minutes ago","2":"\uba85\ud0d0\uc815 \ucf54\ub09c\ub2d8\uc774 \uc54c\ub824\uc8fc\uc168\uc74c,,\u314b @Centrair_Hoya: http:\/\/twitpic.com RT @gaeun_park: \uc774 \ubd84 \uc0ac\uc9c4\ubcf4\ub294 \ud2b8\uc717\ud53d \uc0ac\uc774\ud2b8\uc880 \uc54c\ub824\uc8fc\uc154\uc694, \u314b \uc800\ub3c4 \uc0ac\uc9c4\uc740 \ud578\ud3f0\ubc14\ub85c\uc804\uc1a1\uc73c\ub85c \ud574\uc11c \uc798 \ubaa8... http:\/\/dw.am\/L5rTB","contents":"\uba85\ud0d0\uc815 \ucf54\ub09c\ub2d8\uc774 \uc54c\ub824\uc8fc\uc168\uc74c,,\u314b @<a href='http:\/\/twitter.com\/Centrair_Hoya' target='_blank'>Centrair_Hoya<\/a>: <a href='http:\/\/twitpic.com' target='_blank'>http:\/\/twitpic.com<\/a> RT @<a href='http:\/\/twitter.com\/gaeun_park' target='_blank'>gaeun_park<\/a>: \uc774 \ubd84 \uc0ac\uc9c4\ubcf4\ub294 \ud2b8\uc717\ud53d \uc0ac\uc774\ud2b8\uc880 \uc54c\ub824\uc8fc\uc154\uc694, \u314b \uc800\ub3c4 \uc0ac\uc9c4\uc740 \ud578\ud3f0\ubc14\ub85c\uc804\uc1a1\uc73c\ub85c \ud574\uc11c \uc798 \ubaa8... <a href='http:\/\/dw.am\/L5rTB' target='_blank'>http:\/\/dw.am\/L5rTB<\/a>","3":"<a href='http:\/\/twtkr.com' rel='nofollow'>twtkr<\/a>","source":"<a href='http:\/\/twtkr.com' rel='nofollow'>twtkr<\/a>","4":"20983887343","tid_status":"20983887343","5":"152995457","tid_user":"152995457","6":"gaeun_park","screen_name":"gaeun_park","7":"http:\/\/a3.twimg.com\/profile_images\/1080365215\/_B704_1_normal.JPG","photo_url":"http:\/\/a3.twimg.com\/profile_images\/1080365215\/_B704_1_normal.JPG","8":"152995457","tid_userid":"152995457","original_contents":"\uba85\ud0d0\uc815 \ucf54\ub09c\ub2d8\uc774 \uc54c\ub824\uc8fc\uc168\uc74c,,\u314b @Centrair_Hoya: http:\/\/twitpic.com RT @gaeun_park: \uc774 \ubd84 \uc0ac\uc9c4\ubcf4\ub294 \ud2b8\uc717\ud53d \uc0ac\uc774\ud2b8\uc880 \uc54c\ub824\uc8fc\uc154\uc694, \u314b \uc800\ub3c4 \uc0ac\uc9c4\uc740 \ud578\ud3f0\ubc14\ub85c\uc804\uc1a1\uc73c\ub85c \ud574\uc11c \uc798 \ubaa8... http:\/\/dw.am\/L5rTB","original_date":"2010-08-13 00:29:13"},{"0":"3355004","id":"3355004","1":"2010-08-13 00:24:44","date_tweeted":"about 17 hour 7 minutes ago","2":"http:\/\/twitpic.com RT @gaeun_park: \uc774 \ubd84 \uc0ac\uc9c4\ubcf4\ub294 \ud2b8\uc717\ud53d \uc0ac\uc774\ud2b8\uc880 \uc54c\ub824\uc8fc\uc154\uc694, \u314b \uc800\ub3c4 \uc0ac\uc9c4\uc740 \ud578\ud3f0\ubc14\ub85c\uc804\uc1a1\uc73c\ub85c \ud574\uc11c \uc798 \ubaa8\ub984RT @ygkang2001: @gaeun_park \uc0ac\uc9c4\uc740 \uc5b4\ub514\uc11c \ubcfc\uc218\uc788\ub294\uac70\uc5d0\uc694?(\ud2b8\uc704\ud130\ucd08\ubcf4\uac00...)","contents":"<a href='http:\/\/twitpic.com' target='_blank'>http:\/\/twitpic.com<\/a> RT @<a href='http:\/\/twitter.com\/gaeun_park' target='_blank'>gaeun_park<\/a>: \uc774 \ubd84 \uc0ac\uc9c4\ubcf4\ub294 \ud2b8\uc717\ud53d \uc0ac\uc774\ud2b8\uc880 \uc54c\ub824\uc8fc\uc154\uc694, \u314b \uc800\ub3c4 \uc0ac\uc9c4\uc740 \ud578\ud3f0\ubc14\ub85c\uc804\uc1a1\uc73c\ub85c \ud574\uc11c \uc798 \ubaa8\ub984RT @<a href='http:\/\/twitter.com\/ygkang2001' target='_blank'>ygkang2001<\/a>: @<a href='http:\/\/twitter.com\/gaeun_park' target='_blank'>gaeun_park<\/a> \uc0ac\uc9c4\uc740 \uc5b4\ub514\uc11c \ubcfc\uc218\uc788\ub294\uac70\uc5d0\uc694?(\ud2b8\uc704\ud130\ucd08\ubcf4\uac00...)","3":"<a href='http:\/\/mobileways.de\/gravity' rel='nofollow'>Gravity<\/a>","source":"<a href='http:\/\/mobileways.de\/gravity' rel='nofollow'>Gravity<\/a>","4":"20983556056","tid_status":"20983556056","5":"107643193","tid_user":"107643193","6":"Centrair_Hoya","screen_name":"Centrair_Hoya","7":"http:\/\/a0.twimg.com\/profile_images\/1092997136\/pic_normal.jpg","photo_url":"http:\/\/a0.twimg.com\/profile_images\/1092997136\/pic_normal.jpg","8":"107643193","tid_userid":"107643193","original_contents":"http:\/\/twitpic.com RT @gaeun_park: \uc774 \ubd84 \uc0ac\uc9c4\ubcf4\ub294 \ud2b8\uc717\ud53d \uc0ac\uc774\ud2b8\uc880 \uc54c\ub824\uc8fc\uc154\uc694, \u314b \uc800\ub3c4 \uc0ac\uc9c4\uc740 \ud578\ud3f0\ubc14\ub85c\uc804\uc1a1\uc73c\ub85c \ud574\uc11c \uc798 \ubaa8\ub984RT @ygkang2001: @gaeun_park \uc0ac\uc9c4\uc740 \uc5b4\ub514\uc11c \ubcfc\uc218\uc788\ub294\uac70\uc5d0\uc694?(\ud2b8\uc704\ud130\ucd08\ubcf4\uac00...)","original_date":"2010-08-13 00:24:44"}];

    if(tweets=="" || tweets==[] || tweets==null){
        dummyEmpty();
        
    }else{
        clearInterval(_i.widget_refresh);
        
        var more_count = document.getElementById('more_count_'+_i.widget_no);
        
        //tmxwgList.innerHTML = _i.createTweetList(tweets,_i)+tmxwgList.innerHTML;
        var len = tweets.length;
        
        _i.last_id = tweets[0].id;
        _i.last_date = tweets[0].original_date;

        var more_on = document.getElementById('tmxwgList_'+_i.widget_no).firstChild;
        
        more_on.className = more_on.className + " more-on";
        
        for(var i=0; i < len; i++){
            var tmxwgList = document.getElementById('tmxwgList_'+_i.widget_no);
            _i.createRefreshData(tweets[i],_i, tmxwgList);
        }
        
        _i.refresh_count = _i.refresh_count + tweets.length;
        var check_count = parseInt(_i.max_messages,10);

        var this_total_count = document.getElementById('this_total_count');
        var tot_count = this_total_count.innerHTML;

        tot_count = tot_count.replace('(','');
        tot_count = tot_count.replace(')','');
        
        tot_count = parseInt(tot_count,10) + tweets.length;
        
        var str_tot_count = '('+tot_count+')';
        
        this_total_count.innerHTML = str_tot_count;
        
        if(_i.refresh_count >= check_count){
            more_count.innerHTML = parseInt(more_count.innerHTML,10) + tweets.length;
        }
        
        dummyEmpty();
        checkTweetmixWidgetHeight();
        _i.widgetRefresh(_i);
    }
    
};

Widget.prototype.createRefreshData= function(tweets, _i, tmxwgList){
        var strHTML="";

        var li = document.createElement('li');
        li.className = "tmx_item";

        if(_i.is_show_avatar == 1){

            strHTML = strHTML + '<div class=\"tmx_avatar\">';
            strHTML = strHTML + '<a href=\"'+_i.tw_url;
            strHTML = strHTML + '/'+tweets.screen_name;
            strHTML = strHTML + '\" target=\"_blank\">';
            strHTML = strHTML + '<img src=\"'+tweets.photo_url;
            strHTML = strHTML + '\" alt=\"'+tweets.screen_name;
            strHTML = strHTML + '\" id=\"img'+tweets.id;
            strHTML = strHTML +'-'+tweets.tid_userid+'\"/>';
            strHTML = strHTML + '</a>';
            strHTML = strHTML + '</div>';
            strHTML = strHTML + '<div class=\"tmx_tweet\">';

        }else{
            strHTML = strHTML + '<div class=\"tmx_tweet\" style=\"margin-left:0;\">';

        }

        strHTML = strHTML + '<div class=\"tmx_author\">';
        strHTML = strHTML + '<a style=\"color:#'+_i.color_link+'\" href=\"'+_i.tw_url;
        strHTML = strHTML + '/'+tweets.screen_name;
        strHTML = strHTML + '\" target="_blank\">';
        strHTML = strHTML + tweets.screen_name+'</a>';
        strHTML = strHTML + '</div>';

        strHTML = strHTML + '<p class=\"tmx_article\" style=\"color:#'+ _i.color_text+'\">';
        strHTML = strHTML + (tweets.contents).replace(/<a/g, '<a style=\"color:#'+ _i.color_link+'\"');
        strHTML = strHTML + '</p>';
        
        strHTML = strHTML + '<div class=\"tmx_status\">';

        strHTML = strHTML + '<span class=\"tmx_date\" style=\"color:#'+ _i.color_text+'\">';

        strHTML = strHTML + '<a style=\"color:#'+_i.color_text+'\" href=\"'+_i.tt_url;
        strHTML = strHTML + '/'+tweets.screen_name;
        strHTML = strHTML + '/status/'+tweets.tid_status;
        strHTML = strHTML + '\" target=\"_blank\">';
        strHTML = strHTML + tweets.date_tweeted+'</a>';
        strHTML = strHTML + ' from ' + (tweets.source).replace(/<a/g, '<a style=\"color:#'+ _i.color_text+'\"');

        strHTML = strHTML + '</span>';
        
        strHTML = strHTML + '<ul>';

        if(_i.widget_type==0){
            var more_url = _i.tw_url + "/?u=" + tweets.link_url;
            strHTML = strHTML + '<li><a target=\"_blank\" href=\"'+more_url+'\" class=\"tmxwg_tweetinfo '+_i.btn_type_class+'\" title=\"다른 트윗보기\" ';
            strHTML = strHTML + 'style=\"color:#'+_i.color_text+'\">다른 트윗보기</a></li>';
        }

        strHTML = strHTML + '<li><a href=\"#\" class=\"tmx_btn_reply '+_i.btn_type_class+'\" title=\"Reply\" ';
        strHTML = strHTML + 'style=\"color:#'+_i.color_text+'\" ';
        strHTML = strHTML + 'onclick=\"widget_reply(\''+tweets.screen_name+'\',\''+tweets.tid_status+'\');return false\">Reply</a></li>';
        strHTML = strHTML + '<li><a href=\"#\" class=\"tmx_btn_retweet '+_i.btn_type_class+'\" title=\"Retweet\" ';
        strHTML = strHTML + 'style=\"color:#'+_i.color_text+'\" ';
        
        var original_contents = escap(tweets.original_contents);
        
        strHTML = strHTML + 'onclick=\"widget_retweet(\''+tweets.screen_name+'\',\''+original_contents+'\');return false\">Retweet</a></li>';
        
        strHTML = strHTML + '</ul>';

        strHTML = strHTML + '<div class=\"tmx_clear\"></div> ';
        //tmxwg_status
        strHTML = strHTML + '</div>';
        //tweet
        strHTML = strHTML + '</div>';

        li.innerHTML = strHTML;

        var child = tmxwgList.firstChild;
        
        tmxwgList.insertBefore(li,child);

        if(tmxwgList.firstChild != 'undefined'){

        //animate
            if(!twm_conflict){
                jQuery(tmxwgList.firstChild).hide().delay(100).fadeIn('slow');
                
            }else{
                twm(tmxwgList.firstChild).hide().delay(100).fadeIn('slow');
                
            }
        }
        
};

Widget.prototype.getJsonScriptRefreshData = function(url, callback, _v, id) {

    _v.scriptElement = document.createElement('script');
    _v.scriptElement.type = 'text/javascript';
    _v.scriptElement.src = url;
    if(typeof id != 'undefined') _v.scriptElement.id = id;

    if (typeof _v.scriptElement.addEventListener != 'undefined') {
        _v.scriptElement.addEventListener('load',function (evt) {
            callback(_v);
        },false);
        _v.tmp_div.appendChild(_v.scriptElement);
    }
    else if (typeof _v.scriptElement.attachEvent != 'undefined') {

        //FUCK! FUCK! FUCK! FUCK! FUCK! FUCK! FUCK!
        var scriptElement = _v.scriptElement;
        var IE_FUCK_DIV = _v.tmp_div;

        scriptElement.attachEvent('onreadystatechange',function () {
            if (scriptElement.readyState == 'loaded') {
                IE_FUCK_DIV.appendChild(scriptElement);
                callback(_v);
            }
        });
    }
};

Widget.prototype.getObj = function(thingy) {
    // simple DOM lookup utility function
    if (typeof(thingy) == 'string') thingy = document.getElementById(thingy);
    if (!thingy.addClass) {
        // extend element with a few useful methods
        thingy.hide = function() {
            this.style.display = 'none';
        };
        thingy.show = function() {
            this.style.display = '';
        };
        thingy.addClass = function(name) {
            this.removeClass(name);
            this.className += ' ' + name;
        };
        thingy.removeClass = function(name) {
            var classes = this.className.split(/\s+/);
            var idx = -1;
            for (var k = 0; k < classes.length; k++) {
                if (classes[k] == name) {
                    idx = k;
                    k = classes.length;
                }
            }
            if (idx > -1) {
                classes.splice( idx, 1 );
                this.className = classes.join(' ');
            }
            return this;
        };
        thingy.hasClass = function(name) {
            return !!this.className.match( new RegExp("\\s*" + name + "\\s*") );
        };
    }
    return thingy;
};

Widget.prototype.setInit = function(add_obj_id) {
    
    if (typeof(add_obj_id) == 'string') {
        this.str_add_obj_id = add_obj_id;
    }
    //this.jqueryAdd();
    this.widgetCommonCssAdd();
    this.widgetTypeUrl();
    this.contentsSetting();
};

Widget.prototype.widgetTypeUrl = function() {

    this.url = this.url+"?widget_type="+this.widget_type;
    this.url = this.url+"&target_url="+this.target_url;
    this.url = this.url+"&width="+this.width;
    this.url = this.url+"&height="+this.height;
    this.url = this.url+"&max_messages="+this.max_messages;
    this.url = this.url+"&is_show_ads="+this.is_show_ads;
    
};

Widget.prototype.contentsSetting = function() {

    this.getJsonScript(this.url, this.pushContents ,this);
};

Widget.prototype.pushContents = function(_i) {
    
    if(_i.tmp_div.childNodes.length !=0 ){
        _i.tmp_div.removeChild(_i.scriptElement);
    }
    _i.pushHd(_i);
    _i.pushBd(_i);
    _i.pushFt(_i);
    _i.tweetmixWidgetAdd(_i);

    /*
    if(_i.is_refresh_always==1){
        _i.widgetRefresh(_i);
    }
    */
};

Widget.prototype.pushHd = function(_i) {

    var div_retweet= document.createElement('div');
    var span_tot_count= document.createElement('span');
    var div_clear= document.createElement('div');
    var h3_title = document.createElement('h3');
    var a_title = document.createElement('A');
    var a_tweet= document.createElement('A');

    div_retweet.className="tmx_btn_tweet";
    div_clear.className="tmx_clear";
    span_tot_count.id = 'this_total_count';
    span_tot_count.innerHTML = ' ('+parseInt(_i.jsonWidget.total_count,10)+')';
    span_tot_count.style.cssText = "color: #"+_i.color_upper_text;

    a_title.target = "_blank";
    a_title.innerHTML = _i.widget_title;
    a_title.appendChild(span_tot_count);
    
    if(_i.widget_type==0){
        a_title.href = _i.tw_url+'/?u=' + _i.target_url + '/*';

    }else{
        
        a_tweet.target = "_blank";
        a_tweet.setAttribute('title','tweet');
        a_tweet.className = _i.btn_type_class;

        var span_tweet_text= document.createElement('span');
        span_tweet_text.style.cssText = "color: #"+_i.color_upper_text;
        span_tweet_text.innerHTML = "tweet";
        a_tweet.appendChild(span_tweet_text);
        
        var tweet_content = _i.target_url+" "+ _i.default_msg+" ";

        tweet_content = escap(tweet_content);

        if (typeof a_tweet.addEventListener != 'undefined') {
            a_tweet.setAttribute('onclick',"widget_tweets(\'"+tweet_content+"\');return false;");
        // FUCK IE
        }else if (typeof a_tweet.attachEvent != 'undefined') {
            a_tweet.attachEvent('onmousedown',function () {
                widget_tweets(tweet_content);
            });
        }
        
        a_title.href = _i.tw_url+'/?u=' + _i.target_url;
    }

    //Css Setting
    var tmxwg_hd_css = _i.tmxwg_hd.style;
    var a_title_css = a_title.style;

    tmxwg_hd_css.backgroundColor = "#"+_i.color_upper_back;

    a_title_css.cssText = "color: #"+_i.color_upper_text;
    //a_title_css.color = "#"+_i.color_upper_text;

    //OBJ Append
    h3_title.appendChild(a_title);
    
    div_retweet.appendChild(a_tweet);

    _i.tmxwg_hd.appendChild(h3_title);
    _i.tmxwg_hd.appendChild(div_retweet);
    _i.tmxwg_hd.appendChild(div_clear);
};

Widget.prototype.createTweetList = function(tweets ,_i) {
    
        var strHTML="";
        _i.last_id = tweets[0].id;
        _i.last_date = tweets[0].original_date;
        var len = tweets.length;
        for(var i=0; i < len; i++){
            strHTML = strHTML + "<li class=\"tmx_item\">";

            if(_i.is_show_avatar == 1){

                strHTML = strHTML + '<div class=\"tmx_avatar\">';
                strHTML = strHTML + '<a href=\"'+_i.tw_url;
                strHTML = strHTML + '/'+tweets[i].screen_name;
                strHTML = strHTML + '\" target=\"_blank\">';
                strHTML = strHTML + '<img src=\"'+tweets[i].photo_url;
                strHTML = strHTML + '\" alt=\"'+tweets[i].screen_name;
                strHTML = strHTML + '\" id=\"img'+tweets[i].id;
                strHTML = strHTML +'-'+tweets[i].tid_userid+'\"/>';
                strHTML = strHTML + '</a>';
                strHTML = strHTML + '</div>';
                strHTML = strHTML + '<div class=\"tmx_tweet\">';

            }else{
                strHTML = strHTML + '<div class=\"tmx_tweet\" style=\"margin-left:0;\">';
                
            }

            strHTML = strHTML + '<div class=\"tmx_author\">';
            strHTML = strHTML + '<a style=\"color:#'+_i.color_link+'\" href=\"'+_i.tw_url;
            strHTML = strHTML + '/'+tweets[i].screen_name;
            strHTML = strHTML + '\" target=\"_blank\">';
            strHTML = strHTML + tweets[i].screen_name+'</a>';
            strHTML = strHTML + '</div>';

            strHTML = strHTML + '<p class=\"tmx_article\" style=\"color:#'+ _i.color_text+'\">';
            strHTML = strHTML + (tweets[i].contents).replace(/<a/g, '<a style=\"color:#'+ _i.color_link+'\"');
            strHTML = strHTML + '</p>';

            strHTML = strHTML + '<div class=\"tmx_status\">';

            strHTML = strHTML + '<span class=\"tmx_date\" style=\"color:#'+ _i.color_text+'\">';

            strHTML = strHTML + '<a style=\"color:#'+_i.color_text+'\" href=\"'+_i.tt_url;
            strHTML = strHTML + '/'+tweets[i].screen_name;
            strHTML = strHTML + '/status/'+tweets[i].tid_status;
            strHTML = strHTML + '\" target=\"_blank\">';
            strHTML = strHTML + tweets[i].date_tweeted+'</a>';
            strHTML = strHTML + ' from ' + (tweets[i].source).replace(/<a/g, '<a style=\"color:#'+ _i.color_text+'\"');

            strHTML = strHTML + '</span>';

            strHTML = strHTML + '<ul>';

            if(_i.widget_type==0){
                var more_url = _i.tw_url + "/?u=" + tweets[i].link_url;
                strHTML = strHTML + '<li><a target=\"_blank\" href=\"'+more_url+'\" class=\"tmxwg_tweetinfo '+_i.btn_type_class+'\" title=\"다른 트윗보기\" ';
                strHTML = strHTML + 'style=\"color:#'+_i.color_text+'\">다른 트윗보기</a></li>';
            }

            strHTML = strHTML + '<li><a href=\"#\" class=\"tmx_btn_reply '+_i.btn_type_class+'\" title=\"Reply\" ';
            strHTML = strHTML + 'style=\"color:#'+_i.color_text+'\" ';
            strHTML = strHTML + 'onclick=\"widget_reply(\''+tweets[i].screen_name+'\',\''+tweets[i].tid_status+'\');return false\">reply</a></li>';
            strHTML = strHTML + '<li><a href=\"#\" class=\"tmx_btn_retweet '+_i.btn_type_class+'\" title=\"Retweet\" ';
            strHTML = strHTML + 'style=\"color:#'+_i.color_text+'\" ';

            var original_contents = escap(tweets[i].original_contents);

            strHTML = strHTML + 'onclick=\"widget_retweet(\''+tweets[i].screen_name+'\',\''+ original_contents+'\');return false\">retweet</a></li>';

            strHTML = strHTML + '</ul>';

            strHTML = strHTML + '<div class=\"tmx_clear\"></div> ';
            //tmxwg_status
            strHTML = strHTML + '</div>';
            //tweet
            strHTML = strHTML + '</div>';
        }

        return strHTML;
};

Widget.prototype.pushBd = function(_i) {
    
    var widget_prt = _i.jsonWidget;
    
    var ul_tmxwgList = document.createElement('ul');
    ul_tmxwgList.className="tmx_list";
    ul_tmxwgList.id = "tmxwgList_"+_i.widget_no;
    
    /*
    if(_i.is_show_ads == 1){
        
        if(typeof widget_prt.widget_ads != 'undefined'||widget_prt.widget_ads!=""){
            var len = widget_prt.widget_ads.length;
            for(var i=0; i < len; i++){

                var div_ad= document.createElement('div');
                div_ad.className = "ad";
                div_ad.style.display = "block";
                div_ad.innerHTML = widget_prt.widget_ads[i].contents;
                _i.tmxwg_bd.appendChild(div_ad);
                
            }
        }
    }
    */

    
    if(typeof widget_prt.tweets=='undefined' || widget_prt.tweets == '' || widget_prt.tweets == [] || widget_prt.tweets == -1){
        ul_tmxwgList.innerHTML = '<li class="tmx_none_msg">'+widget_prt.no_msg+'</li>';

    }else{
        var tweets = widget_prt.tweets;
        var strHTML=_i.createTweetList(tweets,_i);
        
        ul_tmxwgList.innerHTML = strHTML;
    }

    //Css Setting
    var tmxwg_bd_css = _i.tmxwg_bd.style;
    
    tmxwg_bd_css.height = widget_prt.height;
    tmxwg_bd_css.overflow = "auto";

    //OBJ Append
    _i.tmxwg_bd.appendChild(ul_tmxwgList);
    
};

Widget.prototype.pushFt = function(_i) {

    var div_moretweet = document.createElement('div');
    var div_copyright = document.createElement('div');
    var a = document.createElement('A');
    var a_cpoyright = document.createElement('A');

    div_moretweet.className = "tmx_more";
    div_copyright.className = "tmx_copyright";
    
    _i.refresh_count = parseInt(_i.jsonWidget.total_count,10);
    var more_counter = parseInt(_i.jsonWidget.total_count,10) - parseInt(_i.max_messages,10);
    if(more_counter < 0) more_counter=0;
    
    a.target = "_blank";
    //a.innerHTML = "more(<span id='more_count_"+_i.widget_no+"'>"+more_counter+"</span>) &rsaquo;";
    a.innerHTML = "<span id='more_count_"+_i.widget_no+"'>"+more_counter+"</span> 트윗 더보기 &rsaquo;";

    a_cpoyright.target = "_blank";
    a_cpoyright.innerHTML = "Tweetmix";
    a_cpoyright.href = _i.tw_url;

    
    if(_i.widget_type==0){
        a.href = _i.tw_url+'/?u=' + _i.target_url + '/*';

    }else{
        a.href = _i.tw_url+'/?u=' + _i.target_url;

    }

    //Css Setting
    var a_css = a.style;
    
    a_css.cssText = "color: #"+_i.color_text;

    //OBJ Append
    div_moretweet.appendChild(a);
    div_copyright.appendChild(a_cpoyright);

    _i.tmxwg_ft.appendChild(div_moretweet);
    _i.tmxwg_ft.appendChild(div_copyright);

    var widget_prt = _i.jsonWidget;

    if(_i.is_show_ads == 1){

        if(typeof widget_prt.widget_ads != 'undefined'||widget_prt.widget_ads!=""){
            var len = widget_prt.widget_ads.length;
            for(var i=0; i < len; i++){

                var span_ad= document.createElement('span');
                span_ad.className = "tmx_ad";
                span_ad.style.display = "block";
                span_ad.innerHTML = widget_prt.widget_ads[i].contents;
                _i.tmxwg_ft.appendChild(span_ad);

            }
        }
    }
    
};

Widget.prototype.addDummy = function() {
    
    if(this.str_add_obj_id!=""){
        this.parentNodeEl = document.getElementById(this.str_add_obj_id);
        
    }else{
        var div = document.getElementById('tweetmix_widget_'+this.widget_no);
        this.parentNodeEl=div.parentNode;
    }

    var zIndex = -99;

    this.tmp_div = document.createElement('div');
    this.tmp_div.className = "dummy";
    var style = this.tmp_div.style;    
    style.left = '0';
    style.top = '0';
    style.width = '0';
    style.height = '0';
    style.zIndex = zIndex;
    
    this.parentNodeEl.insertBefore(this.tmp_div, div);
    
    if(this.parentNodeEl){
        this.parentNodeEl.removeChild(div);
    }
    
};

Widget.prototype.tweetmixWidgetAdd = function(_i){
    
    var tmxwg_box_css = _i.tmxwg_box.style;
    tmxwg_box_css.backgroundColor = "#"+_i.color_tweet_back;
    tmxwg_box_css.border = "1px solid #"+_i.color_border;
    
    tmxwg_box_css.width = _i.jsonWidget.width;

    //original
    _i.parentNodeEl.insertBefore(_i.tweetmix_widget_div_wrap, _i.tmp_div);
    _i.tweetmix_widget_div_wrap.appendChild(_i.tweetmix_widget_div);
    _i.tweetmix_widget_div.appendChild(_i.tmxwg_box);
    _i.tmxwg_box.appendChild(_i.tmxwg_hd);
    _i.tmxwg_box.appendChild(_i.tmxwg_bd);
    _i.tmxwg_box.appendChild(_i.tmxwg_ft);

    checkTweetmixWidgetHeight();
    
};

Widget.prototype.tweetmixWidgetCreate = function(){
    
    this.tweetmix_widget_div_wrap = document.createElement('div');
    this.tweetmix_widget_div = document.createElement('div');
    var style = this.tweetmix_widget_div_wrap.style;
    var zIndex = 99;

    if(this.width!=0){
        style.width = this.width+"px";
        
    }else{
        style.width = '100%';
        
    }

    if(this.height!=0){
        style.height = this.height+"px";
        
    }else{
        style.height = '100%';
    }
    
    style.zIndex = zIndex;
    style.marginBottom = "20px";
    style.marginTop = "20px";
    style.marginLeft = "0";
    style.marginRight = "0";
    
    this.tmxwg_box = document.createElement('div');
    this.tmxwg_hd = document.createElement('div');
    this.tmxwg_bd = document.createElement('div');
    this.tmxwg_ft = document.createElement('div');

    this.tweetmix_widget_div_wrap.className = "tweetmix_widget_wrap";

    if(this.widget_type==0){
        this.tweetmix_widget_div.className =  "tweetmix_widget_unit";

    }else{
        this.tweetmix_widget_div.className =  "tweetmix_widget_post";
        
    }
    
    this.tmxwg_box.className="tmxwg_box";

    this.tmxwg_hd.className = "tmxwg_hd";
    this.tmxwg_bd.className = "tmxwg_bd";
    this.tmxwg_ft.className = "tmxwg_ft";
    
};

Widget.prototype.getJsonScript = function(url, callback, _v, id) {
    
    _v.addDummy();
    _v.tweetmixWidgetCreate();

    _v.scriptElement = document.createElement('script');
    _v.scriptElement.type = 'text/javascript';
    _v.scriptElement.src = url;
    if(typeof id != 'undefined') _v.scriptElement.id = id;

    if (typeof _v.scriptElement.addEventListener != 'undefined') {
        //_v.scriptElement.addEventListener('load',function (evt) {
        _v.scriptElement.addEventListener('load',function () {
            //alert(evt.type);
            callback(_v);
        },false);
        _v.tmp_div.appendChild(_v.scriptElement);
    }
    else if (typeof _v.scriptElement.attachEvent != 'undefined') {

        //FUCK! FUCK! FUCK! FUCK! FUCK! FUCK! FUCK!
        var scriptElement = _v.scriptElement;
        var IE_FUCK_DIV = _v.tmp_div;
        scriptElement.attachEvent('onreadystatechange',function () {
            //alert(scriptElement.readyState);
            if (scriptElement.readyState == 'loaded') {
            //if (scriptElement.readyState == 'complete') {
                IE_FUCK_DIV.appendChild(scriptElement);
                callback(_v);
            }
        });
    }
};

Widget.prototype.widgetCommonCssAdd = function(){

    var check = document.getElementById('tweetmix_widget_comm_css');

    if(!check){
        
        var cc=document.createElement("link");
        cc.href=this.tw_url+this.css_url;
        cc.rel="stylesheet";
        cc.type="text/css";
        cc.id="tweetmix_widget_comm_css";

        document.getElementsByTagName("head")[0].appendChild(cc);
    }
};

//JQUERY
Widget.prototype.jqueryAdd = function(){
    if(!("jQuery" in window)) {
		twm_conflict = true;
		var head      = document.getElementsByTagName('head')[0],
		script        = document.createElement('script');
		script.type   = 'text/javascript';
		script.src    = this.tw_url+"/js/jquery-1.4.2.js"
		script.onload = this.jqueryconflictAdd;
		head.appendChild(script);
	}
};
    
Widget.prototype.jqueryconflictAdd = function(){
    if(twm_conflict) twm = jQuery.noConflict();
};
