// ■STR 二度押し防止
var set=0;

function nidoosi() {
	if(set==0) {
		set=1;
	}else{
		alert("処理中です。\nもう少々お待ちください。");
		return false;
	}
}


// ■テーブルハイライト【マウスが乗ったとき】
function highlightOver(obj){
	obj.style.backgroundColor = "#ccffff";
	obj.style.color = "#ff0066";
//	obj.style.fontWeight = "bold";
	
}

// ■テーブルハイライト【マウスが去ったとき】
function highlightOut(obj){
	obj.style.backgroundColor = "transparent";
	obj.style.color = "black";
//	obj.style.fontWeight = "normal";
}

// ■ページトップへスクロールする
$(function(){
	try {
		$("a[href^=#]").click(function(){
			var Hash = $(this.hash);
			var HashOffset = $(Hash).offset().top;
			$("html,body").animate({ scrollTop: HashOffset }, 1000);
			return false;
		});
	} catch( e ) {}
});

/* ■IE6.0以下を排除
$(function () {
	if ( $.browser.msie && $.browser.version <= 6 ) {
		$('body').prepend('<div class="error">あなたは旧式ブラウザをご利用中です。このウェブサイトを快適に閲覧するにはブラウザをアップグレードしてください。</div>');
    }
}); */

/* ■画像が無い場合、リンク切れファイルは置き換えする
ImgfileMissing = function() {
	$('img').error(function(){
		$(this).attr({	
			 "src"	: "/55_img/common/missing_image.gif"
			,"class": "sumnail"
			,"style": "border: 1px solid #999999;width:150px;height:50px;"
		});
	});
};
$(function(){ ImgfileMissing(); });
*/

// ■Enterキー制御
$(document).ready( function () {
	try {
		$(":input").keydown(function (event) {
			
			var eventObject = event;
			
			if(window.event) {
				eventObject = window.event;
			}
			if(eventObject.keyCode == 13) {	
				
				if( $(this).is("textarea") ) { return; }
				
				inputlist = $(":input:enabled");
				currentindex = inputlist.index($(this));
				
				if(eventObject.shiftKey) {
					if(currentindex > 0) {
						currentindex -= 1;
					}
				} else {
					if(currentindex < inputlist.length -1) {
						currentindex += 1;
					}
				}
				$(":input:enabled:eq(" + currentindex + ")").focus();
				return false;
			}
		});
	} catch( e ) {}
});


$.fn.checked = function(){ return $(this).attr('checked'); }

// ■ページャー
//
var from = 1;
pagerObj = new Object();
PageClick = function(pageclickednumber) {
	
	$("#pager-under").pager({ pagenumber: pageclickednumber
					  , pagecount: ($('#list-count').val() / rows ) +1
					  , buttonClickCallback: PageClick });
	
	from	= (pageclickednumber-1)*rows;
	to 		= (pageclickednumber-1)*rows + rows;
	sum		= parseInt($('#list-count').val()) + parseInt(1);
	if( to >= sum ) { to = sum; }
	
	$("#pager-under-count").html( sum + "件中 " + (from+1) + "～" + to + "件を表示");
	
	pagerObj.method(from);
}


// ■ajax送信
AjaxSendSimple = function(call_ajax_url, send_data, error_canvas_area, f_success) {
	var result = true;
	
	$.ajax({
		  async		: true		// 非同期(true)
		, cache		: false
		, url		: call_ajax_url
		, data 		: send_data
		, dataType	: 'text'
		, type		: 'POST'
		, beforeSend: function() {}
		, complete	: function() {}
		, success 	: f_success
		, error		: function(res, status, errorThrown) {
			if (status == "error") {
				$('#' + error_canvas_area).html("失敗しました");
			} else if (status == "notmodified") {
				$('#' + error_canvas_area).html("更新されていません");
			} else if (status == "timeout") {
				$('#' + error_canvas_area).html("タイムアウト");
			} else if (status == "parsererror") {
				$('#' + error_canvas_area).html("パースエラー");
			}
			result = false;
		}
	});
	
	return result;
}

// ■ajax送信(json)
AjaxSendJson = function(call_ajax_url, send_data, error_canvas_area, f_success) {
	var result = true;
	
	$.ajax({
		  async		: false		// 非同期(true)
		, cache		: false
		, url		: call_ajax_url
		, data 		: send_data
		, dataType	: 'json'
		, type		: 'POST'
		, beforeSend: function() {}
		, complete	: function() {}
		, success 	: f_success
		, error		: function(res, status, errorThrown) {
			if (status == "error") {
				$('#' + error_canvas_area).html("失敗しました");
			} else if (status == "notmodified") {
				$('#' + error_canvas_area).html("更新されていません");
			} else if (status == "timeout") {
				$('#' + error_canvas_area).html("タイムアウト");
			} else if (status == "parsererror") {
				$('#' + error_canvas_area).html("パースエラー");
			}
			result = false;
		}
	});
	
	return result;
}


// ■ajax送信(ダイアログ(モードレス))
AjaxDialogSimple = function( dialog_name, buttonsAction ) {
	$("#"+dialog_name).dialog({
		  bgiframe	: true	
		 ,width		: 500
		 ,modal		: false
		 ,buttons	: buttonsAction
	});
}

// ■ajax送信(ダイアログ)
AjaxDialog = function( dialog_name, buttonsAction ) {
	$("#"+dialog_name).dialog({
		  bgiframe	: true	
		 ,width		: 800
		 ,modal		: true
		 ,buttons	: buttonsAction
	});
}


// ■ajax送信(ダイアログ)
AjaxDialogMap = function( dialog_name, buttonsAction ) {
	$("#"+dialog_name).dialog({
		  bgiframe	: true	
		 ,width		: 800
		 ,modal		: true
		 ,buttons	: buttonsAction
	});
}


