//オンロードイベント複数
function addOnloadEvent(fnc){  
  if ( typeof window.addEventListener != "undefined" )  
    window.addEventListener( "load", fnc, false );  
  else if ( typeof window.attachEvent != "undefined" ) {  
    window.attachEvent( "onload", fnc );  
  }  
  else {  
    if ( window.onload != null ) {  
      var oldOnload = window.onload;  
      window.onload = function ( e ) {  
        oldOnload( e );  
        window[fnc]();  
      };  
    }  
    else  
      window.onload = fnc;  
  }  
}
//小ウィンドウオープン
function ow(url,myWidth,myHeight,myWin){

	if(!myWidth ) myWidth=400
	if(!myHeight) myHeight=350
	if(!myWin   ) myWin='_blank'
	myWin=window.open( url,myWin,"resizable=yes,scrollbars=yes,width="+myWidth+",height="+myHeight);
	myWin.focus();
}
//class="on"付きimgホバー実装
jQuery(document).ready(function($) {
	var postfix = '_on';
	$('img.on').not('[src*="'+ postfix +'."]').each(function() {
		var img = $(this);
		var src = img.attr('src');
		var src_on = src.substr(0, src.lastIndexOf('.'))
		           + postfix
		           + src.substring(src.lastIndexOf('.'));
		$('<img>').attr('src', src_on);
		img.hover(
			function() {
				img.attr('src', src_on);
			},
			function() {
				img.attr('src', src);
			}
		);
	});
});
//inputデフォルトの文字列処理：キーワード検索

function setFocus( that) {		
	that._defaultValue = that.value;		
	that.value = '';		
	that.onblur = function() {			
		if( that.value === '' ) {				
			that.value = that._defaultValue;			
		}		
	}		
	that.onfocus = function() {			
		if( that.value === that._defaultValue ) {				
			that.value = '';			
		}		
	}	
}

//Jqueryによる実装部分
$(document).ready(function() {	
//メニュー実装部分
	$("#topnav li").prepend("<span></span>"); //Throws an empty span tag right before the a tag	
	$("#topnav li").each(function() { //For each list item...
		var linkText = $(this).find("a").html(); //Find the text inside of the a tag
		$(this).find("span").show().html(linkText); //Add the text in the span tag
	}); 	
	$("#topnav li").hover(function() {	//On hover...
		$(this).find("span").stop().animate({ 
			marginTop: "-72" //Find the span tag and move it up 40 pixels
		}, 250);
	} , function() { //On hover out...
		$(this).find("span").stop().animate({
			marginTop: "0" //Move the span back to its original state (0px)
		}, 250);
	});
//外部リンク実装部分
	$('a[rel=_blank]').click(function(){
		this.target = "_blank";
	});
		//IEのリンク点線消す処理
		function links_outline() {
			var blur = function () { this.blur() };
			for (var i = 0; i < document.links.length; i++)
			document.links[i].onfocus = blur;
		}		
			links_outline();






		
});
//アンカースムース
$(document).ready(function(){
  $('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
    && location.hostname == this.hostname) {
      var $target = $(this.hash);
      $target = $target.length && $target
      || $('[name=' + this.hash.slice(1) +']');
      if ($target.length) {
        var targetOffset = $target.offset().top;
        $('html,body')
        .animate({scrollTop: targetOffset}, 1000);
       return false;
      }
    }
  });
});

//inputの入力例薄表示
jQuery(document).ready(function($) {
	$('input[title!=""]').hint();
});

