

function OfflineStore(val,seq)
{
	var mypage = document.getElementById("mypage")
	var mypage_bg = document.getElementById("mypage_bg")
	if (val == "show")
	{	
		OfflineStoreIndex();
		OfflineStoreList(1);
		//OfflineStoreDetail(seq);
		mypage.style.display = "";
		mypage_bg.style.display = "";
	}
	else
	{
		mypage.style.display = "none";
		mypage_bg.style.display = "none";
	}
}


function OfflineStoreIndex()
{
	var mypage = document.getElementById("mypage");
	
	mypage.innerHTML = 

		"<table width=100% border=0 cellspacing=0 cellpadding=0 background=/img/right/detail_topbg.gif >"
		+"  <tr>"
		+"	<td height=25 align=right style=padding-right:11px>"
		+"	<a onMouseOut=MM_swapImgRestore() onMouseOver=MM_swapImage('close','','/img/right/btn_close_hov.gif',1)>"
		+"	<img src=/img/right/btn_close.gif name=close width=14 height=14 border=0 onclick=javascript:OfflineStore('close'); style=cursor:hand;></a></td>"
		+"  </tr>"
		+"</table>"
		+"<table width=100% border=0 cellspacing=0 cellpadding=0 background=/img/right/subtit_bg.gif style='table-layout:fixed'>"
		+"  <tr>"
		+"	<td width=15>&nbsp;</td>"
		+"	<td height=42 width=630><img src=/img/offlinestore/offline.gif width=391 height=42></td>"
		+"	<td align=left class=location width=200>HOME</a> &gt; <b>¿ÀÇÁ¶óÀÎ¸ÅÀå</b></td>"
		+"  </tr>"
		+"  <tr><td height=1 bgcolor=black colspan=5></td></tr>"
		+"  <tr>"
		+"	<td height=33 valign=top style=padding-top:7px colspan=3><table width=100%  border=0 cellspacing=0 cellpadding=0>"
		+"		<tr>"
		+"		  <td width=20 align=right><!--<img src=/img/right/arrow.gif width=9 height=10>--></td>"
		+"		  <td class=subtit></td>"
		+"		</tr>"
		+"	</table></td>"
		
		+"  </tr>"
		+"<tr><td colspan=5><div id='offlinecenter' style='width:100%;height:100%;border:0px solid'></div></td></tr>"
		+"</table>";

}

function OfflineStoreDetail(seq)
{
	var req = getXMLHTTP();

	req.onreadystatechange = function()
	{
		if(req.readyState == 4)
		{	
			if (req.status == 200)
			{
				
				handleOfflineStoreDetailResponse(eval("("+req.responseText+")"));
				
			}
		}
	}
	
	req.open('POST',"/call/call_OffLineStore.asp?seq="+escape(seq),true);
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	req.send(null);
}

function handleOfflineStoreDetailResponse(result)
{
	var offlinecenter = document.getElementById("offlinecenter");
	if (result.img1 !="")
	{var img1 = "<img src='/img/offlinestore/"+result.img1+"' width=63 height=60  border=0 onclick=javascript:PhotoChange('"+result.bimg1+"','1'); style=cursor:hand;>";}
	else{var img1="<img src='/img/offlinestore/off_noimg.gif' width=63 height=60  border=0>";}
	if (result.img2 !="")
	{var img2 = "<img src='/img/offlinestore/"+result.img2+"' width=63 height=60  border=0 onclick=javascript:PhotoChange('"+result.bimg2+"','1'); style=cursor:hand;>";}
	else{var img2="<img src='/img/offlinestore/off_noimg.gif' width=63 height=60  border=0>";}
	if (result.img3 !="")
	{var img3 = "<img src='/img/offlinestore/"+result.img3+"' width=63 height=60  border=0 onclick=javascript:PhotoChange('"+result.bimg3+"','1'); style=cursor:hand;>";}
	else{var img3="<img src='/img/offlinestore/off_noimg.gif' width=63 height=60  border=0>";}
	if (result.img4 !="")
	{var img4 = "<img src='/img/offlinestore/"+result.img4+"' width=63 height=60 border=0 onclick=javascript:PhotoChange('"+result.bimg4+"','1'); style=cursor:hand;>";}
	else{var img4="<img src='/img/offlinestore/off_noimg.gif' width=63 height=60  border=0>";}

	offlinecenter.innerHTML = 
"	<table width=850 border=0 cellspacing=0 cellpadding=0>"
+"	  <tr>"
+"		<td height=530 valign=top>"
		  
+"		  <table width=620 border=0 cellspacing=0 cellpadding=0>"
+"			<tr>"
+"			  <td style=padding:13px 20px 25px 20px><table width=558 border=0 cellspacing=0 cellpadding=0>"
+"				<tr>"
+"				  <td height=345 align=right><div id=mapphoto>"
+"					<iframe width=558 height=345 frameborder=0 scrolling=no marginheight=0 marginwidth=0 src='"+result.google+"'></iframe>"
+"					  </br><a href='"+result.google2+"' target=_blank><span class=map>Áöµµ Å©°Ô º¸±â</span></a>"
+"					  </div></td>"
+"				</tr>"
+"			  </table></td>"
+"			</tr>"
+"		  </table>"
+"		  <table width=620 border=0 cellspacing=0 cellpadding=0>"
+"			<tr>"
+"			  <td width=20></td>"
+"			  <td valign=top>"
+"				<table width=560 border=0 cellspacing=0 cellpadding=0>"
+"				  <tr>"
+"					<td colspan=2 bgcolor=#CCCCCC height=1></td>"
+"				  </tr>"
+"				   <tr>"
+"					<td width=115><img src=/img/offlinestore/icon_print.gif width=115 height=38></td>"
+"					<td width=445><a href='"+result.print+"' target=_blank><img src=/img/offlinestore/btn_print.gif width=69 height=23 border=0 style=cursor:hand;></a></td>"
+"				  </tr>"
+"				  <tr>"
+"					<td colspan=2 bgcolor=#CCCCCC height=1></td>"
+"				  </tr>"
+"			  </table>"
+"			  </td>"
+"			  <td width=40></td>"
+"			</tr>"
+"		  </table>  " 
+"		</td>"
+"		<!-------------------------------------- °¡¿îµ¥ ±¸ºÐ¼± ------------------------------------------->"
+"		<td width=1 height=100% valign=top bgcolor=#CCCCCC><table width=1 border=0 cellspacing=0 cellpadding=0>"
+"			<tr>"
+"			  <td height=13><img src=/img/offlinestore/space_01.gif width=1 height=13></td>"
+"			</tr>"
+"			<tr>"
+"			  <td><img src=/img/offlinestore/line_05.gif></td>"
+"			</tr>"
+"		</table></td>"
+"		<!------------------------------------------------------------------------------------------------>"
+"		<!-------------------------------------- ¿À¸¥ÂÊ ------------------------------------------->"
+"		<td width=256 valign=top style=padding:20px>"
+"		  <table width=100%  border=0 cellspacing=0 cellpadding=0>"
+"			<tr>"
+"			  <td class=product>"+result.name+"</td>"
+"			</tr>"
+"			<tr>"
+"			  <td height=20></td>"
+"			</tr>"
+"			<tr>"
+"			  <td height=123 valign=top>"
+"				<table width=100%  border=0 cellspacing=0 cellpadding=0>"
+"				  <tr>"
+"					<td width=12><img src=/img/common/detail_icon_03.gif width=10 height=4><br><br></td>"
+"					<td class=pro_content>ÁÖ¼Ò : "+result.address+"</td>"
+"				  </tr>"
+"				  <tr>"
+"					<td width=12><img src=/img/common/detail_icon_03.gif width=10 height=4></td>"
+"					<td class=pro_content>ÀüÈ­ : "+result.tel+"</td>"
+"				  </tr>"
+"				  <tr>"
+"					<td width=12><img src=/img/common/detail_icon_03.gif width=10 height=4></td>"
+"					<td class=pro_content>¿µ¾÷½Ã°£ : "+result.worktime+"</td>"
+"				  </tr>"
+"				  <tr>"
+"					<td width=12><img src=/img/common/detail_icon_03.gif width=10 height=4></td>"
+"					<td class=pro_content>Á¡Àå : "+result.manager+"</td>"
+"				  </tr>"
+"				  <tr>"
+"					<td width=12><img src=/img/common/detail_icon_03.gif width=10 height=4></td>"
+"					<td class=pro_content>¸ÅÀåÀü°æ : </td>"
+"				  </tr>"
+"				  <tr>"
+"					<td width=12></td>"
+"					<td height=10></td>"
+"				  </tr>"
+"				  <tr>"
+"					<td width=12></td>"
+"					<td valign=top><table border=0 cellspacing=0 cellpadding=0 width=140>"
+"					  <tr>"
+"						<td width=65 height=60>"
+"						<table width=65 border=0 cellspacing=1 cellpadding=0 bgcolor=#CCCCCC>"
+"						  <tr>"
+"							<td height=60 bgcolor=#FFFFFF>"+img1+"</td>"
+"						  </tr>"
+"						</table></td>"
+"						<td width=10>&nbsp;</td>"
+"						<td width=65><table width=65 border=0 cellspacing=1 cellpadding=0 bgcolor=#CCCCCC>"
+"						  <tr>"
+"							<td height=60 bgcolor=#FFFFFF>"+img2+"</td>"
+"						  </tr>"
+"						</table></td>"
+"					  </tr>"
+"					  <tr>"
+"						<td height=10 colspan=3></td>"
+"						</tr>"
+"					  <tr>"
+"						<td height=60><table width=65 border=0 cellspacing=1 cellpadding=0 bgcolor=#CCCCCC>"
+"						  <tr>"
+"							<td height=60 bgcolor=#FFFFFF>"+img3+"</td>"
+"						  </tr>"
+"						</table></td>"
+"						<td>&nbsp;</td>"
+"						<td><table width=65 border=0 cellspacing=1 cellpadding=0 bgcolor=#CCCCCC>"
+"						  <tr>"
+"							<td height=60 bgcolor=#FFFFFF>"+img4+"</td>"
+"						  </tr>"
+"						</table></td>"
+"					  </tr>"
+"					</table></td>"
+"				  </tr>"
+"			  </table></td>"
+"			</tr>"
+"			<tr>"
+"			  <td height=50>&nbsp;</td>"
+"			</tr>"
+"			<tr>"
+"			  <td>"
+"				<table width=100%  border=0 cellspacing=0 cellpadding=0>"
+"				  <tr>"
+"					<td width=28 height=23 align=right><img src=/img/offlinestore/off_icon.gif width=15 height=17></td>"
+"					<td width=158>"
+"<a onMouseOut=MM_swapImgRestore() onMouseOver=MM_swapImage('btn_offlist','','img/offlinestore/btn_offlist_hov.gif',1)>"
+"					<img src=/img/offlinestore/btn_offlist.gif onclick=javascript:OfflineStoreList(1); style=cursor:hand; name=btn_offlist width=96 height=17 border=0></a></td>"
+"				  </tr>"
+"				</table>"
+"				<!----------------------------------------------------->"
+"			  </td>"
+"			</tr>"
+"		</table></td>"
+"		<!----------------------------------------------------------------------------------------->"
+"	  </tr>"
+"	</table>";
}

function PhotoChange(b_img)
{
	document.getElementById("mapphoto").innerHTML = "<img src='/img/offlinestore/"+b_img+"' width=558 height=345>";
}


function OfflineStoreList(page)
{

	var req = getXMLHTTP();

	req.onreadystatechange = function()
	{
		if(req.readyState == 4)
		{	
			if (req.status == 200)
			{
				
				handleOfflineStoreListResponse(eval("("+req.responseText+")"),page);
				
			}
		}
	}
	
	req.open('POST',"/call/call_OffLineStoreList.asp?page="+escape(page),true);
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	req.send(null);
}

function handleOfflineStoreListResponse(result,page)
{
	var offlinecenter = document.getElementById("offlinecenter");
	var osl = "";

	for (i=0;i<result.list_text.length ;i++ )
	{
		osl = osl + "			<tr>"
	+"			  <td height=30 align=center class=tbl_text>"+result.list_text[i].name+"</td>"
	+"			  <td height=30 align=center class=tbl_tit>&nbsp;</td>"
	+"			  <td height=30 align=center class=tbl_text>"+result.list_text[i].address+"</td>"
	+"			  <td>&nbsp;</td>"
	+"			  <td class=tbl_tit>"+result.list_text[i].tel+"</td>"
	+"			  <td></td>"
	+"			  <td class=tbl_tit>"+result.list_text[i].worktime+"</td>"
	+"			  <td>&nbsp;</td>"
	+"			  <td align=center><img src=/img/offlinestore/off_view.gif width=15 height=15 style=cursor:hand; onclick=javascript:OfflineStoreDetail('"+result.list_text[i].seq+"')></td>"
	+"			</tr>"
				
	+"			<tr>"
	+"			  <td height=1 colspan=9 bgcolor=#CCCCCC></td>"
	+"			</tr>";
	}


	offlinecenter.innerHTML = 

"	<table width=850 border=0 cellspacing=0 cellpadding=0>"
+"	  <tr>"
+"		<td width=850 valign=top style=padding-top:15px>"
		

+"		  <table width=800 border=0 align=center cellpadding=0 cellspacing=0>"
+"			<tr >"
+"			  <td width=165 height=26 background=/img/offlinestore/tbl_tit_bg.gif class=tbl_tit>ÁöÁ¡¸í</td>"
+"			  <td width=4 background=/img/offlinestore/tbl_tit_bg.gif><span class=tbl_tit><img src=img/tbl_tit_line.gif width=5 height=26></span></td>"
+"			  <td width=337 background=/img/offlinestore/tbl_tit_bg.gif class=tbl_tit>ÁÖ¼Ò</td>"
+"			  <td width=4 background=/img/offlinestore/tbl_tit_bg.gif><span class=tbl_tit><img src=img/tbl_tit_line.gif width=5 height=26></span></td>"
+"			  <td width=97 background=/img/offlinestore/tbl_tit_bg.gif class=tbl_tit>ÀüÈ­¹øÈ£</td>"
+"			  <td width=5 background=/img/offlinestore/tbl_tit_bg.gif class=tbl_tit><img src=img/tbl_tit_line.gif width=5 height=26></td>"
+"			  <td width=102 background=/img/offlinestore/tbl_tit_bg.gif class=tbl_tit>¿µ¾÷½Ã°£</td>"
+"			  <td width=5><img src=/img/offlinestore/tbl_tit_line.gif width=5 height=26></td>"
+"			  <td width=81 background=/img/offlinestore/tbl_tit_bg.gif class=tbl_tit>ÀÚ¼¼È÷º¸±â</td>"
+"			</tr>"
+	osl
+"		  </table>"
+"		  </td>"
+"	  </tr>"
+"	  <tr><td laign=center><div id=offlinepage></div></tD></tr>"
+"	</table>";

OfflineStorePage(result,page)
}


function OfflineStorePage(result,page)
{
	var show_page_num = 5;
	var total_page = result.total_page;
	var page_group_cnt = result.page_group_cnt;
	var now_page_group_num = result.now_page_group_num;
	
	var show_start_page = (show_page_num * (now_page_group_num-1)+1)
	var show_page = now_page_group_num * show_page_num
	var next_page = (show_page_num * (now_page_group_num)+1);
	var before_page =(now_page_group_num-2)*show_page_num + 1;
	
	var page_view = document.getElementById("offlinepage");
	
	var pageHTML = "<br><table cellpadding=0 cellspacing=0 border=0 align=center ><tr>";

	if (before_page > 0)
	{
		pageHTML = pageHTML + "<td width=15 align=center><a href=javascript:OfflineStoreList('"+before_page+"')><img src=img/tbl_arrow_1.gif width=7 height=9></td>";
	}
	else
	{
		pageHTML = pageHTML + "<td width=15 align=center></td>";
	}

	for (p=show_start_page;p<=show_page;p++ ){
		if (p <= total_page)
		{
			if (p == page)
			{
				pageHTML = pageHTML + "<td align=center class=page_sel width=15><b>" + p + "</b></td>"
				
			}
			else
			{
				pageHTML = pageHTML + "<td align=center width=15><a href=javascript:OfflineStoreList('"+p+"')>" + p + "</a></td>"
			}
			
		}
		else
		{
			pageHTML = pageHTML + "<td width=15> </td>"
		}

		
	}
	if (next_page <= total_page)
	{
		pageHTML = pageHTML + "<td width=15 align=center><a href=javascript:OfflineStoreList('"+next_page+"')><img src=img/tbl_arrow_2.gif width=7 height=9 border=0></td>"
	}
	else
	{
		pageHTML = pageHTML + "<td width=15 align=center></td>"
	}

	pageHTML = pageHTML + "</tr></table>";
	page_view.innerHTML = pageHTML;
	
}
