/* head searchbox text */
$(document).ready(function(){
  $('#query')
    .blur(function(){
      var $$=$(this);
      if($$.val()=='' || $$.val()==$$.attr('title')){
        $$.css('color', '#696969')
          .val($$.attr('title'));
      }
    })
    .focus(function(){
      var $$=$(this);
      if($$.val()==$$.attr('title')){
        $(this).css('color', '#000')
               .val('');
      }
    })
    .parents('form:first').submit(function(){
      var $$=$('#query');
      if($$.val()==$$.attr('title')){
        $$.triggerHandler('focus');
      }
    }).end()
    .blur();
  });

/* font size */
var minValue=8;
var maxValue=13;

$(document).ready(function(){
	var ChildElements=$('#contentsWrap');

    $("#inc_font").click(function(){
		var fontSizeNew=parseInt(($('#contentsWrap').css("font-size")).replace(/px/,"px"));
		if(fontSizeNew!=maxValue){fontSizeNew += 1;}
		ChildElements.css("font-size",fontSizeNew+"px");
    });

    $("#dec_font").click(function(){
		var fontSizeNew=parseInt(($('#contentsWrap').css("font-size")).replace(/px/,"px"));
		if(fontSizeNew!=minValue){fontSizeNew -= 1;}
		ChildElements.css("font-size",fontSizeNew+"px");
    });
});

/* dropdown list */
$(function() {
	if ($.browser.msie && $.browser.version.substr(0,1)<7)
	{
$('li').has('ul').mouseover(function(){
$(this).children('ul').show();
}).mouseout(function(){
$(this).children('ul').hide();
})
	}
});




/* external */
$(document).ready(function() {

   //外部リンクは全て別ウインドウにする場合
	var domain = location.href.match(/^https?(:\/\/[a-zA-Z0-9.]+)\//i)[1];
		$('a[href^=http]').not('[href*="'+domain+'"]').attr('target','_blank');

   //rel="external" 属性を追加した場合のみ別ウインドウにする場合
		$("a[rel='external']").click(function(){
			this.target = "_blank";
   });
});

/* Rollover */
function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");
		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_off."))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
				}
			}
		}
	}
}
if(window.addEventListener) {
	window.addEventListener("load", smartRollover, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", smartRollover);
}

/* eve */
$(document).ready(function(){
  $("ul").each(function(){
    jQuery(this).find("li:even").addClass("even");
  });
});

