/* 1122 Menu JS */

addEvent(window, 'load', load);
var popID;
var tID;

function load()
{
	inMenu = false;
	body = document.getElementsByTagName("body")[0];
	last = null;

	var clinic = new MenuP(getNode("clinic"));
	var corp = new MenuP(getNode("corp"));
	var staff = new MenuP(getNode("staff"));
	var animal = new MenuP(getNode("animal"));

	clinic.add(new Menu("診察時間・休診日", "/clinic/clinic.php"));
	clinic.add(new Menu("診療方針・体制", "/clinic/policy.php"));
	clinic.create();

	corp.add(new Menu("メッセージ", "/corp/info.php"));
	corp.add(new Menu("当院のご案内", "/corp/fukui.php"));
	//corp.add(new Menu("採用情報", "/corp/recruit.php"));
	corp.create();

	staff.add(new Menu("獣医師の紹介", "/staff/vetz.php"));
	staff.add(new Menu("スタッフの紹介", "/staff/staff.php"));
	staff.create();

	animal.add(new Menu("動物愛護", "/animal/care.php"));
	animal.add(new Menu("献血ご協力", "/animal/donor.php"));
	animal.add(new Menu("病気の予防アドバイス", "/animal/preventive.php"));
	animal.add(new Menu("レーザー治療について", "/animal/laser_therapy.php"));
	animal.add(new Menu("子犬のしつけ教室", "/animal/train.php"));
	animal.add(new Menu("里親探し情報", "/animal/foster.php"));
	//animal.add(new Menu("よくある質問", "/animal/faq.php"));
	animal.create();
}

function MenuP(a){this.node=a;this.menuItems=new Array();MenuP.prototype.add=function(b){this.menuItems[this.menuItems.length]=b};MenuP.prototype.create=function(){var f=document.createElement("div");f.className="jsMenu";var e="_"+this.node.id;f.setAttribute("id",e);var b=this.node.offsetWidth;f.style.width=b>160?b+"px":"160px";f.style.top=(this.node.offsetTop+this.node.offsetHeight)+"px";f.style.left=this.node.offsetLeft+"px";addEvent(this.node,"mouseover",function(){showMenuInTime(e,150)});addEvent(this.node,"mouseout",function(){setInMenu(false)});f.setAttribute("pItemID",this.node.id);addEvent(f,"mouseover",function(){setInMenu(true)});addEvent(f,"mouseout",function(){setInMenu(false)});var d="<ul>";for(var c=0;c<this.menuItems.length;c++){d+=this.menuItems[c].getLinkHTML()}body.appendChild(f);f.innerHTML=d+"</ul>"}}function Menu(b,a){this.value=(b==null)?"":b;this.href=(a==null)?"":a;if(this.href!=""&&typeof useAbsPath!="undefined"){if(useAbsPath&&this.href.indexOf("http://")==-1&&this.href.indexOf("https://")==-1){this.href="http://www.1122shibata.jp"+this.href}}Menu.prototype.getLinkHTML=function(){if(this.value!=""&&this.href!=""){return'<li><a onclick="setInMenu(false); hideMenu(); return true;" onkeypress="setInMenu(false); hideMenu(); return true;" href="'+this.href+'">'+this.value+"</a></li>"}else{if(this.value!=""&&this.href==""){return"<li class='heading'>"+this.value+"</li>"}else{return"<li class='separator'>&nbsp;</li>"}}}}function showMenuInTime(a,b){popID=setTimeout("showMenu('"+a+"')",b)}function showMenu(e){clearTimeout(popID);if(typeof e=="string"){e=getNode(e)}if(last!=null&&last!=e){hideMenu(last)}else{if(last==e){setInMenu(true);return}}var c=getNode(e.getAttribute("pItemID"));var f=0;var d=c.offsetHeight;var b=c;while(b.tagName!="BODY"){if(b.tagName=="html:body"){break}f+=b.offsetLeft;d+=b.offsetTop;b=b.offsetParent}e.style.left=f+"px";e.style.top=d+"px";var a=c.offsetWidth;e.style.width=a>140?a+"px":"140px";e.style.display="block";setInMenu(true);last=e;tID=setTimeout("hideMenu(last)",500)}function hideMenu(b){if(b==null){setInMenu(false);hideMenu(last);return}if(typeof b=="string"){b=getNode(b)}if(!inMenu){b.style.display="none";var a=getNode(b.getAttribute("pItemID"));last=null;clearTimeout(tID)}else{tID=setTimeout("hideMenu(last)",500)}}function setInMenu(a){inMenu=a;if(!a){clearTimeout(popID)}}function addEvent(b,c,a){if(b.addEventListener){b.addEventListener(c,a,false);return true}else{if(b.attachEvent){return b.attachEvent("on"+c,a)}else{return false}}}function getNode(a){if(document.getElementById){return document.getElementById(a)}else{if(document.all&&document.all(a)){return document.all(a)}else{if(document.layers&&document.layers[a]){return document.layers[a]}else{return false}}}};



/* /////////////// 1122_lib.js - ProtoType //////////////////////////////////////////// */
/* Scrolling */
(function(){function a(){$$("a[href^='#']:not([href='#'])").each(function(b){b.observe("click",function(c){new Effect.ScrollTo(this.hash.substr(1));Event.stop(c)}.bindAsEventListener(b))})}Event.observe(window,"load",a,false)})();

/* Calender ShowHide */
(function(){function b(){Event.observe($("dayCld"),"click",function(){a=$("vetCalender").style;a.display=a.display=="block"?"none":"block"},false)}Event.observe(window,"load",b,false)})();

/* Show-Hide for Preventive page */
function munus_swapTx(a){if(document.getElementById){var c="munus_tx_"+a;var b="wit_"+a;document.getElementById(c).className=(document.getElementById(c).className=="open")?"closed":"open";document.getElementById(b).src=(document.getElementById(c).className=="open")?"../media/img_btn/bt_minus.gif":"../media/img_btn/bt_plus.gif"}}var expanded=0;function exAll(){if(document.getElementsByTagName){var c=document.getElementsByTagName("li");for(var a=0;a<c.length;a++){if(c[a].id.indexOf("munus_tx")!=-1){c[a].className=(expanded)?"closed":"open";var b="wit_"+c[a].id.replace("munus_tx_","");c[a].className=(expanded)?"closed":"open";document.getElementById(b).src=(expanded)?"../media/img_btn/bt_plus.gif":"../media/img_btn/bt_minus.gif"}}expanded=(expanded==1)?0:1}};

/* expAll Mouse Over */
(function(){function a(){var b=$A(document.getElementsByClassName("expAll"));b.each(function(c){c.onmouseover=function(){this.style.color="#03f";this.style.backgroundColor="#9f3"};c.onmouseout=function(){this.style.color="#fff";this.style.backgroundColor="#00ac96"}})}Event.observe(window,"load",a,false)})();

/* TextArea Change */
var flag=0;var flag2=0;function doclear(a){if(a=="email"){if(flag==0){flag=1;document.egg.email.value=""}}else{if(a=="comment"){if(flag2==0){flag2=1;document.egg.comment.value=""}}else{document.egg.email.value="";document.egg.comment.value=""}}};

/* Scriptaculous MouseOver Effect */
(function(){function a(){var b=$A(document.getElementsByClassName("over"));b.each(function(c){c.onmouseover=function(){new Effect.Opacity(this,{from:1,to:0.5,duration:0.5})};c.onmouseout=function(){new Effect.Opacity(this,{from:0.5,to:1,duration:0.5})}})}Event.observe(window,"load",a,false)})();
(function(){function b(){var a=$A(document.getElementsByClassName("over2"));a.each(function(d){d.onmouseover=function(){new Effect.Fade(this,{from:0.5,to:1})}})}Event.observe(window,"load",b,false)})();

/* Swap and Popup for prototype.js */
(function(){function b(){var c=$A(document.getElementsByClassName("swap"));c.each(function(e){e.imgsrc=e.src;var d=e.src.lastIndexOf(".");e.imgsrc_on=e.src.substr(0,d)+"_on"+e.src.substr(d,4);new Image().src=e.imgsrc_on;e.onmouseover=function(){this.src=this.imgsrc_on};e.onmouseout=function(){this.src=this.imgsrc}})}function a(){var c=$A(document.getElementsByTagName("a"));c.each(function(e){if(e.getAttribute("rel")){var d=e.getAttribute("rel");if(d.indexOf("popup")==0){e.onclick=function(){var f=this.rel.replace(/^[^\?]+\??/,"").replace(/&/g,",");var g=this.rel.replace(/\?.*$/,"").replace(/^popup_/,"");window.open(this.href,g,f).focus();return false}}}})}Event.observe(window,"load",b,false);Event.observe(window,"load",a,false)})();

