//Yahooブックマーク
function ybook() {
window.open('http://bookmarks.yahoo.co.jp/bookmarklet/showpopup?t='+'情報商材レビュー評価:InfoQuest'+'&u='+'http://infoquest.jp/'+'&opener=bm&ei=UTF-8','popup','width=550px,height=480px,status=1,location=0,resizable=1,scrollbars=0,left=100,top=50',0);
}
//はてな？ブック
function hatena(clipul) {
window.open('http://b.hatena.ne.jp/add?mode=confirm&title='+escape(document.title)+'&url='+clipul);
}
//LiveDoorウック
function live(clipul) {
window.open('http://clip.livedoor.com/clip/add?link='+clipul+'&title='+escape(document.title));
}
//Delicioブック
function icio(clipul) {
window.open('http://del.icio.us/post?url=' + clipul + '&title='+escape(document.title));
}

//Niftyブック
function nifty(clipul) {
window.open('http://clip.nifty.com/create?url=' + clipul + '&title=' +escape(document.title));
}

//Niftyブック
function fc2(clipul) {
window.open('http://bookmark.fc2.com/user/post?url=' + clipul + '&title=' +escape(document.title));
}

function cview(ul) {
document.write ('<div id="add">');
document.write ('<a href="javascript:ybook();"><img src="http://infoquest.jp/img/book-y.gif" /></a> ');
document.write ('<a href="javascript:hatena(\'' + ul + '\');"><img src="http://infoquest.jp/img/book-h.gif" /></a> ');
document.write ('<a href="javascript:live(\'' + ul + '\');"><img src="http://infoquest.jp/img/book-l.gif" /></a> ');
document.write ('<a href="javascript:icio(\'' + ul + '\');"><img src="http://infoquest.jp/img/book-d.gif" /></a> ');
document.write ('<a href="javascript:nifty(\'' + ul + '\');"><img src="http://infoquest.jp/img/book-n.gif" /></a> ');
document.write ('<a href="javascript:fc2(\'' + ul + '\');"><img src="http://infoquest.jp/img/book-f.gif" /></a> ');
document.write ('<input type="button" value="ヽ(°▽、°）お気に入りに追加" onclick="window.external.AddFavorite(\'http://infoquest.jp/\',\'インフォクエスト - 情報商材レビューコミュニティ\')" />');
document.write ('</div>');
}

///////////////////////////////////////////////////////////////////////

//クリックURL
function iul(iurl) {
location.href = iurl;
}

//特典表示
function rtt(stitle) {

document.write('<div id="tokutent" class="main">');
document.write('<a href="http://infoquest.jp/tokuten.html"><img src="http://infoquest.jp/img/pic/rtt.gif" /></a><br />');
document.write('当サイトから｢'+stitle+'｣をご購入された方へ、豪華特典をプレゼント致します。<br />');
//document.write('⇒<a href="http://infoquest.jp/tokuten.html" class="bold">当サイト限定購入者特典についてはこちら！</a><br />');

document.write('</div>');

}


//検索フォーム　検索開始時に一度消す
function schst() {
 if(document.all.search.value == "キーワード入力") {
 document.all.search.value = "";
 }
}

function schstoff() {
document.all.search.value = "キーワード入力";
}

function sch() {
 var opt = "";
 if ((document.all.henkin.checked == true) && (document.all.sup.checked == false)) {
 opt = " 全額返金保障付き";
 }
 if ((document.all.henkin.checked == false) && (document.all.sup.checked == true)) {
 opt = " サポートあり";
 }
 if ((document.all.henkin.checked == true) && (document.all.sup.checked == true)) {
 opt = " 全額返金保障付き サポートあり";
 }

 var asbase;

 document.all.search.value = document.all.search.value + opt;
}



//高速検索用

//検索フォーム　検索開始時に一度消す
function schst_box() {
 if(document.getElementById('search_box').value == "キーワード入力") {
 document.getElementById('search_box').value = "";
 }
}

function schstoff() {
document.getElementById('search_box').value = "キーワード入力";
}

//ブックマークプログラム

AddClipsUrl    = location.href;
AddClipsTitle  = document.title;
AddClipsId = '1B00C0127E379';
AddClipsBcolor='#78BE44';
AddClipsNcolor='#D1E9C0';
AddClipsTcolor='#666666';
AddClipsType='0';
AddClipsVerticalAlign='middle';
AddClipsDefault='bookmark';


//Ajax
function updateRating(request) {
/* alert(request.responseText);  // DEBUGGING */
var resp_arr = request.responseText.split("||");
if (resp_arr[0] == 'ERR') {
alert(resp_arr[1]);
}
if (resp_arr[0] == 'OK') {
var type = resp_arr[1];
var id = resp_arr[2];
var r = parseInt(resp_arr[3]);
var b = 22;
var total = parseInt(resp_arr[4]) - r;
                                var count = parseInt(resp_arr[5]) -1;
                                var a = 0;
                //                var theUL = document.getElementById('rater_ul'+type+id); // the UL
                //        if (theUL) { theUL.innerHTML = '<li id="rater_li'+type+id+'" class="current-rating" style="width:0px"></div>'; }
                                updatePage(type,id,r,b,total,count,a);
}
}
function pushRating(type,id,r,b,total,count,a) {
                        updatePage(type,id,r,b,total,count,a);
                //        var theUL = document.getElementById('rater_ul'+type+id); // the UL
                //if (theUL) { theUL.innerHTML = '<div class="loading"></div>'; }
              new ajax('http://infoquest.jp/mt/plugins/AjaxRating/mt-vote.cgi', {postBody: 'obj_type='+type+'&r='+r+'&obj_id='+id+'&blog_id='+b+'&a='+a, onComplete: updateRating});
}
function updatePage (type,id,r,b,total,count,a) {
                        var avg = Math.round(((total + r)/(count + 1))*10)/10;
                        if (type == "comment") {
                            var new_width =  Math.round(avg / 5 * 150);
                        } else {
                            var new_width =  Math.round(avg / 5 * 150);
                        }
                        var span_avg = document.getElementById("ajaxrating_" + type + "_" + id + "_avg");
                        if (span_avg) {span_avg.innerHTML = avg; }
                        var span_ttl = document.getElementById("ajaxrating_" + type + "_" + id + "_ttl");
                        if (span_ttl) {span_ttl.innerHTML =  total + r; }
                        var span_cnt = document.getElementById("ajaxrating_" + type + "_" + id + "_cnt");
                        if (span_cnt) {span_cnt.innerHTML =  count + 1; }
                        var rater_li = document.getElementById("rater_li" + type +  id);
                        if (rater_li) {rater_li.style.width =  new_width.toString() + "px"; }
                        var thumb = document.getElementById("thumb" + type +  id);
                        if (thumb) {thumb.innerHTML =  ""; }
                        var thanks = document.getElementById("thanks" + type +  id);
                        if (thanks) {thanks.innerHTML =  "投票ありがとうございました"; }
}
function voteDownload (type,id,r,b,total,count,a) {
              new ajax('http://infoquest.jp/mt/plugins/AjaxRating/mt-vote.cgi', {postBody: 'obj_type='+type+'&r='+r+'&obj_id='+id+'&blog_id='+b+'&a='+a});
                        window.location.href = this.href;
}



/////////////////////////////////////////////////////////////////////////////
//コメントエリア///////////////////////////////////////////////////////////////
 // コメントにカスタマイズ絵文字入力機能：画像設定
function getCommentEmojiList() {
var list = new Array();
// 画像名、画像URLの設定
list[list.length] = new Array('・・・', 'http://infoquest.jp/img/emo/1.gif');
list[list.length] = new Array('ハート', 'http://infoquest.jp/img/emo/2.gif');
list[list.length] = new Array('汗', 'http://infoquest.jp/img/emo/3.gif');
list[list.length] = new Array('風', 'http://infoquest.jp/img/emo/4.gif');
list[list.length] = new Array('怒', 'http://infoquest.jp/img/emo/5.gif');
list[list.length] = new Array('♪', 'http://infoquest.jp/img/emo/6.gif');
list[list.length] = new Array('？', 'http://infoquest.jp/img/emo/7.gif');
list[list.length] = new Array('ビックリ', 'http://infoquest.jp/img/emo/8.gif');
list[list.length] = new Array('汗２', 'http://infoquest.jp/img/emo/9.gif');
list[list.length] = new Array('ひらめき', 'http://infoquest.jp/img/emo/10.gif');
list[list.length] = new Array('好き', 'http://infoquest.jp/img/emo/11.gif');
list[list.length] = new Array('複雑', 'http://infoquest.jp/img/emo/12.gif');
list[list.length] = new Array('顔', 'http://infoquest.jp/img/emo/13.gif');
list[list.length] = new Array('しょぼん', 'http://infoquest.jp/img/emo/14.gif');
list[list.length] = new Array('がっかり', 'http://infoquest.jp/img/emo/15.gif');
return list;
} 



function getCustmizeEmojiAttribute() {
// 画像タグに含める属性値（alt属性以外）
var att = 'border="0" style="vertical-align:middle"';

// ***************** 設定ここまで *****************
att = (att != '') ? (' ' + att) : '';
return att;
}


///////////////////////////////////////////////////////////////////////////////////////
//コメントにカスタマイズ絵文字入力機能：画像リスト出力////////////////////////////////////////
function writeCustmizeEmojiTagList() {
// コメントを入力するテキストエリアを指定
var textarea = 'document.comments_form.text'; 
// ***************** 設定ここまで *****************
var list = getCommentEmojiList();
var att = getCustmizeEmojiAttribute();
window.document.write('<p>');
for (var i = 0; i < list.length; i++) {
window.document.write('<a href="javascript:;" onClick="addCustmizeEmoji(' + textarea + ', \'' +
list[i][0] + '\');"><img src="' + list[i][1] + '"' + att + ' alt="' + list[i][0] + '" /></a>');
}
window.document.write('</p>');
}

// reference from jugem.jp (c)
function addCustmizeEmoji(obj, tag) {
var item = '[' + tag + ']';
if (document.selection) {
obj.focus();
sel = document.selection.createRange();
sel.text = item;
} else if (obj.selectionStart || obj.selectionStart == '0') {
var startPos = obj.selectionStart;
var endPos = obj.selectionEnd;
obj.value = obj.value.substring(0, startPos)
+ item + obj.value.substring(endPos, obj.value.length);
} else {
obj.value += item;
}
}


////////////////////////////////////////////////////////////////////////////
// コメントにカスタマイズ絵文字入力機能：画像変換
function changeCustmizeEmojiTag() {
// （１）コメント全体のタグの id 属性
var commentAreaIdName = '';
// （２）コメント全体のタグ名
var commentAreaTag = 'div';
// （３）各コメントの class 属性comment-content
var commentBodyClassName = 'comment-content';
// ***************** 設定ここまで *****************
var list = getCommentEmojiList();
var att = getCustmizeEmojiAttribute();
var objComArea;
var classComArea;
var objComBody = new Array();
if (commentAreaIdName != '') {
objComArea = document.getElementById(commentAreaIdName);
if (!objComArea || !objComArea.innerHTML) return;
classComArea = objComArea.getElementsByTagName(commentAreaTag);
} else {
classComArea = document.getElementsByTagName('*');
}
for (var i = 0; i < classComArea.length; i++) {
if (classComArea[i].className == commentBodyClassName)
objComBody[objComBody.length] = classComArea[i];
}
for (var i = 0; i < objComBody.length; i++) {
objComBody[i].innerHTML = getStringCustmizeEmojiTag(list, objComBody[i].innerHTML, att);
}
}

function getStringCustmizeEmojiTag(list, s, att) {
for (var i = 0; i < list.length; i++) {
s = s.split('[' + list[i][0] + ']').join('<img src="' + list[i][1] + '"' + att + ' alt="' + list[i][0] + '" />');
}
return s;
}

