// JavaScript Document

//Target_Blank
$(function(){
     $("a[href^='http://']").attr("target","_blank");
});


//RollOver
function initRollOverImages() {
  var image_cache = new Object();
  $(".swap").each(function(i) {
    var imgsrc = this.src;
    var dot = this.src.lastIndexOf('.');
    var imgsrc_on = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
    image_cache[this.src] = new Image();
    image_cache[this.src].src = imgsrc_on;
    $(this).hover(
      function() { this.src = imgsrc_on; },
      function() { this.src = imgsrc; });
  });
}

$(document).ready(initRollOverImages);

//Scroll
$(function(){
   // #で始まるアンカーをクリックした場合に処理
   $('a[href^=#]').click(function() {
      // スクロールの速度
      var speed = 400;// ミリ秒
      // アンカーの値取得
      var href= $(this).attr("href");
      // 移動先を取得
      var target = $(href == "#" || href == "" ? 'html' : href);
      // 移動先を数値で取得
      var position = target.offset().top;
      // スムーススクロール
      $($.browser.safari ? 'body' : 'html').animate({scrollTop:position}, speed, 'swing');
      return false;
   });
});

//form 

function btnConform(){
	var inputs = document.getElementsByTagName("input");
	for( var i=0,j=inputs.length; i<j; i++){
		var btn = inputs[i]; 
		if(btn.getAttribute("class") == "input_btn"){
			btn.onmouseover = function(){
				this.style.backgroundPosition = 'left -20px';
				return false;
			}
			btn.onmouseout = function(){
				this.style.backgroundPosition = 'left top';
				return false;
			}
		}
		if(btn.getAttribute("className") == "input_btn"){
			btn.onmouseover = function(){
				this.style.backgroundPosition = 'left -20px';
				return false;
			}
			btn.onmouseout = function(){
				this.style.backgroundPosition = 'left top';
				return false;
			}
		}

		if(btn.getAttribute("class") == "input_btn02"){
			btn.onmouseover = function(){
				this.style.backgroundPosition = 'left -41px';
				return false;
			}
			btn.onmouseout = function(){
				this.style.backgroundPosition = 'left top';
				return false;
			}
		}
		if(btn.getAttribute("className") == "input_btn02"){
			btn.onmouseover = function(){
				this.style.backgroundPosition = 'left -41px';
				return false;
			}
			btn.onmouseout = function(){
				this.style.backgroundPosition = 'left top';
				return false;
			}
		}

	}
}

window.onload = btnConform;


