/**
 * Default.js
 */


function launch_player(url, width, height, start, end)
{
	if (width == undefined)
		width = 315;
	if (height == undefined)
		height = 165;	
	
	var options = 'width=' + width + 
		', height=' + height + 
		', left=' + (screen.availWidth - width) + 
		', top=' + (screen.availHeight - height) + 
		', toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=yes, scrollbars=no';
		
	if (start != undefined)
		url += '/start:' + start;
	if (end != undefined)
		url += '/end:' + end;
	
	window.open(url, '', options);
}

function launch_getflash(url, width, height)
{
	if (width == undefined)
		width = 600;
	if (height == undefined)
		height = 500;	
	
	var options = 'width=' + width + 
		', height=' + height + 
		', toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=yes, scrollbars=yes';
	
	window.open(url, '', options);
}

function launch_quiz_paper(url, width, height)
{
	if (width == undefined)
		width = 600;
	if (height == undefined)
		height = 500;	
	
	var options = 'width=' + width + 
		', height=' + height + 
		', toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=yes, scrollbars=yes';
	
	window.open(url, '', options);
}

function launch_book_print(url, width, height)
{
	if (width == undefined)
		width = 600;
	if (height == undefined)
		height = 500;	
	
	var options = 'width=' + width + 
		', height=' + height + 
		', toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=yes, scrollbars=yes';
	
	window.open(url, '', options);
}

function launch_member_info(url, width, height)
{
	if (width == undefined)
		width = 370;
	if (height == undefined)
		height = 300;	
	
	var options = 'width=' + width + 
		', height=' + height + 
		', toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=yes, scrollbars=yes';
	
	window.open(url, '', options);
}

function launch_messages_info(url, width, height)
{
	if (width == undefined)
		width = 370;
	if (height == undefined)
		height = 300;	
	
	var options = 'width=' + width + 
		', height=' + height + 
		', toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=yes, scrollbars=yes';
	
	window.open(url, '', options);
}

function login()
{
	if (confirm('로그인이 필요한 서비스입니다.\n로그인 하시겠습니까?')) {
		window.location = location.protocol + '//' + location.host + '/member/login?from=' + encodeURIComponent(location.href);
		return true;
	}
	else {
		return false;
	}
}

function truncate_with_comment(comment_class_name, space)
{
	if (!space)
		space = 0;
	
	$$('div.' + comment_class_name).each(function(comment) {
		var parent = comment.up();
		var bound_right = parent.cumulativeOffset().left + parent.getWidth();
		var comment_right = comment.cumulativeOffset().left + comment.getWidth();
		
		if (comment_right > bound_right)
		{
			var title = comment.previous();
			var width = parent.getWidth() - comment.getWidth() - 5 - space;
			title.setStyle({cssFloat: 'left', width: width + 'px'});
			comment.setStyle({cssFloat: 'right', lineHeight: title.getHeight() + 'px'});
		}
	});
}
