var TWF = {};
var boxWidth;
var boxHeight;
var apiKey;
if (!TWF.dynData) {
    TWF.dynData = {
        "site_vars": {
            "canvas_client_compute_content_size_method": 1

        },
        "resources": {
			"base_url_format": "http://www.tweetatweet.com/",
    		// "base_url_format": "http://tat.local/",
			 "prompt_twitter_feed_url": "prompt_twitter_feed.php",
			 "prompt_twitter_feedback_url": "prompt_twitter_feedback_url.php",
			 "twitter_rpc_feedback_url" : "rpc.php?action=feedback"

        }
    };
}

if (!TWF.locale) {
    TWF.locale = "en_US";
}
if (!TWF.localeIsRTL) {
    TWF.localeIsRTL = false;
}

if (!window.TWF) TWF = {};
if (!TWF.Monitor) TWF.Monitor = {
	setUser: function(q){
		if (typeof($) != "function") {
		 TWF.Monitor.jsInclude(TWF.dynData.resources.base_url_format+"tw/js/jquery.js");
		}
		TWF.Monitor.jsInclude(TWF.dynData.resources.base_url_format+"tw/js/jquery.blockUI.js");
		boxHeight2 = 300;boxWidth2 = 400;apiKey2 = q.api_key;
		TWF.Monitor.jsInclude(TWF.dynData.resources.base_url_format+"tw/js/feed_box2.js");
		TWF.Monitor.jsInclude(TWF.dynData.resources.base_url_format+"tw/js/jquery.validates2.js");
		TWF.Monitor.cssInclude(TWF.dynData.resources.base_url_format+"tw/css/feedback.css");
		TWF.Monitor.createMain(q);
		TWF.Monitor.getJsonData(q.api_key);
	},
	createCommentBox:function(q){
		tifInnerHtml = '<div style = "position:fixed;top:50%;  z-index:1000; right:0; _float:right; _position:absolute; "><img src = "http://www.tweetatweet.com/images/feedback.jpg" onclick="ShwTweetaTweetCommBOX()"/></div>';
		TWF.Monitor.ContainerOut(tifInnerHtml);
		},ContainerOut:function(H){
		document.write(H);
	},
	createMain:function(q){
		
		var mainDiv = '<div style=" font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#666;" ><div style=" height:17px; _margin-bottom:-1px;"><div style="background:url('+TWF.dynData.resources.base_url_format+'tw/images/background.gif) no-repeat left top; width:9px; height:17px; float:left;"></div><div style="float:left; color:#1092B7; font-size:15px;  background:url('+TWF.dynData.resources.base_url_format+'tw/images/top-mid.gif) repeat-x; height:17px; width:202px;"><span style="background:#fff; padding:0 5px; line-height:17px; ">'+q.company+'</span></div><div style="background:url('+TWF.dynData.resources.base_url_format+'tw/images/background.gif) no-repeat -11px top; width:9px; height:17px; float:right;"></div></div><div style=" background:url('+TWF.dynData.resources.base_url_format+'tw/images/mid-bk.gif) repeat-y; clear:both; padding:15px; overflow:hidden; "><p id="tweetUI" style="word-wrap:break-word;">Loading.... </p><div style="float:left;font-size:10px;width:100px;">powered by<a href="http://www.tweetatweet.com/" target="_blank" style="background:url('+TWF.dynData.resources.base_url_format+'tw/images/wiget_logo-2.gif) no-repeat; width:73px; height:20px; text-decoration:none; display:block;float:left;"><span style="display:none;">Tweet a Tweet</span></a></div><div style="clear:both;"></div></div><div style=" height:9px;"><div style="background:url('+TWF.dynData.resources.base_url_format+'tw/images/background.gif) no-repeat -21px -7px; width:9px; height:9px; float:left;"></div><div style="float:left; color:#1092B7; font-size:15px;  background:url('+TWF.dynData.resources.base_url_format+'tw/images/bot-bk.gif) repeat-x; height:9px; width:202px;"></div><div style="background:url('+TWF.dynData.resources.base_url_format+'tw/images/background.gif) no-repeat -31px -7px; width:9px; height:9px; float:right;"></div></div></div>';
		document.write(mainDiv);
		},
	getJsonData:function(api_key){	
	
	$(function(){
			  
		    $.getJSON(TWF.dynData.resources.base_url_format+'tw/'+TWF.dynData.resources.twitter_rpc_feedback_url+'&mode=get_random_tweet&api_key='+api_key+'&callback=?', function (data) {
       $("#tweetU").html('');
        $.each(data, function (i, item) {
			
            $("#tweetUI").html( item.tweet);

        });
    });
    $("#tweetU").fadeIn(2000);
	});
	},
	jsInclude:function(jsFile) {
                 document.write('<' + 'script');
                 document.write(' language="JavaScript"');
                 document.write(' type="text/javascript"');
                 document.write(' src="' + jsFile + '">');
                 document.write('</' + 'script' + '>');
         },
	cssInclude:function(cssFile) {
                 document.write('<' + 'link');
                 document.write(' rel="stylesheet"');
				 document.write(' media="all"');
                 document.write(' type="text/css"');
                 document.write(' href="' + cssFile + '"/>');
         }
	

};
