
// スクラップ記事登録処理変数
var xmlHttp_scrapIns;

// スクラップ記事登録処理
function InsScrapData(url,mypdid,aid){

	// ブラウザに対応したオブジェクトを取得
	xmlHttp_scrapIns = null;
	if(window.XMLHttpRequest){
		xmlHttp_scrapIns = new XMLHttpRequest();
	}else if(window.ActiveXObject){
		try{
			xmlHttp_scrapIns = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			xmlHttp_scrapIns = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}

	// オブジェクトの取得のチェック
	if(xmlHttp_scrapIns != null) {
		// URLの取得
		var strReqUrl = url;
		//strReqUrl = strReqUrl.replace("?", "/?");

		// データ取得完了時のイベント設定
		xmlHttp_scrapIns.onreadystatechange = eventInsScrapData;
		xmlHttp_scrapIns.open("POST", strReqUrl, true);
		xmlHttp_scrapIns.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); 
		xmlHttp_scrapIns.send("post_mypdid=" + mypdid + "&post_artid=" + aid);
		//xmlHttp_scrapIns.open("GET", strReqUrl, true);
		//xmlHttp_scrapIns.send(null);
	}else{
		alert("error");
	}
}

// スクラップ記事登録処理完了時
function eventInsScrapData(){
	// 結果を取得した場合
	if (xmlHttp_scrapIns.readyState == 4 && xmlHttp_scrapIns.status == 200){
		alert("スクラップ記事を登録しました。");
	}
}

// スクラップ記事削除処理変数
var xmlHttp_scrapDel;
var urlBack_scrapDel;

// スクラップ記事削除処理
function DelScrapData(url,backurl,mypdid){
	// 戻るURLの保持
	urlBack_scrapDel = backurl;

	// 記事IDの取得
	var strIds = "";
	var blnDel = false;
	for(i = 0; i < document.formscrap.length; i++){
		if(document.formscrap[i].name != 'allCheck_Above' && document.formscrap[i].name != 'allCheck_Under'){
			if(document.formscrap['check' + i].checked == true){
				if(!blnDel){
					blnDel = true;
				}else{
					strIds += ",";
				}
				strIds += document.formscrap['check' + i].value;
			}
		}

	}

	// チェックされていない場合は動作しない
	if(strIds != ""){

		// ブラウザに対応したオブジェクトを取得
		xmlHttp_scrapDel = null;
		if(window.XMLHttpRequest){
			xmlHttp_scrapDel = new XMLHttpRequest();
		}else if(window.ActiveXObject){
			try{
				xmlHttp_scrapDel = new ActiveXObject("Msxml2.XMLHTTP");
			}catch(e){
				xmlHttp_scrapDel = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}

		// オブジェクトの取得のチェック
		if(xmlHttp_scrapDel != null) {
			// URLの取得
			var strReqUrl = url;
			//strReqUrl = strReqUrl.replace("?", "/?");

			// データ取得完了時のイベント設定
			xmlHttp_scrapDel.onreadystatechange = eventDelScrapData;
			xmlHttp_scrapDel.open("POST", strReqUrl, true);
			xmlHttp_scrapDel.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); 
			xmlHttp_scrapDel.send("post_mypdid=" + mypdid + "&post_artids=" + strIds);
			//xmlHttp_scrapDel.open("GET", strReqUrl, true);
			//xmlHttp_scrapDel.send(null);
		}else{
			alert("error");
		}
	}
}

// スクラップ記事削除処理完了時
function eventDelScrapData(){
	// 結果を取得した場合
	if (xmlHttp_scrapDel.readyState == 4 && xmlHttp_scrapDel.status == 200){
		// URLを更新します
		window.open(urlBack_scrapDel, '_self');
	}
}


// スクラップ記事印刷表示処理変数
var xmlHttp_ScrapPrint;

// スクラップ記事印刷表示処理
function PrintScrapData(url){

	// 記事IDの取得
	var strIds = "";
	var blnDel = false;
	for(i = 0; i < document.formscrap.length; i++){

		if(document.formscrap[i].name != 'allCheck_Above' && document.formscrap[i].name != 'allCheck_Under'){

			if(document.formscrap['check' + i].checked == true){
				if(!blnDel){
					blnDel = true;
				}else{
					strIds += ",";
				}
				strIds += document.formscrap['check' + i].value;
			}
		}
	}
	if(strIds != ""){
		var strUrl = url;
		strUrl = strUrl.replace("artids=", "artids=" + strIds);
		window.open(strUrl, "window_name", "width=1000,height=800,scrollbars=yes,resizable=yes,status=yes");
	}else{
		alert("記事が選択されていません。");
	}
}

function checkAllCheckBox(allcheckobj,checkboxCount){

	for(i = 1; i <= checkboxCount; i++){
		if(allcheckobj.checked == true){
			document.formscrap['check' + i].checked = true;
			document.formscrap['allCheck_Above'].checked = true;
			document.formscrap['allCheck_Under'].checked = true;
		}else{
			document.formscrap['check' + i].checked = false;
			document.formscrap['allCheck_Above'].checked = false;
			document.formscrap['allCheck_Under'].checked = false;
		}
	}

}