function showM(m)
{
	var box = getId('subMenuBox'+m);
	if(box) box.style.display = 'block';
}
function hideM(m)
{
	var box = getId('subMenuBox'+m);
	if(box) box.style.display = 'none';
}
function layoutLogCheck(f)
{
	if (f.id.value == '')
	{
		alert('아이디를 입력해 주세요.');
		f.id.value='';
		f.id.focus();
		return false;
	}
	if (f.pw.value == '')
	{
		alert('패스워드를 입력해 주세요.');
		f.pw.value='';
		f.pw.focus();
		return false;
	}
}
function layoutRMBpw(ths)
{
	if (ths.checked == true)
	{
		if (!confirm('\n\n패스워드정보를 저장할 경우 다음접속시 \n\n패스워드를 입력하지 않으셔도 됩니다.\n\n그러나, 개인PC가 아닐 경우 타인이 로그인할 수 있습니다.     \n\nPC를 여러사람이 사용하는 공공장소에서는 체크하지 마세요.\n\n정말로 패스워드를 기억시키겠습니까?\n\n'))
		{
			ths.checked = false;
		}
	}
}

function twtOver(target,st)
{
	//$("#sub_"+target).show();
	if(st == 2)
	{
		$("#top_"+target).css('background-color','#FFFFCC');
	}
	else
	{
		$("#top_"+target).css('background-color','#eeeeee');
	}
}

function twtOut(target,st)
{
	//$("#sub_"+target).hide();
	$("#top_"+target).css('background-color','#ffffff');
}


function best_price_display()
{
	var url = 'http://json2.twtlink.co.kr/_tmp/json/best_price.php?callback=?';
	var html = '';
   // $('#best_price').empty();
	$("#best_price").html("<div style='margin:5px 0 0 5px'><img src='/layouts/default2/image/spinner.gif' border='0'></div>");

	$(document).ready(function(){
	$.ajax({
		type: "GET",
		url: url,
		dataType: "json",
		success: function(data) {
			html ='<table width="100%" style="padding:0px;margin:0" cellspacing="0" cellpadding="0" border="0">';
			html +='<col width="8">';
			html +='<col width="140">';
			html +='<col width="*">';
			$.each(data, function(i, post){

                html += '<tr>'+
					'<td><img src="/layouts/default2/image/dot1.gif" width="8" height="7" border="0"></td>'+		
					'<td height="20"><a href="/click/c.php?type=list&v='+post.t_num+'&ch=leftweekbest" target="_blank">'+post.t_title+'</a></td>'+
					'<td align="right"><span style="color:red">'+post.t_live_price+'</span> 원</td></tr>';
			});	
			html +='</table>';

			$('#best_price').html(html);	
		}
	});	
	});
}

function best_price_top_display(v)
{
    var html='';
	$("#best_today").removeClass();	
	$("#best_yesterday").removeClass();	
	$("#best_week").removeClass();	
	$("#best_month").removeClass();		
	$("#best_ipad").removeClass();	
	$("#best_camera").removeClass();	
	$("#best_ipod").removeClass();	
	$("#best_notebook").removeClass();	
	$("#best_nintendo").removeClass();	
	$("#best_iphone").removeClass();	
	$("#best_galaxy").removeClass();	
	$("#best_monitor").removeClass();	

	$("#best_"+v).addClass("selected");

	var url = 'http://json2.twtlink.co.kr/_tmp/json/best_price_top_'+v+'.php?callback=?';
	$('#best_price_top').empty();
	$("#best_price_top").html("<div style='margin:5px 0 0 5px'><img src='/layouts/default2/image/spinner.gif' border='0'></div>");

	if(v == 'month')
	{
		html = "<iframe name='ads_frame' width='100%' height='190' frameborder='0' src='http://banner.twtlink.co.kr/package_ads/package_ads.php?n_pub=3422&n_pid=3&n_w=765&n_h=190&n_ref=http://allauction.co.kr' marginwidth='0' marginheight='0' vspace='0' hspace='0' allowtransparency='true' scrolling='no'></iframe>";
		$('#best_price_top').html(html);
	}
	else
	{
	
	//html = '<div style="height:auto;margin:0;padding:0">';
	$(document).ready(function(){
	$.ajax({
		type: "GET",
		url: url,
		dataType: "json",
		success: function(data) {
			$.each(data, function(i, post){
			if(i<=5)
			{
			html += '<div style="margin-top:15px;margin-left:7px;float:left;text-align:center;background-color:#fff">'+
			'<div><a href="/click/c.php?type=list&v='+post.t_num+'&ch=topgoodsphoto" target="_blank"><img src="'+post.t_image_url+'" width="110" height="92" border="0" style="padding:3px;border:#ccc solid 1px"></a></div>'+
			'<div style="margin:5px 0 0 0"><a href="/click/c.php?type=list&v='+post.t_num+'&ch=topgoodsphoto" target="_blank">'+post.t_title+'</a></div>'+
			'<div style="margin:4px 0 0 0"><span style="font-size:12px;color:#777;font-weight:bold"><s>'+post.t_goods_price+'</s></span>원</div>'+
			'<div style="margin:4px 0 0 0"><span style="font-size:12px;color:red;font-weight:bold">'+post.t_live_price+'</span>원  <img src="/layouts/default2/image/icon_down.gif"> <span style="font-weight:bold;color:blue">'+post.t_success_per+'</span>%</div>'+
			'<!-- div style="margin:4px 0 0 0"><a href="/click/c.php?type=list&v='+post.t_num+'&ch=topgoodsphoto" target="_blank">'+post.t_merchant_name+'</a></div -->'+
			'</div>';
			}
			});	
			//html += '</div>';
			$('#best_price_top').html(html);
			//$("#best_price_top_wait").hide();
		}
	});	
	});

	}
}

function best_price_top_display_back(v)
{
    var html='';
	$("#best_today").removeClass();	
	$("#best_yesterday").removeClass();	
	$("#best_week").removeClass();	
	$("#best_month").removeClass();		
	$("#best_ipad").removeClass();	
	$("#best_camera").removeClass();	
	$("#best_ipod").removeClass();	
	$("#best_notebook").removeClass();	
	$("#best_nintendo").removeClass();	
	$("#best_iphone").removeClass();	
	$("#best_galaxy").removeClass();	
	$("#best_monitor").removeClass();	

	$("#best_"+v).addClass("selected");

	var url = 'http://json2.twtlink.co.kr/_tmp/json/best_price_top_'+v+'.php?callback=?';
	$('#best_price_top').empty();
	$("#best_price_top").html("<div style='margin:5px 0 0 5px'><img src='/layouts/default2/image/spinner.gif' border='0'></div>");
	//html = '<div style="height:auto;margin:0;padding:0">';
	$(document).ready(function(){
	$.ajax({
		type: "GET",
		url: url,
		dataType: "json",
		success: function(data) {
			$.each(data, function(i, post){
			if(i<=5)
			{
			html += '<div style="margin-top:15px;margin-left:7px;float:left;text-align:center;background-color:#fff">'+
			'<div><a href="/click/c.php?type=list&v='+post.t_num+'&ch=topgoodsphoto" target="_blank"><img src="'+post.t_image_url+'" width="110" height="92" border="0" style="padding:3px;border:#ccc solid 1px"></a></div>'+
			'<div style="margin:5px 0 0 0"><a href="/click/c.php?type=list&v='+post.t_num+'&ch=topgoodsphoto" target="_blank">'+post.t_title+'</a></div>'+
			'<div style="margin:4px 0 0 0"><span style="font-size:12px;color:#777;font-weight:bold"><s>'+post.t_goods_price+'</s></span>원</div>'+
			'<div style="margin:4px 0 0 0"><span style="font-size:12px;color:red;font-weight:bold">'+post.t_live_price+'</span>원  <img src="/layouts/default2/image/icon_down.gif"> <span style="font-weight:bold;color:blue">'+post.t_success_per+'</span>%</div>'+
			'<!-- div style="margin:4px 0 0 0"><a href="/click/c.php?type=list&v='+post.t_num+'&ch=topgoodsphoto" target="_blank">'+post.t_merchant_name+'</a></div -->'+
			'</div>';
			}
			});	
			//html += '</div>';
			$('#best_price_top').html(html);

			//$("#best_price_top_wait").hide();
		}
	});	
	});
}

function best_goods_top_display()
{
	var url = 'http://json2.twtlink.co.kr/_tmp/json/best_goods.php?callback=?';
	var html = '';
	var cnt = 1;
	$("#best_goods_top").html("<div style='margin:5px 0 0 5px'><img src='/layouts/default2/image/spinner.gif' border='0'></div>");
	$(document).ready(function(){
	$.ajax({
		type: "GET",
		url: url,
		dataType: "json",
		success: function(data) {
			html ='<table width="100%" style="padding:0px;margin:0" cellspacing="0" cellpadding="0" border="0">';
			html +='<col width="24">';
			html +='<col width="132">';
			html +='<col width="8">';
			html +='<col width="*">';
			$.each(data, function(i, post){
				if(i<=7)
				{
				
					if(i<=2)
					{
						rank_image = 'r_a_'+cnt;
					}
					else
					{
						rank_image = 'r_'+cnt;
					}
					html +='<tr>'+
					'<td align="center"><img src="/layouts/default2/image/'+rank_image+'.gif" border="0"></td>'+		
					'<td width="160" height="22"><a href="/click/c.php?type=list&v='+post.t_num+'&ch=topgoodsrank" target="_blank">'+post.t_title+'</a></td>'+
					'<td><img src="/layouts/default2/image/icon_up.gif" align="absmiddle"></td>'+
					'<td><span style="font-size:11px;color:red">'+post.t_rand_num+'</span></td>'+
					'</tr>';
					cnt++;
				}
			});	
			html +='</table>';
			$("#best_goods_top").html(html);
		}
	});	
	});
}

// 낙찰후기
function review_display()
{
    var html='';
	var url = 'http://json2.twtlink.co.kr/_tmp/json/review.php?callback=?';
	$('#review_left').empty();
	$("#review_left").html("<div style='margin:5px 0 0 5px'><img src='/layouts/default2/image/spinner.gif' border='0'></div>");
	
	$(document).ready(function(){
	$.ajax({
		type: "GET",
		url: url,
		dataType: "json",
		success: function(data) {
			//html ='<table width="100%" style="padding:0px;margin:0" cellspacing="0" cellpadding="0" border="0">';
			//html +='<col width="110">';
			//html +='<col width="110">';
			$.each(data, function(i, post){
				if(i<=5)
				{
					if(i%2==0 && i!=0) html +='<div style="clear:both"></div>';
					html +='<div style="width:91px;height:105px;float:left;text-align:center"><div><a href="?m=auctioncomment&p=1&type=view&c=15&v='+post.t_num+'"><img src="'+post.t_thumb_url+'" border="0" width="70" height="60"></a></div><div style="font-size:11px;margin:3px 0 0 0"><a href="?m=auctioncomment&p=1&type=view&c=15&v='+post.t_num+'">'+post.t_title+'<br><font color="red">'+post.t_live_price+'</font>원</a></div></div>';
				}
			});
			$('#review_left').html(html);
		}
	});	
	});
}

// rank widget 형태
function rank_display(v)
{
    var html='';
	var json_file = '';
	$("#rank_today").removeClass();	
	$("#rank_yesterday").removeClass();	
	$("#rank_week").removeClass();	
	$("#rank_total").removeClass();	

	if(v == 'today')
	{
		$("#rank_today").addClass("selected");
		json_file = 'rank_today';
	}
	else if(v == 'yesterday')
	{
		$("#rank_yesterday").addClass("selected");
		json_file = 'rank_yesterday';
	}
	else if(v == 'week')
	{
		$("#rank_week").addClass("selected");
		json_file = 'rank_week';
	}	
	else if(v == 'total')
	{
		$("#rank_total").addClass("selected");
		json_file = 'rank_total';
	}
	else
	{
		$("#rank_today").addClass("selected");
		json_file = 'rank_today';
	}

	var url = 'http://json2.twtlink.co.kr/_tmp/json/'+json_file+'.php?callback=?';	
	$('#siterank').empty();
	$("#siterank").html("<div style='margin:5px 0 0 5px'><img src='/layouts/default2/image/spinner.gif' border='0'></div>");
	
	$(document).ready(function(){
	$.ajax({
		type: "GET",
		url: url,
		dataType: "json",
		success: function(data) {
				html = '<div style="height:253px;margin:6px 0 0 0;text-align:left"><table style="padding:0px;margin:0px">';
			$.each(data, function(i, post){
				if(i<=5)
				{
				html +='<tr>'+
					'<td width="17" height="16" align="center"><img src="/layouts/default2/image/r_'+post.t_rank+'.gif" border="0"></td>'+
					'<td width="112"><a href="/click/c.php?type=event&site='+post.t_merchant_id+'&ch=rankwidget" target="_blank"><font style="font-weight:bold;color:#666">'+post.t_merchant_name+'</font></a></td>'+
					'<td><a href="/click/c.php?type=event&site='+post.t_merchant_id+'&ch=rankwidget" target="_blank"><img src="/modules/auctionsite/theme/_pc/default/image/'+post.t_merchant_id+'_logo_60.gif" width="37" border="0" style="padding:2px;border:1px solid #ddd;"></a></td>'+
					'</tr>';
				}
			});	
			html += '</table></div>';
			$('#siterank').html(html);
		}
	});	
	});
}

// inkey (내부 키워드 순위)
function inkey_display()
{
    var html='';
	var rank_image = '';
	var cnt = 1;
	var url = 'http://json2.twtlink.co.kr/_tmp/json/rank_keyword.php?callback=?';
	$('#inkey').empty();
	$("#inkey").html("<div style='margin:5px 0 0 5px'><img src='/layouts/default2/image/spinner.gif' border='0'></div>");
	
	$(document).ready(function(){
	$.ajax({
		type: "GET",
		url: url,
		dataType: "json",
		success: function(data) {
			html ='<table width="100%" style="padding:0px;margin:0" cellspacing="0" cellpadding="0" border="0">';
			html +='<col width="35">';
			html +='<col width="110">';
			html +='<col width="13">';
			html +='<col width="*">';
			$.each(data, function(i, post){
				if(i<=2)
				{
					rank_image = 'r_a_'+cnt;
				}
				else
				{
					rank_image = 'r_'+cnt;
				}
				html +='<tr>'+
				'<td align="center"><img src="/layouts/default2/image/'+rank_image+'.gif" border="0"></td>'+		
				'<td height="22"><a href="/?r=home&c=&m=auctionmeta&type=all&keyword='+post.keyword_full+'">'+post.keyword+'</a></td>'+
				'<td><img src="/layouts/default2/image/icon_up.gif" align="absmiddle"></td>'+
				'<td align=right><span style="font-size:11px;color:#555;margin-right:3px;">'+post.hit+'건</span></td>'+
				'</tr>';
				cnt++;
			});	
			html +='</table>';
			$('#inkey').html(html);		
		}
	});	
	});
}

// counter
function counter_display()
{
    var html='';
    var cnt_title='';
	var url = 'http://json2.twtlink.co.kr/_tmp/json/counter.php?callback=?';
	$('#counter').empty();
	$("#counter").html("<div style='margin:5px 0 0 5px'><img src='/layouts/default2/image/spinner.gif' border='0'></div>");
	
	$(document).ready(function(){
	$.ajax({
		type: "GET",
		url: url,
		dataType: "json",
		success: function(data) {
			$.each(data, function(i, post){
				if(i<=0)
				{
					cnt_title = "오늘방문자";
				}
				else
				{
					cnt_title = "어제방문자";
				}
					html +='<div style="padding:3px">'+cnt_title+' : '+post.hit+' 명</div>';				
			});	
			$('#counter').html(html);
		}
	});	
	});
}


// 리뷰 플로팅 
function review_right_display()
{
    var html='';
	var url = 'http://json2.twtlink.co.kr/_tmp/json/review_best.php?callback=?';
	$('#best_review_right').empty();
	$("#best_review_right").html("<div style='margin:60px 0 0 5px'><img src='/layouts/default2/image/spinner.gif' border='0'></div>");
	
	$(document).ready(function(){
	$.ajax({
		type: "GET",
		url: url,
		dataType: "json",
		success: function(data) {

			html +='<div style="margin-top:65px;margin-left:5px;padding:0px;"><img src="/layouts/default2/image/right_best01.gif" border="0"></div><div style="margin-left:5px;width:90px;height:375px;padding:0px;border-left:#ccc solid 1px;border-right:#ccc solid 1px;border-bottom:#ccc solid 1px">';
			$.each(data, function(i, post){
				if(i<=4)
				{
					html +='<div style="height:70px;text-align:center"><a href="/click/c.php?type=community&site='+post.t_merchant_id+'&v='+post.t_num+'&ch=reviewfloating" target="_blank"><img src="'+post.t_thumb_url+'" border="0" width="60" height="50" style="padding:2px;border:#ccc solid 1px"></a><br><span style="font-size:11px;line-height:1.4em"><a href="/click/c.php?type=community&site='+post.t_merchant_id+'&v='+post.t_num+'&ch=reviewfloating" target="_blank">'+post.t_title+'<br><font color="red">'+post.t_live_price+'</font>원</a></span></div>';
				}
			});	
			html +='</div>';
			/*
			html +='<div style="padding:0;width:90px;margin:5px 0 0 5px;height:90px;border:#ccc solid 1px;text-align:center">';
			html +='<div style="padding:0;margin:3px 0 0 0;"><font color=red><b>고비드 이벤트</b></font></div>';
			html +='<div style="padding:0;margin:3px 0 0 0"><a href="/click/c.php?type=join&site=gobid&ch=rightfloatingfree" target="_blank"><span style="font-size:12px">입찰권5개 + 5개<br>총10개 지급</span></a></div>';
			html +='<div style="padding:0;margin:3px 0 0 0;"><a href="/click/c.php?type=join&site=gobid&ch=rightfloatingfree" target="_blank"><img src="/layouts/default2/image/go_event2.gif" border="0"></a></div>'
			html +='</div>';
			*/

			$('#best_review_right').html(html);
		}
	});	
	});
}

// floating
var yScrollThumb;
var yMenuTop;
var LyScrollThumb;
var LyMenuTop;
var yscrollTopPos = 80;
var yScrollThumbPos = 950;

function CheckMenuPosition()
{
  //alert(document.body.scrollWidth);
  yScrollThumbPos = document.body.scrollWidth / 2;  
  yScrollThumb = (document.body.clientWidth-(document.body.clientWidth-yScrollThumbPos));
  if (yScrollThumb != $('#quick_menu').css('left'))
  {
    $('#quick_menu').css('left',yScrollThumb + "px");
  }

  if (document.documentElement && document.documentElement.scrollTop)
    yScrollThumb = document.documentElement.scrollTop + yscrollTopPos;
  else
    yScrollThumb = document.body.scrollTop + yscrollTopPos;

  yMenuTop = parseInt($('#quick_menu').css('top'), 10);

  if (yMenuTop == yScrollThumb)
  {
    TimeOutInterval = 500;
  }
  else
  {
    yMenuTop = ( yMenuTop + yScrollThumb) / 2;
    if ( yscrollTopPos >= yMenuTop)
    {
      $('#quick_menua').css('top',yscrollTopPos + "px");
      TimeOutInterval = 500;
    }
    else
    {
      $('#quick_menu').css('top',yMenuTop + "px");
      TimeOutInterval = 10;
    }
  }
  setTimeout ("CheckMenuPosition()", TimeOutInterval);
  $("#quick_menu").show();
}

function unload_popup() 
{
	
	if (event.clientX < 0 && event.clientY < 0) 
	{
		//window.open("http://allauction.co.kr/click/c.php?type=event&site=coolbay&ch=popup","_blank");
	}

/*
	if (self.screenTop > 8000)
	{
		window.open("http://allauction.co.kr/click/c.php?type=event&site=coolbay&ch=popup","_blank");
		// 브라우저 닫힘
    }
    else
    {
		if (document.readyState == "complete")
        {
            // 새로고침
        }
        else  if (document.readyState == "loading")
        {
	        // window.open("http://allauction.co.kr/click/c.php?type=event&site=coolbay&ch=popup","_blank");
		   // 다른 사이트로 이동
        }
	}
	*/
}

