var mouseX,mouseY,mouseID,mouseHOME;

function getMouseX(e) {
  e = e || window.event;
  var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
	return (e.pageX) ? e.pageX : scrollLeft + e.clientX;
}
function getMouseY(e) {
  e = e || window.event;
	var scrollTop = document.documentElement.scrollTop || document.body.scrollTop; 
	return (e.pageY) ? e.pageY : scrollTop + e.clientY;
}
function getMemberLayer(id,homepage,e)
{
	var x = getMouseX(e);
	var y = getMouseY(e);
	var layer = document.getElementById('member_layer');

	layer.style.top = y + 5 + 'px';
	layer.style.left = x - 10 + 'px';
	layer.style.display = 'block';

	if (location.href.indexOf('/home/') != -1||location.href.indexOf('/_system/') != -1) frames.action_frame.location.href = g_homepath + "mypage.php?a=mbr_layer&id=" + id;
	else frames.action_frame.location.href = "./_check.php?checkfile=mbrlayer&id=" + id;

	mouseX = x;
	mouseY = y;
	mouseID= id;
	mouseHOME = homepage;
}
function MemberLayerHide(e)
{
	var x = getMouseX(e);
	var y = getMouseY(e);
	if (x != mouseX || y != mouseY)
	{
		var layer = document.getElementById('member_layer');
		layer.style.display = 'none';
	}
}
function getMemberWin(que)
{
	getPopUpFlag(window.open(g_syspath + 'module/member/member.php?xsite=' + g_msite + '&id=' + que,'','left=0,top=0,width=800,height=630,status=yes,scrollbars=yes'));
}
function getMemberHome(url)
{
  if (url) window.open('http://'+url.replace('http:\/\/',''));
  else alert('홈페이지가 등록되지 않았습니다.   ');
}
function getEmailWin(domain,id)
{
	location.href = "mailto:" + id + "@" + domain;
}
function OpenZipcode(pwd,z1,z2,ad,ad1) 
{
	var gpwd = (pwd) ? pwd : '.';
	var url = gpwd+'/zipsearch/zipcode.php?zip1='+z1+'&zip2='+z2+'&address='+ad+'&address1='+ad1;
	window.open(url,'zip_win','width=460,height=550,statusbar=no,scrollbars=yes,toolbar=no');
}
function smOver(obj)
{
	obj.style.background='#007AD1';
	obj.style.color='#ffffff';
}
function smOut(obj)
{
	obj.style.background='#fafafa';
	obj.style.color='#000000';
}
function goUrl(url,opt)
{
	if (opt == "") {
	  location.href = url;
	}	else {
	  window.open(url , '' , opt);
	}
}
function reqChat(myid,userid)
{
	if (myid == '')
	{
		alert('로그인해 주세요.      ');
	}
	else {
		window.open(g_syspath + 'module/chat/chat.php?xsite=' + g_msite + '&a=mkroom&que=mantoman/main&callid='+userid,'','left=0,top=0,width=500,height=480,scrollbars=no,status=yes');
	}
}
function SendSms(name,num,path,module)
{
  module = module || 'youiwe';
	if (num == "")
	{
		alert("휴대폰 번호가 지정되지 않았습니다.        ");
	}
	else
	{
		var n = num.split('-');
		url = path+"module.php?module=sms/"+module+"&q=phone&mobile_1="+n[0]+"&mobile_2="+n[1]+""+n[2]+"&toname="+name;
		getPopUpFlag(window.open(url , '' , 'left=0,top=0,width=170,height=390,scrollbars=no,status=yes,resizable=no'));
	}
}
function UploadView(id,uid,ok,que)
{
	if (ok == '1')
	{
		getPopUpFlag(window.open(g_syspath + "module/upload/view.php?xsite=" + g_msite + "&id="+id+"&uid=" + uid + "&view=" + que , 'uploadviewwin', 'left=0,top=0,width=440,height=100,scrollbars=yes,status=yes'));
	}
	else {
		alert(g_errorcode010);
	}
}
function BbsArticleWin(url,w,h)
{
	getPopUpFlag(window.open(url , 'articlewin' , 'left=0,top=0,width='+w+',height='+h+',scrollbars=yes,status=yes'));
}
function imgpreview1(obj)
{
	var KimsonPopupCheck = getPopUpFlag(window.open('','iwin','left=0,top=0,width=100,height=100,scrollbars=yes,status=yes'));
	KimsonPopupCheck.document.write("<html><head><title>미리보기<\/title>\<script\>function getImageWin(ob){window.resizeTo(ob.width+27,ob.height+58);document.body.innerHTML=\"<table cellspacing=0 cellpadding=3 background='"+obj+"' width='\"+ob.width+\"' height='\"+ob.height+\"'><tr><td align=right valign=bottom><table cellspacing=0 cellpadding=0><tr><td style='font-size:9pt;'>" + g_watermark + "<\/td><td width='" + g_waterright + "' height='" + g_waterbottom + "'><\/td><\/tr><\/table><\/td><\/tr><\/table>\";}\<\/script\><\/head><body leftmargin=0 topmargin=0 onclick='self.close()' oncontextmenu='return false'><img src='"+obj+"' onload=\"getImageWin(this)\"><\/body><\/html>");
}
function imgpreview2(id,uid,e)
{
  try{
  e = e || window.event;
  var w = e.target ? e.target.width : e.srcElement.width;
  if (w < 670) return false;
	}catch(e){}
	var KimsonPopupCheck = getPopUpFlag(window.open('','iwin','left=0,top=0,width=100,height=100,scrollbars=yes,status=yes'));
	KimsonPopupCheck.document.write("<html><head><title>미리보기<\/title>\<script\>function getImageWin(ob){window.resizeTo(ob.width+30,ob.height+90);document.body.innerHTML=\"<table cellspacing=0 cellpadding=3 background='" + g_syspath + "include/image.view.php?id="+id+"&uid="+uid+"' width='\"+ob.width+\"' height='\"+ob.height+\"'><tr><td align=right valign=bottom><table cellspacing=0 cellpadding=0><tr><td style='font-size:9pt;'>" + g_watermark + "<\/td><td width='" + g_waterright + "' height='" + g_waterbottom + "'><\/td><\/tr><\/table><\/td><\/tr><\/table>\";}\<\/script\><\/head><body leftmargin=0 topmargin=0 onclick='self.close()' oncontextmenu='return false'><img src='" + g_syspath + "include/image.view.php?id="+id+"&uid="+uid+"' onload=\"getImageWin(this)\"><\/body><\/html>");
}
function showInvWin(url)
{
	getPopUpFlag(window.open(url , 'articlewin' , 'left=0,top=0,width=800,height=600,scrollbars=yes,status=yes'));
}
function zoom(uid)
{
	window.open(g_syspath + 'module/shop/zoom.php?uid=' + uid,'','left=0,top=0,width=480,height=555,scrollbars=no,status=yes');
}
function getTpriceLoyaltyJs(tprice,val)
{
	var tmpval = val ? val : 1; 
	return parseInt(Math.floor(parseInt(tprice)/tmpval ) * tmpval);
} 
function getLoginNeed(url)
{
	if(confirm('로그인하셔야 이용하실 수 있습니다.        \n\n지금 로그인하시겠습니까?'))
	{
	  url = url ? escape(url) : escape(location.href);
		location.href = "./login.php?referer=" + escape(url);
	}
}
function getDownInfo(uid)
{
	window.open(g_syspath + 'module/upload/info.php?uid=' + uid,'','left=0,top=0,width=480,height=555,scrollbars=yes,status=yes');
}
function getMessenger(id)
{
	window.open(g_syspath + 'module/messenger/index.php?id=' + id,'','left=0,top=0,width=550,height=650,scrollbars=no,status=yes,resizable=yes');
}
function getFullScreen(url)
{
  if(url) {
	  getPopUpFlag(window.open(url , 'fullscreen' , 'left=0,top=0,width='+screen.availWidth+',height='+screen.availHeight+',fullscreen=yes,scrollbars=yes'));
	} else {
	  this.moveTo(0,0);
    resizeTo(screen.availWidth,screen.availHeight);
	}
}
function getPopWin(url,w,h)
{
  w = w || 600;
  h = h || 800;
	window.open(url , 'popwin' , 'left=0,top=0,width='+w+',height='+h+',scrollbars=no,resizable=yes');
}

