yearObj = {
	showYear : function(target){
		var today = new Date();
		var year = today.getFullYear();
		var target = document.getElementById(target);
		target.innerHTML = year+" ";
	}
};

function _getDate(){
	var today = new Date();
	var year = today.getFullYear();
	var month = today.getMonth()+1;
	var day = today.getDate();
	var weekTemp = today.getDay();
	var weekArray = ["日","月","火","水","木","金","土"];
	var week = weekArray[weekTemp];
	document.write(year+"年"+month+"月"+day+"日"+"（"+week+"）");
}


// ページの先頭に戻る
function backToTop() {
  var x1 = x2 = x3 = 0;
  var y1 = y2 = y3 = 0;
  if (document.documentElement) {
      x1 = document.documentElement.scrollLeft || 0;
      y1 = document.documentElement.scrollTop || 0;
  }
  if (document.body) {
      x2 = document.body.scrollLeft || 0;
      y2 = document.body.scrollTop || 0;
  }
  x3 = window.scrollX || 0;
  y3 = window.scrollY || 0;
  var x = Math.max(x1, Math.max(x2, x3));
  var y = Math.max(y1, Math.max(y2, y3));
  window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));
  if (x > 0 || y > 0) {
      window.setTimeout("backToTop()", 25);
  }
}

function _reset(){
	var flg  = confirm("入力内容を全てリセットしてよろしいですか？");
	if(flg==true){
		for(var i=0; i<document.forms.length; i++){
			document.forms[i].reset();
		}
	}
	return false;
}


// ポップアップヘルプ
$(document).ready(function(){
	setPopup("#help1","#popupHelp1");
	setPopup("#help2","#popupHelp2");
})

function setPopup(targetElement,popupElement){
	$(popupElement).hide();
	
	$(targetElement).mouseover(function(event){
		$(popupElement).css("left",event.pageX+10);
		$(popupElement).css("top",event.pageY+5);
		$(popupElement).show();
	})
	$(targetElement).mouseout(function(event){
		$(popupElement).hide();
	})
}


// テーブル行の色
$(document).ready(function(){
	$('div.data table tr:even').addClass('even-row');
})


function toSubmit(fm, action, method) {
	if (action != null && action != '') {
		fm.action = action;
	}
	if (method != null && method != '') {
		fm.method = method;
	}
	return fm.submit();
}


// 全選択＆全解除
$(function() { 
	$('a.allCheck').click(function(){
		$("input[name='city[]']").attr('checked', true);
		return false;
	});

	$('a.allUncheck').click(function(){
		$("input[name='city[]']").attr('checked', false);
		return false;
	});
});
