function getBounds(tag) 
{ 
	var ret = new Object(); 
	if(tag.getBoundingClientRect()) { 
		var rect = tag.getBoundingClientRect(); 
		ret.left = rect.left + (window.pageXOffset|| document.documentElement.scrollLeft || document.body.scrollLeft);
		if( navigator.appVersion.indexOf("MSIE 6") > -1)       // 브라우저 버전 IE6 일경우
			ret.left -= 2;

		ret.top = rect.top + (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop); 
		ret.width = rect.right - rect.left; 
		ret.height = rect.bottom - rect.top; 
	} else { 
		var box = document.getBoxObjectFor(tag); 
		ret.left = box.x; 
		ret.top = box.y; 
		ret.width = box.width; 
		ret.height = box.height; 
	} 
	return ret; 
}

function FooterSetting()
{
	var screenHeight = 0;
	var screenWidth = 0;
	/*
	if (document.documentElement && document.documentElement.scrollWidth) {
		screenWidth = document.documentElement.scrollWidth;
		screenHeight = document.documentElement.scrollHeight;
	}
	else if (document.body.scrollWidth) {
		screenWidth = document.body.scrollWidth;
		screenHeight = document.body.scrollHeight;
	}
	*/
	if (document.getElementById('PostBody') == null || document.getElementById('Footer') == null)
		return;

	var rect = getBounds(document.getElementById('PostBody'));
	screenHeight = rect.height;

	var height = 0;
	if (window.innerHeight) 
	{
		height = window.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight) {
		height = document.documentElement.clientHeight;
	}
	else if (document.body.clientHeight) {
		height = document.body.clientHeight;
	}

	//alert('screenHeight' + screenHeight + 'height' + height);
	if (height - 155 < screenHeight)
		document.getElementById('Footer').className = 'Bottom background';
	else
		document.getElementById('Footer').className = 'Bottom background FoooterFix';
}

var Close_flag = false;
function StarterMenuVisible(flag)
{
	if (flag == true)
	{
		Close_flag = true;
		document.getElementById('StarterMenu').style.display = '';
		document.getElementById('Top_IdArrow').innerHTML = '▲';
	}
	else
	{
		document.getElementById('StarterMenu').style.display = 'none';
		document.getElementById('Top_IdArrow').innerHTML = '▼';
	}
}
function StarterMenuToggle()
{
	if (document.getElementById('StarterMenu').style.display == 'none')
	{
		Close_flag = true;
		document.getElementById('StarterMenu').style.display = '';
		document.getElementById('Top_IdArrow').innerHTML = '▲';
	}
	else
	{
		document.getElementById('StarterMenu').style.display = 'none';
		document.getElementById('Top_IdArrow').innerHTML = '▼';
	}
}

function StarterMenuClose()
{
	if (Close_flag == false)
	{
		document.getElementById('StarterMenu').style.display = 'none';
		document.getElementById('Top_IdArrow').innerHTML = '▼';
	}
	Close_flag = false;
}


function ismaxlength(obj){

}


function Post_Checker()
{
	Edit_Checker('Post_Editor', 'PostLength');
	return EditKeyDown(event, 'Post_Editor', 'PostLength', ajaxPostSend);
}

function Post_Clicked()
{
	return Submit_Post('Post_Editor', 'PostLength', ajaxPostSend);
}

function SetList_MyCast()
{
	post_loadingText = 
		'<div class="NoPost" style="margin:100px;text-align:center;">'+
		'<div class="NoPostSubject" style="font-size:20px;font-weight:bold;color:#666666;margin-bottom:20px;">Wait a minute!</div>'+
		'<div class="NoPostDescription" style="color:#AAAAAA;">Now loading cast of this page.</div>'+
		'</div>';

	FooterSetting();

	document.getElementById('PM_MyCast').className = 'Profile_Menu_Selected';
	document.getElementById('PM_NewsFeed').className = 'Profile_Menu';

	document.getElementById('update_btn').onclick = update_post;

	post_count = 0;
	update_post(); // FooterSetting(); 내부적으로 실행됨
}
function SetList_NewsFeed()
{
	post_loadingText = 
		'<div class="NoPost" style="margin:100px;text-align:center;">'+
		'<div class="NoPostSubject" style="font-size:20px;font-weight:bold;color:#666666;margin-bottom:20px;">Wait a minute!</div>'+
		'<div class="NoPostDescription" style="color:#AAAAAA;">Now loading cast of this page.</div>'+
		'</div>';

	FooterSetting();

	if (document.getElementById('PM_MyCast') != null)
	{
		document.getElementById('PM_MyCast').className = 'Profile_Menu';
		document.getElementById('PM_NewsFeed').className = 'Profile_Menu_Selected';

		document.getElementById('update_btn').onclick = update_news;
	}

	post_count = 0;
	update_news(); // FooterSetting(); 내부적으로 실행됨
}

function update_post()
{
	update_PostList(user_id, 5, 'post');
}
function update_news()
{
	update_PostList(user_id, 5, 'news');
}

function init()
{
	createRequest();
	SetList_MyCast();

	document.onclick = StarterMenuClose;
	window.onresize = FooterSetting;
	document.getElementById('Post_Editor').onkeydown = Post_Checker;
	document.getElementById('Post_Editor').onkeypress = Post_Checker;
	document.getElementById('Post_Editor').onkeyup = Post_Checker;

	document.getElementById('PostSubmit').onclick = Post_Clicked;

	document.getElementById('PM_MyCast').onclick = SetList_MyCast;
	document.getElementById('PM_NewsFeed').onclick = SetList_NewsFeed;
}


