/* Dropdown Menu - by Ryo Watanabe */
$(document).ready(function(){
  ddmenu($('#ubutton > a'),$('#ubutton ul'));
	ddmenu($('#ibutton > a'),$('#ibutton ul'));
  $(document).click(function(){
    $("*").removeClass("hover");
  });
  $("#ubutton,#ibutton").click(function(event){
    event.stopPropagation();
  });

  /* Toggle Search Box Text */
	$("#searchbox").focus(function(){
    if($(this).val() == "Search TUJ website" || $(this).val() == "サイト内を検索する"){
		  $(this).val("");
		}
	});
	$("#searchbox").blur(function(){
    if($(this).val() == ""){
		  $("#searchbox").val("Search TUJ website");
			$(".ja #searchbox").val("サイト内を検索する");
		}
	});
	
	/* Hide URLBar for iPhone*/
	hideUrlBar();
});

/* for dropdown menu */
function ddmenu(button,menu){
  $(button).click(function(){
    if($(menu).hasClass("hover")){
      $(menu).removeClass("hover");
		}else{
      $("*").removeClass("hover");
      $(menu).addClass("hover");
    }
    return false;
  });
}

/* for hiding Mobile Safari URL bar - see: http://remysharp.com/2010/08/05/doing-it-right-skipping-the-iphone-url-bar/ */
function hideUrlBar(){
  /iPhone/.test(navigator.userAgent) && !location.hash && setTimeout(function () {
    pageYOffset || window.scrollTo(0, 1);
  }, 1000);
}
