function getXMLHttpRequest() {
	if (window.ActiveXObject) {
		try {
			return new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				return new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e1) { return null; }
		}
	} else if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else {
		return null;
	}
}

var httpRequest = null;

function sendRequest(url, params, callback, method) {
	httpRequest = getXMLHttpRequest();
	var httpMethod = method ? method : 'GET';
	if (httpMethod != 'GET' && httpMethod != 'POST') {
		httpMethod = 'GET';
	}
	var httpParams = (params == null || params == '') ? null : params;
	var httpUrl = url;
	if (httpMethod == 'GET' && httpParams != null) {
		httpUrl = httpUrl + "?" + httpParams;
	}
	httpRequest.open(httpMethod, httpUrl, true);
	httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	httpRequest.onreadystatechange = callback;
	httpRequest.send(httpMethod == 'POST' ? httpParams : null);
}

/*
 ----------------------------------------------------------> orange skin start...
*/

function DispMenu(strFlag)
{
	var strMenuUrl;

	DispMenuImg(strFlag);

	if(strFlag=="1"){
		strMenuUrl = "main_menu_01.html";
	}else if(strFlag=="2"){
		strMenuUrl = "main_menu_02.html";
	}else if(strFlag=="3"){
		strMenuUrl = "main_menu_03.html";
	}else if(strFlag=="4"){
		strMenuUrl = "main_menu_04.html";
	}else{
		strMenuUrl = "main_menu_01.html";
	}
	
	new ajax.xhr.Request("/skins/Orange/files/"+strMenuUrl, "", InsertMenu, "get");

}

function HiddenMenu()
{
	HiddenMenuImg();

	var div_result = document.getElementById("SubMenu")
	
	div_result.innerHTML="";
	div_result.style.display = "none";
}

 function InsertMenu(req)
{	
		var div_result = document.getElementById("SubMenu")

		if (req.readyState == 4) {
			if (req.status == 200) {
				div_result.innerHTML=req.responseText;
				div_result.style.display = "block";
			}
		}
}

function DispMenuImg(strFlag)
{
	if(strFlag !=''){

			for (var i=1;i<5 ;i++)
			{
				if(i==strFlag){
					document.getElementById("submenu"+i).src = "http://img.walkholic.com/wh09/wh_tm0"+ i +"_on.gif" ;							
				}else{
					document.getElementById("submenu"+i).src = "http://img.walkholic.com/wh09/wh_tm0"+ i +".gif" ;							
				}

			}

	}
}

function HiddenMenuImg()
{
	for (var i=1;i<5 ;i++)
	{
		document.getElementById("submenu"+i).src = "http://img.walkholic.com/wh09/wh_tm0"+ i +".gif" ;
	}			
}
			
function Fill_Main_ManageDiv01(req)
 {	
		var div_result = document.getElementById("ManageDiv01")

		if (req.readyState == 4) {
			if (req.status == 200) {							
				div_result.innerHTML=req.responseText;
			}
		}
}

function Fill_Main_ManageDiv02(req)
 {	
		var div_result = document.getElementById("ManageDiv02")

		if (req.readyState == 4) {
			if (req.status == 200) {							
				div_result.innerHTML=req.responseText;
			}
		}
}

function Fill_Main_ManageDiv03(req)
 {	
		var div_result = document.getElementById("ManageDiv03")

		if (req.readyState == 4) {
			if (req.status == 200) {							
				div_result.innerHTML=req.responseText;
			}
		}
}

function Fill_Main_ManageDiv04(req)
 {	
		var div_result = document.getElementById("ManageDiv04")

		if (req.readyState == 4) {
			if (req.status == 200) {							
				div_result.innerHTML=req.responseText;
			}
		}
}

function Fill_Main_ManageDiv05(req)
 {	
		var div_result = document.getElementById("ManageDiv05")

		if (req.readyState == 4) {
			if (req.status == 200) {							
				div_result.innerHTML=req.responseText;
			}
		}
}

function Fill_Main_ManageDiv06(req)
 {	
		var div_result = document.getElementById("ManageDiv06")

		if (req.readyState == 4) {
			if (req.status == 200) {							
				div_result.innerHTML=req.responseText;
			}
		}
}

function Fill_Main_ManageDiv07(req)
 {	
		var div_result = document.getElementById("ManageDiv07")

		if (req.readyState == 4) {
			if (req.status == 200) {							
				div_result.innerHTML=req.responseText;
			}
		}
}

function Fill_Sub_NewArticle(req){

		var div_result = document.getElementById("NewArticleDiv")

		if (req.readyState == 4) {
			if (req.status == 200) {							
				div_result.innerHTML=req.responseText;
			}
		}
}

var result = Math.floor(Math.random() * 3) + 1;
var result2 = Math.floor(Math.random() * 3) + 1;
var result3 = Math.floor(Math.random() * 4) + 1;

function show_index()
{   
	
	new ajax.xhr.Request("/skins/Orange/files/main_section_item.php?Sec=01&Flag=01", "", Fill_Main_ManageDiv01, "GET");
	new ajax.xhr.Request("/skins/Orange/files/main_section_item.php?Sec=02&Flag=01", "", Fill_Main_ManageDiv02, "GET");
	new ajax.xhr.Request("/skins/Orange/files/main_section_item.php?Sec=03&Flag=01", "", Fill_Main_ManageDiv03, "GET");
	new ajax.xhr.Request("/skins/Orange/files/main_section_category.php?Sec=04&Flag=0" + result, "", Fill_Main_ManageDiv04, "GET");
	new ajax.xhr.Request("/skins/Orange/files/main_section_category.php?Sec=05&Flag=0" + result2, "", Fill_Main_ManageDiv05, "GET");
	new ajax.xhr.Request("/skins/Orange/files/main_section_category.php?Sec=07&Flag=0" + result3, "", Fill_Main_ManageDiv07, "GET");
	new ajax.xhr.Request("/skins/Orange/files/main_section_community.php?Sec=06&Flag=01", "", Fill_Main_ManageDiv06, "GET");				
	new ajax.xhr.Request("/skins/Orange/files/main_section_blog_01.html", "", Fill_Blog_ManageDiv, "GET");

}

function show_sub()
{
	new ajax.xhr.Request("/skins/Orange/files/main_section_new_sub.php", "", Fill_Sub_NewArticle, "GET");
	new ajax.xhr.Request("/skins/Orange/files/main_section_blog_01.html", "", Fill_Blog_ManageDiv, "GET");
}

function FocusPhotoTab(ID, ImgName, Title, Url){

	if(ImgName != "" && Title !="" && Url !=""){
	
		var Str1;
		Str1 = "";
		Str1 += "<a href='"+ Url +"'>"+ Title +"</a>" ;

		var Str2;
		Str2 = "";
		Str2 += "<a href='"+ Url +"'><img src='"+ ImgName +"' alt='"+ Title +"' width='236' height='144' border='0' /></a>" ;

		vt01.innerHTML = Str1;
		vt02.innerHTML = Str2;

		for(var k=1;k<=3;k++){
			if(k==ID){
				document.getElementById("Photo"+k).className = "over";
			}else{
				document.getElementById("Photo"+k).className = "";					
			}

		}

	}
}

function DispManageImg(strSection, strFlag){

	if(strFlag==''){strFlag = '01';}
	if(strSection==''){strSection='01';}						

	if(strFlag=='01'){
		document.getElementById("ManageImg"+strSection+"01").src="http://img.walkholic.com/wh09/wh_putab01_on.gif"
		document.getElementById("ManageImg"+strSection+"02").src="http://img.walkholic.com/wh09/wh_putab02.gif"
	
	}else{
		document.getElementById("ManageImg"+strSection+"01").src="http://img.walkholic.com/wh09/wh_putab01.gif"
		document.getElementById("ManageImg"+strSection+"02").src="http://img.walkholic.com/wh09/wh_putab02_on.gif"
	}
}

function DispManageDiv(strSection, strFlag)
{
	if(strFlag==''){strFlag = '01';}
	if(strSection==''){strSection='01';}

	var strMenuUrl;								

	if(strSection=='01'){
		new ajax.xhr.Request("/skins/Orange/files/main_manage_"+ strSection +"_"+ strFlag +".html", "", Fill_Main_ManageDiv01, "GET");								
	}else if(strSection=='02'){
		new ajax.xhr.Request("/skins/Orange/files/main_manage_"+ strSection +"_"+ strFlag +".html", "", Fill_Main_ManageDiv02, "GET");								
	}else if(strSection=='03'){
		new ajax.xhr.Request("/skins/Orange/files/main_manage_"+ strSection +"_"+ strFlag +".html", "", Fill_Main_ManageDiv03, "GET");								
	}else if(strSection=='04'){
		new ajax.xhr.Request("/skins/Orange/files/main_section_category.php?Sec="+strSection+"&Flag="+strFlag, "", Fill_Main_ManageDiv04, "GET");
	}else if(strSection=='05'){
		new ajax.xhr.Request("/skins/Orange/files/main_section_category.php?Sec="+strSection+"&Flag="+strFlag, "", Fill_Main_ManageDiv05, "GET");
	}else if(strSection=='06'){
		new ajax.xhr.Request("/skins/Orange/files/main_section_community.php?Sec="+strSection+"&Flag="+strFlag, "", Fill_Main_ManageDiv06, "GET");
	}else if(strSection=='07'){
		new ajax.xhr.Request("/skins/Orange/files/main_section_category.php?Sec="+strSection+"&Flag="+strFlag, "", Fill_Main_ManageDiv07, "GET");
	}

}

// section HMenu start ----------------------------------------------------------------------------------------

var HMenuID;
var HMenuList;
var HPage;
var HPageSize=4;
var oPageForm;

function getHMenu(HMenuID){

	if(HMenuID=='Foot'){
		HMenuList =['신체 균형과 발','발 질환과 치료','풋케어'];								
	}else if(HMenuID=='Food'){
		HMenuList =['메디시컬 푸드','다이어트','성인병 예방'];
	}else if(HMenuID=='Clock'){
		HMenuList =['유아','청년','중년','노년'];
	}

	return HMenuList;
}


function getPage()
{
	if(HMenuID=='Foot'){
		return oPageForm.FootPage.value;
	}else if(HMenuID=='Food'){
		return oPageForm.FoodPage.value;								
	}else if(HMenuID=='Clock'){
		return oPageForm.FoodPage.value;
	}
}

function setPage()
{
	if(HMenuID=='Foot'){
		oPageForm.FootPage.value = HPage;
	}else if(HMenuID=='Food'){
		oPageForm.FoodPage.value = HPage;	
	}else if(HMenuID=='Clock'){
		oPageForm.FoodPage.value = HPage;	
	}								
}

function HMenu(ID, PageFlag){

	oPageForm = document.HPage;

	HMenuID = ID;
	HMenuList = getHMenu(HMenuID);
	HPage = Number(getPage());

	var MnuLen;
	MnuLen = HMenuList.length

	var PageNum = Math.ceil(MnuLen/HPageSize); 

	if(PageFlag =='Pre')
	{
		HPage = HPage - 1;
	
		if(HPage < 1){HPage =1;}

	}
	else if(PageFlag=='Next')
	{
		HPage = HPage +1;

		if(HPage > PageNum){HPage = PageNum;}

	}

	setPage();

	var PageStart = (HPage * HPageSize) - HPageSize;
	var PageEnd = (HPage * HPageSize);

	var html = '';
	html = html + '<ul>';

	for(var z=PageStart; z< PageEnd;z++)
	{
		if(z >= MnuLen){
			html = html + '  <li class="d11_g slt_tit">&nbsp;</li>';			
		}else{

			if(HMenuID=='Foot'){
				if (Number(z+1) ==result){
					html = html + '  <li id="'+ HMenuID +'_MenuLi_'+Number(z+1)+'" onclick="javascript:HMenuFocus(\''+ HMenuID+'\',\''+ Number(z+1) +'\');" class="d11_g slt_tit" ><a href="javascript:DispManageDiv(\'04\',\'0'+ Number(z+1) +'\');">'+ HMenuList[z] +'</a></li>';
				}else{
					html = html + '  <li id="'+ HMenuID +'_MenuLi_'+Number(z+1)+'" onclick="javascript:HMenuFocus(\''+ HMenuID+'\',\''+ Number(z+1) +'\');" class="d11_g"><a href="javascript:DispManageDiv(\'04\',\'0'+ Number(z+1) +'\');">'+ HMenuList[z] +'</a></li>';													
				}

			}else if(HMenuID=='Food'){

				if (Number(z+1) ==result2){
					html = html + '  <li id="'+ HMenuID +'_MenuLi_'+Number(z+1)+'" onclick="javascript:HMenuFocus(\''+ HMenuID+'\',\''+ Number(z+1) +'\');" class="d11_g slt_tit" ><a href="javascript:DispManageDiv(\'05\',\'0'+ Number(z+1) +'\');">'+ HMenuList[z] +'</a></li>';
				}else{
					html = html + '  <li id="'+ HMenuID +'_MenuLi_'+Number(z+1)+'" onclick="javascript:HMenuFocus(\''+ HMenuID+'\',\''+ Number(z+1) +'\');" class="d11_g"><a href="javascript:DispManageDiv(\'05\',\'0'+ Number(z+1) +'\');">'+ HMenuList[z] +'</a></li>';
				}

			}else if(HMenuID=='Clock'){

				if (Number(z+1) ==result3){
					html = html + '  <li id="'+ HMenuID +'_MenuLi_'+Number(z+1)+'" onclick="javascript:HMenuFocus(\''+ HMenuID+'\',\''+ Number(z+1) +'\');" class="d11_g slt_tit" ><a href="javascript:DispManageDiv(\'07\',\'0'+ Number(z+1) +'\');">'+ HMenuList[z] +'</a></li>';
				}else{
					html = html + '  <li id="'+ HMenuID +'_MenuLi_'+Number(z+1)+'" onclick="javascript:HMenuFocus(\''+ HMenuID+'\',\''+ Number(z+1) +'\');" class="d11_g"><a href="javascript:DispManageDiv(\'07\',\'0'+ Number(z+1) +'\');">'+ HMenuList[z] +'</a></li>';
				}
			}
		}
	}

	html = html + '</ul>';

	var div_result = document.getElementById(HMenuID+"MenuDiv");
	div_result.innerHTML=html;

}

function HMenuFocus(HMenuID, Num)
{
		for(var i=1;i<=4;i++){
			if(document.getElementById(HMenuID+"_MenuLi_"+ i)){
				if(Num ==i){
					document.getElementById(HMenuID+"_MenuLi_"+ i).className = "d11_g slt_tit";			
				}else{
				document.getElementById(HMenuID+"_MenuLi_"+ i).className = "d11_g";		
				}
			}
		}
}

// section HMenu end ----------------------------------------------------------------------------------------


function XY_getCookie( name ) 
{ 
	if (name==null)
	{
		return "";
	}
	else
	{
			var nameOfCookie = name + "="; 
			var x = 0; 
			while ( x <= document.cookie.length ) 
			{ 
			var y = (x+nameOfCookie.length); 
			if ( document.cookie.substring( x, y ) == nameOfCookie ) { 
			if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 ) 
			endOfCookie = document.cookie.length; 
			return unescape( document.cookie.substring( y, endOfCookie ) ); 
			} 
			x = document.cookie.indexOf( " ", x ) + 1; 
			if ( x == 0 ) 
			break; 
			} 
			return ""; 
	}
}



 function alldelCookie()
 {
	deleteCookie( "person");
	deleteCookie( "per_wg");
	//set_wgCookie("per_wg","wg12",1);
	//set_wgCookie("per_wg","wg13",1);
	 
	location.href = '/index.php';
 }
 


 function deleteCookie(name)
 {
  var expireDate = new Date();

  expireDate.setDate( expireDate.getDate() - 1 );
  document.cookie = name + "= " + "; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/";
 }


function MakeCategory(obj){

	var CateListVal = document.getElementById("MiruguIsolationList").value;
	var CateVal = obj.value;

	if(obj.checked){
		if(CateListVal !=''){
			document.getElementById("MiruguIsolationList").value = CateListVal +','+CateVal;
		}else{
			document.getElementById("MiruguIsolationList").value = CateListVal + CateVal;
		}
	}else{
		var TempCateListVal = RemoveCategory(CateListVal, CateVal);
		document.getElementById("MiruguIsolationList").value = TempCateListVal;
	}

}

function RemoveCategory(chStr,strWord) {

	var ArryCate = chStr.split(",");
	var CateListVal;
	CateListVal = "";

	for (var i = 0; i<ArryCate.length; i++)
	{
		if(ArryCate[i]==strWord){

		}else{
			if(CateListVal != ""){
				CateListVal = CateListVal + "," + ArryCate[i]			
			}else{
				CateListVal = CateListVal + ArryCate[i]				
			}
		}
	}

	return CateListVal;
}

/*
 ----------------------------------------------------------> orange skin end..
*/

function pre()
{
	document.upload.action="/index.php/%EB%8C%80%EB%AC%B8";
	document.upload.submit();
}

function pre2()
{
	document.upload2.action="/index.php/%EB%8C%80%EB%AC%B8";
	document.upload2.submit();
}


function search_form_check() {

	var form = document.searchform;
	var wiki_form = document.wikiSearchform;

	if( form.query.value == "" ){
		form.query.value ='자출족';
	   //alert("검색어를 입력하세요.");
	   //form.query.focus();
	   //return false;
	}

	var acturl = "";
	var srch_type = form.srch_type.value;	// 통합검색 or 위키검색
	var act = form.act.value;				// 통합검색 (통합/문서/이미지/태그/사용자)

	if(srch_type==""){
		srch_type = 1;
	}

	if(srch_type=="1"){
		if("doc" == act){
			acturl = "/index.php/special:DALSearchDoc";
		}else if("img" == act){
			acturl = "/index.php/special:DALSearchImg";
		}else if("tag" == act){
			acturl = "/index.php/special:DALSearchTag";
		}else if("user" == act){
			acturl = "/index.php/special:DALSearchUser";
		}else{
			acturl = "/index.php/special:DALSearchTotal";
		}
	}else{
		form.search.value = form.query.value;
		form.query.value = "";
		acturl ="<?php $this->text('searchaction') ?>";	
	}


	if(acturl != ""){
		form.action = acturl;
		return true;
	}else{
		alert("error");
		return false;
	}

 }	


 function clear_search_form(obj) {
	obj.style.background = "url()";
 }

function select_search_type(id){

	document.searchform.srch_type.value = id;

	if("1"==id){
		document.getElementById("sc_type").src = "http://img.walkholic.com/wh09/wh_search_slt01.gif";
		document.getElementById("sc_type").alt = "통합검색";		
	}else if("2"==id){
		document.getElementById("sc_type").src = "http://img.walkholic.com/wh09/wh_search_slt02.gif";
		document.getElementById("sc_type").alt = "위키검색";
	}
}

function sltopt(no) {
	if (no=="1") {
		document.getElementById('TS_select').src="http://img.walkholic.com/wh09/wh_search_slt01.gif";
		document.getElementById('TS_select_opt').style.display="block";
	}
	if (no=="2") {
		document.getElementById('TS_select').src="http://img.walkholic.com/wh09/wh_search_slt01.gif";
		document.getElementById('TS_select_opt').style.display="none";
	}
}


function DispManageBlog(Num){

	if(Num==""){
		Num = "01";
	}

	new ajax.xhr.Request("/skins/Orange/files/main_section_blog_"+Num+".html", "", Fill_Blog_ManageDiv, "GET");

}

function DispMenuBlogImg(strFlag)
{
	if(strFlag !=''){

		for (var i=1;i<5 ;i++)
		{
			if(i==strFlag){
				document.getElementById("blogtab"+i).src = "http://img.walkholic.com/wh09/wh_btab0"+ i +"_on.gif" ;							
			}else{
				document.getElementById("blogtab"+i).src = "http://img.walkholic.com/wh09/wh_btab0"+ i +".gif" ;							
			}

		}

	}
}


function Fill_Blog_ManageDiv(req)
 {	
		var div_result = document.getElementById("BlogManageDiv")

		if (req.readyState == 4) {
			if (req.status == 200) {							
				div_result.innerHTML=req.responseText;
			}
		}
}

function DispRank(Opt){

	var DivRankToday = document.getElementById("cr07_con01")
	var DivRankYear = document.getElementById("cr07_con02")	

	if(Opt=='cr07_con01'){
			document.getElementById("RankTab01").src="http://img.walkholic.com/wh09/wh_prtab01_on.gif";
			document.getElementById("RankTab02").src="http://img.walkholic.com/wh09/wh_prtab02.gif";
			DivRankToday.style.display = "";
			DivRankYear.style.display = "none";
	}else{
			document.getElementById("RankTab01").src="http://img.walkholic.com/wh09/wh_prtab01.gif";
			document.getElementById("RankTab02").src="http://img.walkholic.com/wh09/wh_prtab02_on.gif";
			DivRankToday.style.display = "none";	
			DivRankYear.style.display = "";
	}
}

function help01(no) {
	if (no=="1") {
		document.getElementById('help01');
		document.getElementById('help01_view').style.display="block";
	}
	if (no=="2") {
		document.getElementById('help01');
		document.getElementById('help01_view').style.display="none";
	}
}
function help02(no) {
	if (no=="1") {
		document.getElementById('help02');
		document.getElementById('help02_view').style.display="block";
	}
	if (no=="2") {
		document.getElementById('help02');
		document.getElementById('help02_view').style.display="none";
	}
}