/*****************************
 * (c)ウェブシステムズ
 * http://www.websystems.jp/
 *****************************/

$(function()
{
	// table#itiran
	$('tr:even', $('.itiran tbody')).addClass('even');

	// pager
	$('select[@name="view"]').change(function(){
		var v = this.options[this.selectedIndex].value;
		if (v) {
			var data = "action=setCookie&name="+pager_name+"&value="+v+"&url="+pager_url;
			$.ajax({
				type: "GET",
				url: "./",
				data: data,
				dataType: "script"
//				success: function(res){ alert(res);}
			});
		}
	});

	//sort
	$('a', $('.itiran th')).each(function(){
		$(this).click(function(){
			var v = $(this).attr('id').split('-');
			var data = "action=setSort&name="+v[0]+"&value="+v[1]+"&url="+pager_url;
			$.ajax({
				type: "GET",
				url: "./",
				data: data,
				dataType: "script"
				//success: function(res){ alert(res);}
			});
			return false;
		});
	});

	// a.btn_del
	$('a.btn_del').click(function(){
		return confirm("このデータを削除してよろしいですか？");
	});


	//まとめて問合せチェックボックス
	$('.inq_chk').each(function(){
		$(this).click(function(){
			var checked = $(this).attr('checked');
			var flg = 0;
			if(checked){
				flg = 1;
			}
			var seq = $(this).attr('id').split('_').pop();
			var buf = $(this).attr('id').split('_');
			var lb = "";
			if(buf[0] != "chk"){
				lb = buf[0]+'_'+buf[1];
			}

			//alert(lb);

			var data = "action=setInq&seq_no="+seq+"&flg="+flg+"&url="+pager_url+"&lb="+lb;
			$.ajax({
				type: "GET",
				url: "./",
				data: data,
				dataType: "text"
				//success: function(res){ alert(res);}
			});
		});
	});

	//まとめてpdfチェックボックス
	$('.pdf_chk').each(function(){
		$(this).click(function(){
			var checked = $(this).attr('checked');
			var flg = 0;
			if(checked){
				flg = 1;
			}
			var seq = $(this).attr('id').split('_').pop();
			var buf = $(this).attr('id').split('_');
			var lb = "";
			if(buf[0] != "pdf"){
				lb = buf[0]+'_'+buf[1];
			}

			//alert(lb);

			var data = "action=setPdf&seq_no="+seq+"&flg="+flg+"&url="+pager_url+"&lb="+lb;
			$.ajax({
				type: "GET",
				url: "./",
				data: data,
				dataType: "text"
				//success: function(res){ alert(res);}
			});
		});
	});

	//詳細PDFリンク
	$('.set_pdf').click(function(){
		var seq = $(this).attr('id').split('_').pop();
		var buf = $(this).attr('id').split('_');
		var lb = "";
		if(buf[0] != "tintai"){
			lb = buf[0]+'_'+buf[1];
		}else{
			lb = "tintai";
		}

		var data = "action=setPdf&seq_no="+seq+"&flg=1&lb="+lb;
		$.ajax({
			type: "GET",
			url: "./",
			data: data,
			dataType: "text"
			//success: function(res){ alert(res);}
		});
	});
});

