
function AdbookSearch(tg, key, str){
	var op = '';
	
	if(tg=='search'){
		op += '&q=' + $( 'adbook_q' ).value;
		op += '&pg=' + key;
		
	}else{
		op += '&key=' + key;
		if(key=='addasin' || key=='del'){
			op += '&str=' + str;
		}
	}

	/*データ更新*/
	new Ajax.Request( '../adbook_search.php', 
						{
							method: 'post', 
							parameters: 'tg=' + tg + op,
							onLoading:  AdbookSearchShowLoading(tg),
							onComplete:  AdbookSearchDisplayData
						}				
					);
}

function AdbookSearchShowLoading(tg) {

	Element.hide( 'adbook_' + tg);
	$( 'adbook_' + tg).innerHTML = '<img src="../images/loading_s.gif" style="vertical-align:middle;" /> ';
	Element.show( 'adbook_' + tg);
}

function AdbookSearchDisplayData(httpObj){

	var res_ary = httpObj.responseText.split('||');
	var span_name = res_ary[0];
	$(span_name).innerHTML = res_ary[1];
	Element.show(span_name);

}

function ExhibitDate(start_year, start_month, start_day, end_year, end_month, end_day){
	var str = '';
	str += start_year +'年' + start_month + '月' + start_day + '日 12時 ～ ';
	str += end_year +'年' + end_month + '月' + end_day + '日 12時';
	str += '<input type="hidden" name="adbook_exhibit_date" id="adbook_exhibit_date" value="'+ start_year + '-' + start_month + '-' + start_day + '">' + "\n";
	str += '&nbsp;&nbsp;<input type="button" value="変更" onclick="javascript:ExhibitDateModify();">' + "\n";

	$( 'exhibit_date' ).innerHTML = str;
	$( 'exhibit_date' ).style.display = "";
	$( 'exhibit_calender' ).style.display = "none";
}

function ExhibitDateModify(){
	$( 'exhibit_date' ).style.display = 'none';
	$( 'exhibit_calender' ).style.display = "";
}

function ExhibitASIN(asin_num, image, title){
	var str = '';
	str += decodeURIComponent(image) + '<br />';
	str += decodeURIComponent(title);
	str += '<input type="hidden" name="adbook_exhibit_asin" id="adbook_exhibit_asin" value="'+ asin_num + '">' + "\n";
	str += '<input type="hidden" name="adbook_exhibit_image" id="adbook_exhibit_image" value="'+ image + '">' + "\n";
	str += '<input type="hidden" name="adbook_exhibit_title" id="adbook_exhibit_title" value="'+ title + '">' + "\n";
	str += '&nbsp;&nbsp;<input type="button" value="変更" onclick="javascript:ExhibitASINModify();">' + "\n";

	$( 'exhibit_asin' ).innerHTML = str;
	$( 'exhibit_asin' ).style.display = "";
	$( 'exhibit_search' ).style.display = "none";
}

function ExhibitASINModify(){
	$( 'exhibit_asin' ).style.display = 'none';
	$( 'exhibit_search' ).style.display = "";
}


function adbook_check(){
	var err = 0;
	var err_msg = "";
	
	if( document.getElementById("adbook_exhibit_date") == null) {
		err = 1;
		err_msg = "出品日を選択してください。\n";
	}
	if( document.getElementById("adbook_exhibit_asin") == null) {
		err = 1;
		err_msg = err_msg + "献本を選択してください。\n";
	}
		
	if(err == 1) {
		alert(err_msg);
		return false;
	}

}

function rating_check(){
	var err = 0;
	var err_msg = "";

	if( $('adbook_rating_grade').value == 0) {
		err = 1;
		err_msg = "評価を選択してください。\n";
	}

	if( $('adbook_rating_comment').value == "") {
		err = 1;
		err_msg = err_msg + "コメントを入力してください。\n";
	}

	if(err == 1){
		alert(err_msg);
		return false;
	
	}else{
		var action = confirm('この評価でよろしいですか？');
		if(action==true){
			return true;
		}else{
			return false;
		}
	}

}

function noticeRow(num) {
	notice = document.getElementById("dt"+num).style;
	if (notice.display == "none") {
	  	notice.display = "" ;
	}else{
		notice.display = "none" ;
	}
}



