function openBrWindow(theURL,winName,features) {
	window.open(theURL,winName,features);
}
function goToUrl(url)
{
	document.location.href=url;
}


function img_resize(MAX_WIDTH,MAX_HEIGHT,id)
{
	obj = eval('document.images.Oneshow' + id);

	obj2 = new Image();
	obj2.src = obj.src;

	var w = obj2.width;
	var h = obj2.height;

	if ( w > MAX_WIDTH && h > MAX_HEIGHT)
	{
		per = MAX_WIDTH / w;

		w = MAX_WIDTH;
		h = h * per;

		if( h > MAX_HEIGHT )
		{
			per = MAX_HEIGHT / h;
			w = w * per;
			h = MAX_HEIGHT;
		}

		obj.width = w;
		obj.height = h;

	}
	else if ( w > MAX_WIDTH)
	{
		obj.width = MAX_WIDTH;

		per = MAX_WIDTH / w;
		obj.height = h * per;
	}
	else if ( h > MAX_HEIGHT)
	{
		obj.height = MAX_HEIGHT;

		per = MAX_HEIGHT / h;
		obj.width = w * per;
	}
	else
	{
		obj.width = w;
		obj.height = h;
	}	
}

//*** ContextMenu °ü·Ã
function initiate()
{
}

var nowContext = 0;
var nowOuser = 0;
function show_context(userCode,Ouser)
{
	nowOuser = Ouser;	
	nowContext = userCode;	
	javascript:cnj_menu_layer('cnj_id_layer');
}
function go_context1()
{	
	a_win = window.open("/hompy/congaltan_list.aspx?ix=" + nowOuser + "&code=" + nowContext,"Hompy", "width=850 ,height=620,resizable=no,scrollbars=no");
	a_win.focus();
}
function go_context3()
{
	
	a_win = window.open("/hompy/congaltan_list.aspx?ix=" + nowOuser + "&code=" + nowContext,"Hompy", "width=840 ,height=600,resizable=no,scrollbars=no");
	a_win.focus();
}
function go_context2()
{
	
	a_win = window.open("/hompy/hompy_guestbook.aspx?ix=" + nowOuser + "&code=" + nowContext,"Hompy", "width=840 ,height=600,resizable=no,scrollbars=no");
	a_win.focus();
}
function go_context4()
{
	
	a_win = window.open("/include/control/sendMessage.aspx?ix=" + nowOuser + "&code=" + nowContext,"popmessage", "width=325 ,height=305,resizable=no,scrollbars=no");
	a_win.focus();
}
function goChanggo(code,i)
{
	if (i==null)
	{
		i=0;
	}
	a_win = window.open("/hompy/congaltan_list.aspx?ix=" + i + "&code=" + code,"Hompy", "width=850 ,height=630,resizable=no,scrollbars=no");
	a_win.focus();
}
function deleteComment(uid,sub_uid,name1,name2,refer)
{
	goToUrl("/defaultModule/deleteComment.aspx?name1=" + name1 + "&name2=" + name2 + "&uid=" + uid + "&sub_uid=" + sub_uid + refer);
}
function modifyContent(modpage,uid,refer)
{
	goToUrl(modpage + "?uid=" + uid + refer);
}
function deleteContent(uid,name1,name2,refer)
{
	goToUrl("/defaultModule/deleteContent.aspx?name1=" + name1 + "&name2=" + name2 + "&uid=" + uid + refer);
}

String.prototype.trim = function() {

return this.replace(/^\s*(\b.*\b|)\s*$/, "$1"); // ¹®ÀåÀÇ ¾Õ°ú µÚÀÇ °ø¹é Á¦°Å

}

function length_count(txtform)
{
var str_character;
var int_char_count;
var int_contents_length;

int_char_count = 0;

int_contents_length = txtform.value.length;


for(k=0; k < int_contents_length; k++)
{
	str_character = txtform.value.charAt(k);
	if(escape(str_character).length > 4)
		int_char_count += 2; 
	else
		int_char_count++;
}

return int_char_count;
}

function whenSearch(obj)
{
	if(length_count(obj.searchTxt) <= 2)
	{
		alert("°Ë»ö¾îÀÇ ±æÀÌ°¡ ³Ê¹« Âª½À´Ï´Ù.  ");
		return false;
	}
	
	return true;	
}

function whenComment(obj)
{
	obj.commentTxt.value = obj.commentTxt.value.trim();
	
	if(!obj.commentTxt.value)
	{
		alert("¸ÕÀú µ¡¸»À» ÀÔ·ÂÇÏ¼¼¿ä.  ");
		return false;
	}
	
	return true;	
}

function bigImg(locate)
{
	a_win = window.open("/defaultModule/bigImg.asp?img=" + locate,"bigimg", "width=100,height=80,resizable=auto,scrollbars=auto");
	a_win.focus();
}

function point2congaltan()
{
	a_win = window.open("/shop/point2congaltan.aspx","point2cong", "scrollbars=yes,resizable=yes,width=500,height=360");
	a_win.focus();
}

function helpGuide(id)
{
	switch(id)
	{
		case 1:
			a_win = window.open("/service/congaltanguide.aspx","guide1", "scrollbars=yes,resizable=yes,width=750,height=550");
			break;
		case 2:
			a_win = window.open("/service/pointguide.aspx","guide1", "scrollbars=yes,resizable=yes,width=750,height=550");
			break;
	}	
}

function viewMessage(code)
{
	nowContext = code;
	a_win = window.open("/hompy/message_list.aspx?code=" + nowContext,"Hompy", "width=850 ,height=600,resizable=no,scrollbars=no");
	a_win.focus();
}


//** context ¸Þ´º **//

function doBlink() {
var blink = document.all.tags("BLINK")
for (var i=0; i<blink.length; i++)
blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "" 
}
function startBlink() {
if (document.all)
setInterval("doBlink()",500)
}
window.onLoad = startBlink();


var xdistance=0;
var ydistance=0;
var timer;
var x,y;
var open_submenu;
var close_submenu;
var activated=false;

function initiate() {        
	if (document.all) {
		close_submenu=eval("document.all.empty_layer.style");
		activated=true;
		
	}
	if (document.layers) {
		close_submenu=eval("document.empty_layer");
		activated=true;
	}
}

var on_layser3 = false;

var onMouse_layser3 = false;

var parentX=0;
var parentY=0;
function cnj_menu_layer(cnj_menu) {
	if (activated) {   
		if (document.all) {
			close_submenu.visibility="hidden";
			close_submenu=eval("document.all."+cnj_menu+".style");
			open_submenu=eval("document.all."+cnj_menu+".style");
			parentY = y+ydistance;
			parentX = x+xdistance;
			open_submenu.posTop=parentY;
			open_submenu.posLeft=parentX;
			open_submenu.visibility="visible";
		}
		if (document.layers) {
			close_submenu.visibility="hidden";
			close_submenu=eval("document."+cnj_menu);
			open_submenu=eval("document."+cnj_menu);		
			parentY = y+ydistance;
			parentX = x+xdistance;
			open_submenu.top=parentY;
			open_submenu.left=parentX;
			open_submenu.visibility="visible";
		}
	}
}


function hidesubmenu() {
	close_submenu.visibility="hidden";
	open_submenu.visibility="hidden";
}


function handlerMM(e){
	x = (document.layers) ? e.pageX : document.body.scrollLeft+event.clientX;
	y = (document.layers) ? e.pageY : document.body.scrollTop+event.clientY;
}

function body_click(){
	
	if (event.srcElement.tagName != "A"){
		cnj_menu_layer('empty_layer');
		return false;
	}	
}


function go_link(url){
	window.open(url, '','');
}

if (document.layers){
document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove=handlerMM;

window.onload=initiate;


function imgover(obj)
{
	var orignSrc = obj.src;
	var fileName = orignSrc.substring(0,orignSrc.length-4);
	var ext = orignSrc.substring(orignSrc.length-4,orignSrc.length);
	
	obj.src= fileName + "Over" + ext;
}

function imgout(obj)
{
	var orignSrc = obj.src;
	var fileName = orignSrc.substring(0,orignSrc.length-4);
	var ext = orignSrc.substring(orignSrc.length-4,orignSrc.length);
	
	fileName = fileName.substring(0,fileName.length-4);

	obj.src= fileName + ext;
}

