var _widthMargin = 320;

$(function() {
	
	$("#tabBar").css("top","0px");
    $("#tabBar").css("right","300px");
    $("#tabBar").css("width","20px");
    $("#tabBar").css("height","100%");
	
	//layout timeline
	$("body").prepend('<div id="tabBar"><div id="tl_tab"><img id="tab_icon" src="./twitter/images/list-arrow.png"></div></div><div id="timeline_wrapper" style="width:300px;height:100%;position: absolute;top:0;right:0;"><iframe width="300px" height="100%" src="./twitter/index.html" hspace="0" vspace="0" marginheight="0" marginwidth="0" border="0" frameborder="0" framespacing="0"></iframe></div>');
	$("body").attr("marginheight","0");
	$("body").attr("marginwidth","0");
	$("body").attr("leftMargin","0");
	$("body").attr("topMargin","0");
	$("body").css("overflow","hidden");
	
	
	myOnLoad();
	
	$("#tabBar").click(function(){
        if($("#tabBar").css("right") == "300px"){
            $("#timeline_wrapper").hide();
            $("#tabBar").animate({"right":"0px"},{complete : function (){
                $("#tl_tab img").attr("src","./twitter/images/list-arrow-back.png");
                _widthMargin = 20;
                windowResize();
            }});
        }else{
             _widthMargin = 320;
            windowResize();
            $("#tabBar").animate({"right":"300px"},{complete : function () {
                $("#tl_tab img").attr("src","./twitter/images/list-arrow.png");
                $("#timeline_wrapper").show();
            }});
        }
    });
	
	$("#tl_tab").mouseover(function(){
		$("#tab_icon").attr("src",$("#tab_icon").attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"));
	}).mouseout(function(){
		$("#tab_icon").attr("src",$("#tab_icon").attr("src").replace(/^(.+)_on(\.[a-z]+)$/, "$1$2"));
	});
	
});

function myOnLoad(){
     			windowResize();
     			window.onresize = windowResize;
	        }
	       
	        //---
	        function windowResize(){
	        	element = document.getElementById("content");
				var tmpSizeObj = getWindowSize();
				element.style.top = "0px";
				element.style.left = "0px";
				element.style.width = Number(tmpSizeObj.width-_widthMargin)+"px";
				element.style.height = (Number(tmpSizeObj.height))+"px";
	        }
	        //---
	        function getWindowSize() {
				var winSizeObj = new Object();
				
			    // IE以外。
				if (!document.all && (document.layers || document.getElementById)) {
				    winWidth=window.innerWidth;
				    winHeight=window.innerHeight;
				    }
				// ウィンドウズIE 6・標準モード。
				else if (document.getElementById && (document.compatMode=='CSS1Compat')) {
				    winWidth=document.documentElement.clientWidth;
				    winHeight=document.documentElement.clientHeight;
				    }
				// その他のIE。
				else if (document.all) {
				    winWidth=document.body.clientWidth;
				    winHeight=document.body.clientHeight;
				    }
				// その他(非対応)。
				else {
				    winWidth=1024;
				    winHeight=768;
			    }
			    
			    winSizeObj.width = winWidth;
			    winSizeObj.height = winHeight;
			    
			    return winSizeObj;
		  }