﻿function MainImageOn(MenuID)
{
	try
	{
		if(!document.getElementsByTagName) return false;
		if(!document.getElementById) return false;
		for (var i=0; i < $("top_rightArea2").getElementsByTagName("SPAN").length - 1 ; i++)
		{
			MainImageOff($("top_rightArea2").getElementsByTagName("SPAN")[i].id);
		}
		var topimgs = "topimg" + MenuID;
		$(topimgs).setAttribute("src", $("tmn_" + MenuID).getAttribute("img_on"));
			
		var obj = document.getElementById("tsm" + MenuID);
		obj.style.display = "block";
		setDivLocation(MenuID, obj, 200, 1020);
	}
	catch (oEx)
	{
	}
}

function MainImageOff(sId)
{
	var MenuID = sId.split('_')[1];
	var topimgs = "topimg" + MenuID;
	$(topimgs).setAttribute("src", $(sId).getAttribute("img_off"));

	var obj = document.getElementById("tsm" + MenuID);
	obj.style.display = "none";
}

function setDivLocation(m_id, o_cat, start, main_width)
{
	var o_mnu = $("tmn_" + m_id);
	var mnu_left = 0;
	for (var i = 0; i < $("top_rightArea2").getElementsByTagName("SPAN").length - 1 ; i++)
	{
		if ($("top_rightArea2").getElementsByTagName("SPAN")[i].id == o_mnu.id)
		{
			break;
		}
		mnu_left += $("top_rightArea2").getElementsByTagName("SPAN")[i].offsetWidth;
	}
	mnu_left += start;
	var oLeft = start;
	var cat_width = o_cat.offsetWidth;

	var mnu_center = mnu_left + Math.floor(o_mnu.offsetWidth / 2);
	var cat_center = Math.floor(cat_width / 2);
	if (cat_width < main_width)
	{
		oLeft = (mnu_center - cat_center);
		if (oLeft < start)
		{
			oLeft = start;
		}
		else
		{
			if ((oLeft + cat_width) > main_width)
			{
				oLeft = oLeft - ((oLeft + cat_width) - main_width);
			}
		}
	}
	o_cat.style.left = oLeft + "px";
	//alert("mnu_left = " + mnu_left + "\n\n---------------------\n\noLeft = " + oLeft + "\n\ncat_width=" + cat_width + "\n\nmnu_center=" + mnu_center + "\n\ncat_center=" + cat_center);
}



function SearchImageOn(num)
{
	if(!document.getElementsByTagName) return false;
	if(!document.getElementById) return false;

	if (eval(num) == 0)
	{
		if(!document.getElementById("search_button_1")) return false;
		if(!document.getElementById("search_button_2")) return false;
		var search_button_1 = document.getElementById("search_button_1");
		var search_button_2 = document.getElementById("search_button_2");

		search_button_1.setAttribute ("src","/images/lay/lay_left_schsrea_tab1_on.gif");
		search_button_2.setAttribute ("src","/images/lay/lay_left_schsrea_tab2.gif");
		
		var hospital_search = document.getElementById("hospital_search");
		hospital_search.style.display = "block";
		var clinic_information = document.getElementById("clinic_information");
		clinic_information.style.display = "none";
	}
	else if (eval(num) == 1)
	{
		if(!document.getElementById("search_button_1")) return false;
		if(!document.getElementById("search_button_2")) return false;
		var search_button_1 = document.getElementById("search_button_1");
		var search_button_2 = document.getElementById("search_button_2");

		search_button_1.setAttribute ("src","/images/lay/lay_left_schsrea_tab1.gif");
		search_button_2.setAttribute ("src","/images/lay/lay_left_schsrea_tab2_on.gif");
		
		var hospital_search = document.getElementById("hospital_search");
		hospital_search.style.display = "none";
		var clinic_information = document.getElementById("clinic_information");
		clinic_information.style.display = "block";
	}

}
function SideImageOn2(MenuID, now)
{
	if(!document.getElementsByTagName) return false;
	if(!document.getElementById) return false;

	try
	{
		var topimgs = "tmp"+ MenuID;
		$(topimgs).setAttribute("src", $("tmp" + MenuID).getAttribute("img_on"));

		$(topimgs).onmouseover = function() {
			SideImageOn2(MenuID, now);
		}

		if (now != "")
		{
		}
		else 
		{
			$(topimgs).onmouseout = function() {
				SideImageOff2(MenuID, now);
			}
		}
		
	}
	catch (oEx)
	{
	}
}
function SideImageOff2(MenuID, now)
{
	if(!document.getElementsByTagName) return false;
	if(!document.getElementById) return false;
	
	var topimgs = "tmp" + MenuID;
	$(topimgs).setAttribute("src", $("tmp" + MenuID).getAttribute("img_off"));

	$(topimgs).onmouseover= function() {
		SideImageOn2(MenuID, now);
	}
	if (now != "")
	{
	}
	else 
	{
		$(topimgs).onmouseout = function() {
			SideImageOff2(MenuID, now);
		}
	}
}


function SideImageOn(MenuName, MenuID, now)
{
	if(!document.getElementsByTagName) return false;
	if(!document.getElementById) return false;

	var topimgs = "tmp"+ MenuID;

	var link = "/images/common/tmp" + MenuName + MenuID + "_on.jpg"
	if(!document.getElementById(topimgs)) return false;
	var topimg = document.getElementById(topimgs);
	
	topimg.setAttribute ("src",link);

	topimg.onmouseover= function() {
		SideImageOn(MenuName,MenuID,now);
	}
	

	if (now != "")
	{
	}
	else 
	{
		topimg.onmouseout= function() {
			SideImageOff(MenuName,MenuID,now);
		}
	}
}

function SideImageOff(MenuName, MenuID, now)
{
	if(!document.getElementsByTagName) return false;
	if(!document.getElementById) return false;
	
	var topimgs = "tmp" + MenuID;
	var link = "/images/common/tmp" + MenuName + MenuID + ".jpg";

	if(!document.getElementById(topimgs)) return false;
	var topimg = document.getElementById(topimgs);
	topimg.setAttribute ("src",link);

	topimg.onmouseOver= function() {
		SideImageOn(MenuName, MenuID, now);
	}
	if (now != "")
	{
	}
	else
	{
		topimg.onmouseout= function() {
		SideImageOff(MenuName, MenuID, now);
		}
	}
}

function MakeSub(MenuID)
{
	if(!document.getElementsByTagName) return false;
	if(!document.getElementById) return false;

	if(!document.getElementById("tmp1")) return false;	
	if(!document.getElementById("tmp2")) return false;
	if(!document.getElementById("tmp3")) return false;
	if(!document.getElementById("tmp4")) return false;
	if(!document.getElementById("tmp5")) return false;
	if(!document.getElementById("tmp6")) return false;
	
	var imgName1 = document.getElementById("tmp1");	
	var imgName2 = document.getElementById("tmp2");
	var imgName3 = document.getElementById("tmp3");
	var imgName4 = document.getElementById("tmp4");
	var imgName5 = document.getElementById("tmp5");
	var imgName6 = document.getElementById("tmp6");

	if(!document.getElementById("to_information2_5")) return false;
	if(!document.getElementById("to_information2_6")) return false;
	
	var to_information2_5 = document.getElementById("to_information2_5");
	var to_information2_6 = document.getElementById("to_information2_6");

	if (MenuID == "1")
	{	
		var link1 = "/images/common/tmp_onlineCh1.jpg";
		var link2 = "/images/common/tmp_onlineSub2.jpg";
		var link3 = "/images/common/tmp_onlineSub3.jpg";
		var link4 = "/images/common/tmp_onlineRe4.jpg";
		var link5 = "/images/common/tmp_onlineRe5.jpg";
		var link6 = "/images/common/tmp_onlineRe6.jpg";

		imgName1.setAttribute ("src",link1);
		
		imgName1.onmouseover= function() {
			SideImageOn('_onlineCh','1');
		}

		imgName1.onmouseout= function() {
			SideImageOff('_onlineCh','1');
		}

		var to1 = document.getElementById("to1");
		to1.setAttribute("href", "javascript:DelSub();");

		imgName2.setAttribute ("src",link2);
		
		imgName2.onmouseover= function() {
			SideImageOn('_onlineSub','2');
		}

		imgName2.onmouseout= function() {
			SideImageOff('_onlineSub','2');
		}

		var to2 = document.getElementById("to2");
		to2.setAttribute("href", "수술 전 상담");

		imgName3.setAttribute ("src",link3);
		
		imgName3.onmouseover= function() {
			SideImageOn('_onlineSub','3');
		}
		
		imgName3.onmouseout= function() {
			SideImageOff('_onlineSub','3');
		}

		var to3 = document.getElementById("to3");
		to3.setAttribute("href", "수술 후 상담");

		imgName4.setAttribute ("src",link4);

		imgName4.onmouseover= function() {
			SideImageOn('_onlineRe','4');
		}
		
		imgName4.onmouseout= function() {
			SideImageOff('_onlineRe','4');
		}

		var to4 = document.getElementById("to4");
		to4.setAttribute("href", "전화");

		imgName5.setAttribute ("src",link5);
		
		imgName5.onmouseover= function() {
			SideImageOn('_onlineRe','5');
		}
		
		imgName5.onmouseout= function() {
			SideImageOff('_onlineRe','5');
		}

		imgName6.setAttribute ("src",link6);
		
		imgName6.onmouseover= function() {
			SideImageOn('_onlineRe','6');
		}
		
		imgName6.onmouseout= function() {
			SideImageOff('_onlineRe','6');
		}

		var alink = document.createElement("a");
		var alink2 = document.createElement("a");

		if (!document.getElementById("to5"))
		{
			alink.setAttribute("id", "to5");
			alink.setAttribute("href","javascript:MakeSub('3');");
			to_information2_5.appendChild(alink);
			alink.appendChild(imgName5);
		}
		else 
		{
			var to5 = document.getElementById("to5");
			to5.setAttribute("href", "javascript:MakeSub('3');");
		}

		if (!document.getElementById("to6"))
		{
			alink2.setAttribute("id", "to6");
			alink2.setAttribute("href","FAQ");
			to_information2_6.appendChild(alink2);
			alink2.appendChild(imgName6);	
		}
		else
		{
			var to6 = document.getElementById("to6");
			to6.setAttribute("href", "FAQ");
		}
	}

	if (MenuID == "3")
	{	
		var link1 = "/images/common/tmp_online1.jpg";
		var link2 = "/images/common/tmp_online2.jpg";
		var link3 = "/images/common/tmp_online3.jpg";
		var link4 = "/images/common/tmp_onlineSub4.jpg";
		var link5 = "/images/common/tmp_onlineSub5.jpg";
		var link6 = "/images/common/tmp_onlineRe6.jpg";
		
		imgName1.setAttribute ("src",link1);
		
		imgName1.onmouseover= function() {
			SideImageOn('_online','1');
		}

		imgName1.onmouseout= function() {
			SideImageOff('_online','1');
		}

		var to1 = document.getElementById("to1");
		to1.setAttribute("href", "javascript:MakeSub('1');");

		imgName2.setAttribute ("src",link2);
		
		imgName2.onmouseover= function() {
			SideImageOn('_online','2');
		}

		imgName2.onmouseout= function() {
			SideImageOff('_online','2');
		}
		
		var to2 = document.getElementById("to2");
		to2.setAttribute("href", "전화");
		
		imgName3.setAttribute ("src",link3);
		
		imgName3.onmouseover= function() {
			SideImageOn('_onlineCh','3');
		}

		imgName3.onmouseout= function() {
			SideImageOff('_onlineCh','3');
		}

		var to3 = document.getElementById("to3");
		to3.setAttribute("href", "javascript:DelSub();");

		imgName4.setAttribute ("src",link4);

		imgName4.onmouseover= function() {
			SideImageOn('_onlineSub','4');
		}
		
		imgName4.onmouseout= function() {
			SideImageOff('_onlineSub','4');
		}

		var to4 = document.getElementById("to4");
		to4.setAttribute("href", "방문 상담 예약");

		imgName5.setAttribute ("src",link5);
		
		imgName5.onmouseover= function() {
			SideImageOn('_onlineSub','5');
		}
		
		imgName5.onmouseout= function() {
			SideImageOff('_onlineSub','5');
		}

		imgName6.setAttribute ("src",link6);
		
		imgName6.onmouseover= function() {
			SideImageOn('_onlineRe','6');
		}
		
		imgName6.onmouseout= function() {
			SideImageOff('_onlineRe','6');
		}

		var alink = document.createElement("a");
		var alink2 = document.createElement("a");

		if (!document.getElementById("to5"))
		{
			alink.setAttribute("id", "to5");
			alink.setAttribute("href","수술 예약");
			to_information2_5.appendChild(alink);
			alink.appendChild(imgName5);

		} 
		else
		{
			var to5 = document.getElementById("to5");
			to5.setAttribute("href", "수술 예약");
		}

		if (!document.getElementById("to6"))
		{
			alink2.setAttribute("id", "to6");
			alink2.setAttribute("href","FAQ");
			to_information2_6.appendChild(alink2);
			alink2.appendChild(imgName6);	
		} 
		else
		{
			var to6 = document.getElementById("to6");
			to6.setAttribute("href", "FAQ");	
		}
	}
}

function DelSub()
{
	if(!document.getElementsByTagName) return false;
	if(!document.getElementById) return false;

	if(!document.getElementById("tmp1")) return false;	
	if(!document.getElementById("tmp2")) return false;
	if(!document.getElementById("tmp3")) return false;
	if(!document.getElementById("tmp4")) return false;
	if(!document.getElementById("tmp5")) return false;
	if(!document.getElementById("tmp6")) return false;
	
	var imgName1 = document.getElementById("tmp1");	
	var imgName2 = document.getElementById("tmp2");
	var imgName3 = document.getElementById("tmp3");
	var imgName4 = document.getElementById("tmp4");
	var imgName5 = document.getElementById("tmp5");
	var imgName6 = document.getElementById("tmp6");

	if(!document.getElementById("to_information2_5")) return false;
	if(!document.getElementById("to_information2_6")) return false;

	var to_information2_5 = document.getElementById("to_information2_5");
	var to_information2_6 = document.getElementById("to_information2_6");

	var to5 = document.getElementById("to5");
	var to6 = document.getElementById("to6");
	
	var link1 = "/images/common/tmp_online1.jpg";
	var link2 = "/images/common/tmp_online2.jpg";
	var link3 = "/images/common/tmp_online3.jpg";
	var link4 = "/images/common/tmp_online4.jpg";
	var link5 = "/images/common/tmp_online5.jpg";
	var link6 = "/images/common/tmp_online6.jpg";
		
	imgName1.setAttribute ("src",link1);
	
	imgName1.onmouseover= function() {
		SideImageOn('_online','1');
	}
	
	imgName1.onmouseout= function() {
		SideImageOff('_online','1');
	}

	var to1 = document.getElementById("to1");
	to1.setAttribute("href", "javascript:MakeSub('1');");

	imgName2.setAttribute ("src",link2);
	
	imgName2.onmouseover= function() {
		SideImageOn('_online','2');
	}
	
	imgName2.onmouseout= function() {
		SideImageOff('_online','2');
	}

	var to2 = document.getElementById("to2");
	to2.setAttribute("href", "전화");

	imgName3.setAttribute ("src",link3);
	
	imgName3.onmouseover= function() {
		SideImageOn('_online','3');
	}
	
	imgName3.onmouseout= function() {
		SideImageOff('_online','3');
	}
	
	var to3 = document.getElementById("to3");
	to3.setAttribute("href", "javascript:MakeSub('3');");

	imgName4.setAttribute ("src",link4);
	
	imgName4.onmouseover= function() {
		SideImageOn('_online','4');
	}
	
	imgName4.onmouseout= function() {
		SideImageOff('_online','4');
	}

	var to4 = document.getElementById("to4");
	to4.setAttribute("href", "FAQ");
	
	var imgName5 = document.createElement("img");
	imgName5.setAttribute("id","tmp5");
	imgName5.setAttribute("src",link5);
	
	var imgName6 = document.createElement("img");
	imgName6.setAttribute("id","tmp6");
	imgName6.setAttribute("src",link6);

	if (document.getElementById("to5"))
	{
		to_information2_5.removeChild(to5);
		to_information2_5.appendChild(imgName5);
	}

	if (document.getElementById("to6"))
	{
		to_information2_6.removeChild(to6);
		to_information2_6.appendChild(imgName6);
	}
}


			function goLinkURL(VarObjValue){
				var LinkURL=VarObjValue;
					if (VarObjValue.length>1){
							if (LinkURL.substring(0,7).toLowerCase()=="http://" || LinkURL.substring(0,8).toLowerCase()=="https://"){
								
								 window.open(LinkURL,"_blank");
								//  window.open(your_page,"new_win")  
							}else{
								 window.open("http://"+LinkURL,"_blank");
							}
					}
			}

			function goTopLinkURL(VarObjValue){
				var LinkURL=VarObjValue;
					if (VarObjValue.length>1){
							if (LinkURL.substring(0,7).toLowerCase()=="http://" || LinkURL.substring(0,8).toLowerCase()=="https://"){
								
									window.location.href =LinkURL;
								//  window.open(your_page,"new_win")  
							}else{
								 	window.location.href ="http://"+LinkURL;
							}
					}
			}