//検索CGIの指定
$(document).ready(function(){

$('#belt-box').append('<li id="top-searchform"><form method="get" action="http://www.it-networks.co.jp/mt/mt-search.cgi"><input title="サイト内検索" type="text" id="search" class="ti" name="search" value="" /><input type="hidden" name="IncludeBlogs" value="1,3,4" /><input type="hidden" name="limit" value="20" /><input type="submit" accesskey="4" id="search-btn" value="検索" /></form></li>');

//現在のページにclass="sopen"をつける
var nowurl=location.href;
$('ul.menu-lt a').each(
function(){
	if($(this).attr('href')==nowurl){
		$(this).parent().addClass('sopen');

	}
	
}
);

$('#search')
    .blur(function(){
      var $$=$(this);
      if($$.val()=='' || $$.val()==$$.attr('title')){
        $$.css('color', '#999')
          .val($$.attr('title'));
      }
    })
    .focus(function(){
      var $$=$(this);
      if($$.val()==$$.attr('title')){
        $(this).css('color', '#000')
               .val('');
      }
    })
    .parents('form:first').submit(function(){
      var $$=$('#search');
      if($$.val()==$$.attr('title')){
        $$.triggerHandler('focus');
      }
    }).end()
    .blur();

});

//新しいウィンドウの設定
var Newwin = function(){
	
	this.blank = function(){
		if(!document.getElementsByTagName){
			return;
		}

		var cnt;
		var anchors	= document.getElementsByTagName("a");
		var anchor;

		cnt = anchors.length;
		for(var y = 0; y < cnt; y++){
			anchor = anchors[y];

			if(
			anchor.getAttribute("href")&&
			!anchor.getAttribute("target")&&
			anchor.getAttribute("href",2).indexOf("it-networks.co.jp",0) == -1&&
			anchor.getAttribute("href",2).indexOf("http://",0)>-1
			) {
				anchor.target = "_blank";
			}
		}
	}
}

var neww = new Newwin().blank;

if (window.addEventListener) { //for W3C DOM
  window.addEventListener("load", neww, false);
} else if (window.attachEvent) { //for IE
  window.attachEvent("onload", neww);
} else  {
  window.onload = neww;
}
