var sRepeat=null;
var scrLeft=0;
function doScrollerIE(dir, src, amount){
	var scrollObj = document.getElementById(src);
	scrollObj.scrollLeft = scrLeft;

	if (amount==null) amount=20;
	if (dir=="right") {
		scrollObj.scrollLeft-=amount;
	} else {
		scrollObj.scrollLeft+=amount;
	}

	if (sRepeat==null){
		sRepeat = setInterval("doScrollerIE('" + dir + "','" + src + "'," + amount + ")",1);
	}

	scrLeft = scrollObj.scrollLeft;
	return false
}

window.document.onmouseout = new Function("clearInterval(sRepeat);sRepeat=null");
window.document.ondragstart = new Function("return false");

function goCfPopUp(id){

	location.href = "/report/" + id + "/";

}


function amazon_get(id){

	Event.observe(window, 'load',function(){
		new Ajax.Request('/actor/amazon_get.php?id=' + id,{method:'get',
		onComplete : function( httpObject ){$('amazon_get').innerHTML = httpObject.responseText;}
		}
		);
	}
	);

}


// comment write
function comment_create(){

	if(!document.form_comment.comment.value) {alert("コメントを入力してください。");document.form_comment.comment.focus(); return false;}

	var str = Form.serialize('form_comment');

	document.getElementById('sendBtn').disabled = true;

	new Ajax.Request("/actor/comment.php",{"method": "post","parameters": str,
		onSuccess: function(httpObject) {
			comment_create_msg(httpObject.responseText);
		}
	}
	);

}


function comment_create_msg(text_data) {

	var lines = new Array();

	var lines = text_data.split("\n");

	var result = lines.shift();

	if(result != 'OK'){

		alert("書き込み出来ませんでした。");

	}

	document.getElementById('sendBtn').disabled = false;

	document.location.reload();

	return;

}


// comment delete
function comment_del(id){

	if(confirm("削除しますか？")){
		new Ajax.Request('/actor/comment.php?trn=delete&id=' + id,{method:'get',
		onSuccess : function( httpObject ) {
			comment_del_msg(httpObject.responseText);
		}
		});

	}

	return false;

}


// comment delete message
function comment_del_msg(text_data) {

	var lines = new Array();

	var lines = text_data.split("\n");

	// OKかNGかを読み取る
	var result = lines.shift();

	// 結果ごとの処理
	if(result == 'OK'){

		alert("削除しました。");

	}else{

		alert("削除出来ませんでした。");

	}

	document.location.reload();
	
	return;

}


// comment delete request
function comment_del_req(id){

	if(confirm("削除依頼しますか？")){
		new Ajax.Request('/actor/comment.php?trn=delete_req&id=' + id,{method:'get',
		onSuccess : function( httpObject ) {
			comment_del_req_msg(httpObject.responseText);
		}
		});

	}

	return false;

}


// comment delete request message
function comment_del_req_msg(text_data) {

	var lines = new Array();

	var lines = text_data.split("\n");

	// OKかNGかを読み取る
	var result = lines.shift();

	// 結果ごとの処理
	if(result == 'OK'){

		alert("削除依頼しました。");

	}else{

		alert("削除依頼出来ませんでした。");

	}

	//document.location.reload();

	return;

}

function emotshow(){
	var open = $('personacon').style.display;
	if (open == "none"){
		$('personacon').style.display = "block";
		$('prs_hidden').style.height = '24px';
	}else{
		$('personacon').style.display = "none";
		$('prs_hidden').style.height = '0px';
	}
}

function setemot(e,emot){
	var evt = e || window.event;

	document.form_comment.myemot.width = 16;
	document.form_comment.myemot.height = 16;
	document.form_comment.myemot.src = "/image/common/comment/emoticon/" + emot + ".gif";
	document.form_comment.emoticon.value =  emot;
	document.getElementById("personacon").style.display = "none";

	if (evt.stopPropagation) {
		evt.stopPropagation();
	} else {
		evt.cancelBubble = true;
	}

}

function setpersonaconemot(e, emot){
	var evt = e || window.event;

	document.form_comment.myemot.width = 16;
	document.form_comment.myemot.height = 16;
	document.form_comment.myemot.src = "/image/common/emoticon/" + emot + ".gif";
	document.form_comment.emoticon.value = emot;
	document.getElementById("personacon").style.display = "none";

	if (evt.stopPropagation) {
		evt.stopPropagation();
	} else {
		evt.cancelBubble = true;
	}

}

function hiddenPersonalIcon(){
	$("personacon").style.display = "none";
}

