var xmlhttp
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
  try {
  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
 } catch (e) {
  try {
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  } catch (E) {
   xmlhttp=false
  }
 }
@else
 xmlhttp=false
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 try {
  xmlhttp = new XMLHttpRequest();
 } catch (e) {
  xmlhttp=false
 }
}
diggburylock = 0;

function myXMLHttpRequest() {
  var xmlhttplocal;
  try { xmlhttplocal= new ActiveXObject("Msxml2.XMLHTTP") }
  catch (e) {
     try { xmlhttplocal= new ActiveXObject("Microsoft.XMLHTTP") }
      catch (E) { xmlhttplocal=false; }
   }

   if (!xmlhttplocal && typeof XMLHttpRequest!='undefined') {
       try { var xmlhttplocal = new XMLHttpRequest(); }
         catch (e) {
           var xmlhttplocal=false;
           alert('couldn\'t create xmlhttp object');
       }
   }
   return(xmlhttplocal);
}

var hex = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F");
var i, j, k;
k = 0;
for (i = 0; i < 16; i ++) {
    for (j = 0; j < 16; j ++) {
       rgb[k] = hex[i] + hex[j];
       k ++;
   }
}
function rgb(r, g, b) {
   return('#'+rgb[r]+rgb[g]+rgb[b]);
}
var ColorIn= new Array();
for (i = 1; i <= 5; i ++) {
  ColorIn[i] = new Array();
}

ColorIn[1][1] = rgb(248, 242, 198);
ColorIn[1][2] = rgb(234, 227, 181);
ColorIn[1][3] = rgb(220, 212, 164);
ColorIn[1][4] = rgb(206, 195, 147);
ColorIn[1][5] = rgb(192, 180, 130);
ColorIn[1][6] = rgb(178, 165, 113);
ColorIn[1][7] = "#A39A5D";

ColorIn[2][1] = rgb(247, 236, 172);
ColorIn[2][2] = rgb(231, 220, 158);
ColorIn[2][3] = rgb(215, 204, 140);
ColorIn[2][4] = rgb(199, 188, 122);
ColorIn[2][5] = rgb(183, 172, 104);
ColorIn[2][6] = rgb(167, 156, 86);
ColorIn[2][7] = "#998D43"; 

ColorIn[3][1] = rgb(247, 236, 158);
ColorIn[3][2] = rgb(229, 218, 140);
ColorIn[3][3] = rgb(211, 200, 122);
ColorIn[3][4] = rgb(193, 182, 104);
ColorIn[3][5] = rgb(175, 164, 86);
ColorIn[3][6] = rgb(157, 146, 68);
ColorIn[3][7] = "#897D2F";

ColorIn[4][1] = rgb(247, 232, 137);
ColorIn[4][2] = rgb(225, 210, 119);
ColorIn[4][3] = rgb(203, 188, 101);
ColorIn[4][4] = rgb(181, 166, 83);
ColorIn[4][5] = rgb(159, 144, 65);
ColorIn[4][6] = rgb(137, 122, 47);
ColorIn[4][7] = "#73681F"; 

ColorIn[5][1] = "#F6E26B";
ColorIn[5][2] = "#DAC85B";
ColorIn[5][3] = "#BEAE4B";
ColorIn[5][4] = "#A2943B";
ColorIn[5][5] = "#867A2B";
ColorIn[5][6] = "#6A6019";
ColorIn[5][7] = "#50470D";

ColorSpy = new Array();
ColorSpy[1] = "#FFFFFF";
ColorSpy[2] = "#F1F3F5";
ColorSpy[3] = "#EBEEF1";
ColorSpy[4] = "#DEE2E7";
ColorSpy[5] = "#CCD5DB";
ColorSpy[6] = "#BCC7CF";
ColorSpy[7] = "#ACB9C4";

var timeid = Array();
var timeidview = Array();
var myxmlhttp = Array()
var responsestring = Array();
var myxmlhttpView = Array()
var responsestringView = Array();
var myxmlhttpSpamCheck = Array()
var responsestringSpamCheck = Array();
var myxmlhttpSpamRegister = Array()
var responsestringSpamRegister = Array();
var myxmlhttpNastyCheck = Array()
var responsestringNastyCheck = Array();
var myxmlhttpNastyRegister = Array()
var responsestringNastyRegister = Array();
var responseString = new String;
var myxmlhttpRelated = null;

function isIE() {
	var useragent = navigator.userAgent;
	var pos = useragent.indexOf('MSIE');
	if (pos > -1) {
		return true;
	} else {
		return false;
	}
}

function waittofade_full(id) {
  timeid[id] = window.setTimeout("fadeInFull('"+id+"')",100);
}

function flash(id) {
  timeid[id] = window.setTimeout("fadeInSpy(7, '"+id+"')",100);
}

function alreadydug() {
  alert("You have already dug this item");
}

function alreadydugi() {
  alert("You have already dug this story (or someone at the same internet address has)\nYou can try logging in and digging then.");
}

function myclearTimeout(id) {
  clearTimeout(timeid[id]);
} 

var digging = -1;
var viewing = -1;
var digging_head = "diggs-strong-";

function wrapper_full(id, rowid) {
   digging_head = "diggs-strong-";
  if (digging == id) {
    alert('すでに選択された記事です。');
    return;
  }
	else digging = id;

  if (xmlhttp) {
  	 Effect.Fade('choixExecuteImage' + id);
    digjfull(id, rowid);
    waittofade_full(id);
  }
}

function fadeInFull(id) {
  window.setTimeout('fadeOutFull('+id+')', 1000);
  Effect.Fade(digging_head + id);
}

function fadeOutFull(id) {
  shownewcontentfull(id);
  Effect.Appear(digging_head + id);
}

function fadeInSpy(where, id) {
  if (where >= 1) {
    $('main'+id).style.backgroundColor = ColorSpy[where];
    if (where > 1) {
      where -= 1;
      timeid[id] = window.setTimeout("fadeInSpy("+where+",'"+id+"')", 100);
    } else {
      where -= 1;
      $('main'+id).style.backgroundColor = "transparent";
      myclearTimeout(id);
    }
  }
}

function openSpellChecker() {
  // get the textarea we're going to check
  var text1 = $('title');
  var textarea1 = $('bodytext');
  var speller = new spellChecker( text1, textarea1 );
  speller.openChecker();
}

function openSpellCheckerComment() {
  // get the textarea we're going to check
  var textarea1 = $('comment');
  var speller = new spellChecker( textarea1 );
  speller.openChecker();
}
function openSpellCheckerVote() {
  // get the textarea we're going to check
  var textarea1 = $('vote');
  var speller = new spellChecker( textarea1 );
  speller.openChecker();
}
function confirmblock(username) {
  return(confirm('Are you sure you want to block user '+username+' ?'));
}
function reportj(id, code) {
  url="/reportj?id="+id+"&code="+code;
  xmlhttp.open("GET",url,true);
  xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4) {
      alert(xmlhttp.responseText);
    }
  }
  xmlhttp.send(null);
  return false;
}
function updaterating(frm,commentid,commentdiv,tolerance) {
  url="/setratingj/"+commentid+"/"+frm.ratings.value;
  xmlhttp.open("GET",url,true);
  xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4) {
      score = xmlhttp.responseText;
      $('scorediv'+commentid).innerHTML = score;
      if (score < tolerance) {
	thediv = $(commentdiv); 
	thediv.innerHTML = '';
	frm.ratings.selectedIndex=xmlhttp.responseText;
      }
    }
  }
  //  xmlhttp.setRequestHeader('Accept','message/x-formresult');
  xmlhttp.send(null);
  return false;
}
function showCaptcha(name) {
  var target = $('commentcaptcha');
  target.onclick = null;
  target.style.display = 'block';
  if (!(target.innerHTML.length)) {	
    $('submitbutton').disabled = true;
    url = '/get_captcha?keyname='+name;
    xmlhttp.open("GET",url,true);
    xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4) {
	target.innerHTML = xmlhttp.responseText;
	$('submitbutton').disabled = false;
      }
    }
    xmlhttp.send(null);
  } 
}
function enablebutton(button, button2, target) {
  var string = target.value; 
  button2.disabled = false;
  if (string.length > 0) {
    button.disabled = false;
  } else {
    button.disabled = true;
  }
  var target2 = $('commentcaptcha');
}
function startlastdigs() {
  window.setInterval("lastdigs()",10000);
}
function startlastdigs_up() {
  window.setInterval("lastdigs_up()",10000);
}
function filldigs() {
  var s;
  var url2 = 'last10';
  s = new myXMLHttpRequest();
  s.open("GET",url2,true);
  s.onreadystatechange=function() {
    if (s.readyState == 4) {
      responsestring2 = s.responseText;	
      split = new RegExp("!#-!");
      b = responsestring2.split(split);
      split2 = new RegExp("~");
      c = b[1].split(split2);
      $('diggspy').innerHTML = b[0];
      do_anim();
    }
  }
  s.send(null);
  delete s;
  return;
}
function filldigs_up() {
  var s;
  var url2 = 'last10digg';
  s = new myXMLHttpRequest();
  s.open("GET",url2,true);
  s.onreadystatechange=function() {
    if (s.readyState == 4) {
      responsestring2 = s.responseText;	
      split = new RegExp("!#-!");
      b = responsestring2.split(split);
      split2 = new RegExp("~");
      c = b[1].split(split2);
      $('diggspy').innerHTML = b[0];
      do_anim();
    }
  }
  s.send(null);
  delete s;
  return;
}

function do_anim() {
    // find all items in c not in ids
    var notdone = 1;
    var i = 0;
    var j = 0;
    while (notdone) {   
       if (c[i] != ids[j]) {
            flash(c[i]); 
            i ++;
            if (i > c.length) {
                notdone = 0;
            }
       } else {
            notdone = 0;
       }
    }
    for (i = 0; i < c.length; i ++) {
       ids[i] = c[i];
    }
}
function lastdigs() {
  if (!spypause) {
    filldigs();
  }
}
function lastdigs_up() {
  if (!spypause_up) {
    filldigs_up();
  }
}
function checkit(form) {
  var name = escape(form.username.value);
  url = 'checkusername?username='+name;
  checkitxmlhttp = new myXMLHttpRequest();
  checkitxmlhttp.open("GET",url,true);
  checkitxmlhttp.onreadystatechange=function() {
    if (checkitxmlhttp.readyState==4) {
      responsestring = checkitxmlhttp.responseText;
      if (responsestring == 'taken'|| responsestring == 'not acceptable - user names must have 4-15 characters, and only alphanumeric characters.') {
	$('checkitvalue').innerHTML = '<strong style="background: url(/img/deny.png) 0 1px no-repeat; padding-left: 16px; font-size: 85%; color: #c00;">Sorry, the username "'+name+'" is '+responsestring+'.</strong>';
	form.submit.disabled = 'disabled';
      } else {
	$('checkitvalue').innerHTML = '<strong style="background: url(/img/confirm.png) 0 1px no-repeat; padding-left: 16px; font-size: 85%; color: #090;">Great, the username "'+name+'" is '+responsestring+'.</strong>';
	form.submit.disabled = '';
      }
    }
  }
  //  xmlhttp.setRequestHeader('Accept','message/x-formresult');
  checkitxmlhttp.send(null);
  return false;  
}
function blankcontent(id) {
  hovercontent(id);
  content = '<div id=\'popup\'></div>';
  return(content);
}
function hovercontent (id) {
  url = '/hovercontent?id='+id;
  hoverxmlhttp = new myXMLHttpRequest();
  hoverxmlhttp.open("GET",url,true);
  hoverxmlhttp.onreadystatechange=function() {
    if (hoverxmlhttp.readyState==4) {
      responsestring = hoverxmlhttp.responseText;
      $('popup').innerHTML = responsestring;
    }
  }
  //  xmlhttp.setRequestHeader('Accept','message/x-formresult');
  hoverxmlhttp.send(null);
  return('');
}

// Update new content on the webpage, diggs or stories
function shownewcontentfull(id) {
  if (myxmlhttp[id].readyState!=4) window.setTimeout("shownewcontentfull("+id+")",300);
  else {
    split = new RegExp("~--~");
    b = responsestring[id].split(split);
	if (b[0] == 3) {
	  target1 = getElById(digging_head + id);
		target1.className = "unm_new_x";
//		target1.style.backgroundColor = "#ffffe6";
		if (parseInt(target1.innerHTML) < parseInt(b[1])) target1.innerHTML = b[1];

	  target4 = getElById('choixExecuteImage' + id);
	  if (target4) target4.src = "/img/choixing_btn_c.gif";
  	  Effect.Appear('choixExecuteImage' + id);

	  target2 = getElById('choixExecuteTd' + id);
	  if (target2) target2.style.backgroundImage = "url('/img/choixing_bg_b.gif')";
    }
  }
  return;
}

function fadeInIncrement(id, count) {
	//$(target).innerHTML = count;
	target1 = getElById(digging_head + id);
	Effect.Appear(target1);
	target1.className = "unm_new_x";
//	target1.style.backgroundColor = "#ffffe6";
	if (target1.innerHTML < count) target1.innerHTML = count;

	target4 = getElById('choixExecuteImage' + id);
	if (target4) target4.src = "/img/choixing_btn_c.gif";
	Effect.Appear('choixExecuteImage' + id);

	target2 = getElById('choixExecuteTd' + id);
	if (target2) target2.style.backgroundImage = "url('/img/choixing_bg_b.gif')";
}

function digjfull(row, id) {
  Effect.Fade(digging_head + row);
  currdigs = parseInt($(digging_head + row).innerHTML);
  currdigs += 5;
  setTimeout('fadeInIncrement(\''+row+'\', '+currdigs+')', 1000);
  url = "/diginfull";
  content="id="+id;
  myxmlhttp[row] = new myXMLHttpRequest();
  if (myxmlhttp[row]) {
	myxmlhttp[row].open("POST",url,true);
	myxmlhttp[row].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  	myxmlhttp[row].send(content);
 	myxmlhttp[row].onreadystatechange=function() {
	  	errormatch = new RegExp("^ERROR:");
		if (myxmlhttp[row].readyState==4) {
   		 	responsestring[row] = myxmlhttp[row].responseText;
			if (responsestring[row].match(errormatch)) {
				alerttext = responsestring[row].replace(/ERROR:/, '');
				alert(alerttext);
				myclearTimeout(row);
    			}   
	  	}
	}
  }
  return false;
}

ratingLayers = new Array(5);
ratingMsgColors = new Array(5);

ratingLayers[0] = "low_passwd";
ratingLayers[1] = "low_passwd";
ratingLayers[2] = "mid_passwd";
ratingLayers[3] = "high_passwd";
ratingLayers[4] = "high_passwd";

ratingMsgColors[0] = "#FFFFFF";
ratingMsgColors[1] = "#8AC71E";
ratingMsgColors[2] = "#A9DD50";
ratingMsgColors[3] = "#C8F579";
ratingMsgColors[4] = "#C8F579";

function passwordstrength(password) {
   url = "/passwordstrength";
   content="password="+password;
   myxmlhttpPass = new myXMLHttpRequest();

   if (myxmlhttpPass) {
      myxmlhttpPass.open("POST",url,true);
      myxmlhttpPass.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      myxmlhttpPass.send(content);
      myxmlhttpPass.onreadystatechange=function() {
         errormatch = new RegExp("^ERROR:");
         if (myxmlhttpPass.readyState==4) {
            responsestringPass = myxmlhttpPass.responseText;
            if (responsestringPass.match(errormatch)) {
               alerttext = responsestringPass.replace(/ERROR:/, '');
            }
            passInt = parseInt(responsestringPass);
            var obj = null;
            for (var i = 0; i <= passInt; i ++) {
               obj = document.getElementById(ratingLayers[i]);
               obj.style.backgroundColor = ratingMsgColors[i];
            }
            for (var i = (passInt + 1); i < ratingLayers.length; i ++) {
               obj = document.getElementById(ratingLayers[i]);
               obj.style.backgroundColor = "#FFFFFF";
            }
         }
      }
   }
   return false;
}

var id_availability = true;

function checkid(id) {
   url = "/checkid";
   content="id="+id;
   myxmlhttpID = new myXMLHttpRequest();

   if (myxmlhttpID) {
      myxmlhttpID.open("POST",url,true);
      myxmlhttpID.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      myxmlhttpID.send(content);
      myxmlhttpID.onreadystatechange=function() {
         errormatch = new RegExp("^ERROR:");
         if (myxmlhttpID.readyState==4) {
            responsestringID = myxmlhttpID.responseText;
            if (responsestringID.match(errormatch)) {
               alerttext = responsestringID.replace(/ERROR:/, '');
            }
            passInt = parseInt(responsestringID);
            var obj = document.getElementById('id_alert');
            if (passInt == 0) {
               id_availability = true;
               obj.style.display = "none";
            }
            else {
               id_availability = false;
               obj.style.display = "block";
            }
         }
      }
   }
   return false;
}

function checkidByButton(id) {
   cleariderrormessage();
   var msgobj = document.getElementById('iderror_msg');
   var length = id.length;
   if (length < 6) {
      msgobj.innerHTML = "&nbsp;&nbsp;<img src=\"/images/man03.gif\" alt=\"caution\" width=\"11\" height=\"21\" align=\"absmiddle\" border=\"0\" />&nbsp;<font color=\"#CC0000\"><strong>６～１２文字以内の半角英数字を入力してください。</strong></font>";
      id_availability = false;
   }
   else {
      url = "/checkid";
      content="id="+id;
      myxmlhttpID = new myXMLHttpRequest();

      if (myxmlhttpID) {
         myxmlhttpID.open("POST",url,true);
         myxmlhttpID.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
         myxmlhttpID.send(content);
         myxmlhttpID.onreadystatechange=function() {
            errormatch = new RegExp("^ERROR:");
            if (myxmlhttpID.readyState==4) {
               responsestringID = myxmlhttpID.responseText;
               if (responsestringID.match(errormatch)) {
                  alerttext = responsestringID.replace(/ERROR:/, '');
               }
               passInt = parseInt(responsestringID);
               var obj = document.getElementById('id_alert');
               var obj_ok = document.getElementById('id_alert_ok');
               if (passInt == 0) {
                  msgobj.innerHTML = "&nbsp;&nbsp;<img src=\"/images/man03.gif\" alt=\"caution\" width=\"11\" height=\"21\" align=\"absmiddle\" border=\"0\" />&nbsp;<font color=\"#0066cc\"><strong>ご利用いただけるIDです。</strong></font>";
                  id_availability = true;
               }
               else {
                  msgobj.innerHTML = "&nbsp;&nbsp;<img src=\"/images/man02.gif\" alt=\"caution\" width=\"11\" height=\"21\" align=\"absmiddle\" border=\"0\" />&nbsp;<font color=\"#CC0000\"><strong>すでに使用されています。</strong></font>";
                  id_availability = false;
               }
               document.getElementById('overlapflag').value = '1';
            }
         }
      }
   }
   return false;
}

var email_availability = true;

function checkEmail(email) {
   if (email == "") return true;
   url = "/checkemail";
   content="email="+email;
   myxmlhttpEmail = new myXMLHttpRequest();

   if (myxmlhttpEmail) {
      myxmlhttpEmail.open("POST",url,true);
      myxmlhttpEmail.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      myxmlhttpEmail.send(content);
      myxmlhttpEmail.onreadystatechange=function() {
         errormatch = new RegExp("^ERROR:");
         if (myxmlhttpEmail.readyState==4) {
            responsestringEmail = myxmlhttpEmail.responseText;
            if (responsestringEmail.match(errormatch)) {
               alerttext = responsestringEmail.replace(/ERROR:/, '');
            }
            passInt = parseInt(responsestringEmail);
            var obj = document.getElementById('email_alert');
            if (passInt == 0) {
               email_availability = true;
               obj.style.display = "none";
            }
            else {
               email_availability = false;
               obj.style.display = "block";
            }
         }
      }
   }
   return false;
}

function hideTagInPost(idx) {
   var boxobj = document.getElementById('tagbox'+idx);
   boxobj.style.display = 'none';
}

function showTagInPost(seq, idx) {
   var obj = document.getElementById('tags'+idx);
   var boxobj = document.getElementById('tagbox'+idx);
   pretext = obj.innerHTML;

   if (boxobj.style.display == "block") {
      Effect.Fade('tagbox'+idx);
      window.setTimeout("hideTagInPost('"+idx+"')", 1000);
      return;
   }

   if (pretext.length > 0) {
      Effect.Appear('tagbox'+idx);
		boxobj.style.display = 'block';
   }
   else
	{
	   url = "/loadtags";
	   content="seq="+seq;
	   myxmlhttpTag = new myXMLHttpRequest();

	   if (myxmlhttpTag) {
		  myxmlhttpTag.open("POST",url,true);
		  myxmlhttpTag.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		  myxmlhttpTag.send(content);
		  myxmlhttpTag.onreadystatechange=function() {
			 errormatch = new RegExp("^ERROR:");
			 if (myxmlhttpTag.readyState==4) {
				responsestringTags = myxmlhttpTag.responseText;
				if (responsestringTags.match(errormatch)) {
				   alerttext = responsestringTags.replace(/ERROR:/, '');
				   alert(alerttext);
				}
				obj.innerHTML = responsestringTags;
				boxobj.style.display = 'block';
            Effect.Appear('tagbox'+idx);
			 }
		  }
	   }
	}
}

function showChoixersInPost(seq, idx) {
   var obj = document.getElementById('choixers'+idx);
   var boxobj = document.getElementById('choixersbox'+idx);
   pretext = obj.innerHTML;

   if (boxobj.style.display == "block") {
      Effect.Fade('choixersbox'+idx);
      window.setTimeout("hideTagInPost('"+idx+"')", 1000);
      return;
   }

   if (pretext.length > 0) {
      Effect.Appear('choixersbox'+idx);
		boxobj.style.display = 'block';
   }
   else
	{
	   url = "/loadchoixers";
	   content="seq="+seq;
	   myxmlhttpTag = new myXMLHttpRequest();

	   if (myxmlhttpTag) {
		  myxmlhttpTag.open("POST",url,true);
		  myxmlhttpTag.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		  myxmlhttpTag.send(content);
		  myxmlhttpTag.onreadystatechange=function() {
			 errormatch = new RegExp("^ERROR:");
			 if (myxmlhttpTag.readyState==4) {
				responsestringTags = myxmlhttpTag.responseText;
				if (responsestringTags.match(errormatch)) {
				   alerttext = responsestringTags.replace(/ERROR:/, '');
				   alert(alerttext);
				}
				obj.innerHTML = responsestringTags;
				boxobj.style.display = 'block';
            Effect.Appear('choixersbox'+idx);
			 }
		  }
	   }
	}
}

function closeTagInPost(idx) {
   Effect.Fade('tagbox'+idx);
   window.setTimeout("hideTagInPost('"+idx+"')", 1000);
}

function closeChoixersInPost(idx) {
   Effect.Fade('choixersbox'+idx);
   window.setTimeout("hideTagInPost('"+idx+"')", 1000);
}

function getTagCloud(choixerid, searchkey) {
   var obj = document.getElementById('tags');
   var selvalue = 0;
   if (document.getElementById('condition'))
   {
	   selvalue = document.getElementById('condition').selectedIndex;
   }

   if (selvalue==0)
   {
	   content = "page=allcloud&searchkey="+searchkey;
   }
   else
   {
	   content = "page=usercloud&choixerid="+choixerid+"&searchkey="+searchkey;
   }
   
   url = "/gettag";
   myxmlhttpTag = new myXMLHttpRequest();

   if (myxmlhttpTag) {
	  myxmlhttpTag.open("POST",url,true);
	  myxmlhttpTag.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  myxmlhttpTag.send(content);
	  myxmlhttpTag.onreadystatechange=function() {
		 errormatch = new RegExp("^ERROR:");
		 if (myxmlhttpTag.readyState==4) {
			responsestringTags = myxmlhttpTag.responseText;
			if (responsestringTags.match(errormatch)) {
			   alerttext = responsestringTags.replace(/ERROR:/, '');
			   obj.innerHTML = alerttext;
			}
			obj.innerHTML = responsestringTags;
		 }
	  }
   }
}

function getTagCloudMini() {
   var obj = document.getElementById('tags');
   
   url = "/gettagmini";
   myxmlhttpTag = new myXMLHttpRequest();
   content = "page=a";

   if (myxmlhttpTag) {
	  myxmlhttpTag.open("POST",url,true);
	  myxmlhttpTag.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  myxmlhttpTag.send(content);
	  myxmlhttpTag.onreadystatechange=function() {
		 errormatch = new RegExp("^ERROR:");
		 if (myxmlhttpTag.readyState==4) {
			responsestringTags = myxmlhttpTag.responseText;
			if (responsestringTags.match(errormatch)) {
			   alerttext = responsestringTags.replace(/ERROR:/, '');
			   obj.innerHTML = alerttext;
			}
			obj.innerHTML = responsestringTags;
		 }
	  }
   }
}

function checknasty(spamid, posttype, contentseq, choixerId) {
   url = "/checkspam";
   content = "postOrcomment=" + posttype + "&contentSeq=" + contentseq + "&type=1&choixerId=" + choixerId;
   myxmlhttpNastyCheck[spamid] = new myXMLHttpRequest();
   if (myxmlhttpNastyCheck[spamid]) {
      myxmlhttpNastyCheck[spamid].open("POST",url,true);
      myxmlhttpNastyCheck[spamid].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      myxmlhttpNastyCheck[spamid].send(content);
      myxmlhttpNastyCheck[spamid].onreadystatechange=function() {
         errormatch = new RegExp("^ERROR:");
         if (myxmlhttpNastyCheck[spamid].readyState==4) {
            responsestringNastyCheck[spamid] = myxmlhttpNastyCheck[spamid].responseText;
            if (responsestringNastyCheck[spamid].match(errormatch)) {
               alerttext = responsestringNastyCheck[spamid].replace(/ERROR:/, '');
               alert(alerttext);
            }
            responsestringNastyCheck[spamid] = parseInt(responsestringNastyCheck[spamid]);
            if (responsestringNastyCheck[spamid] == 0) {
				hidespamalert(spamid);
				shownastyalert(spamid);
			}
            else {
               var obj = document.getElementById('nastyalert'+spamid);
               obj.innerHTML = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><table width=\"100%\" height=\"25\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td height=\"25\" background=\"/img/caution_subbg.gif\" style=\"padding-left:10px\" class=\"a11\"><img src=\"/img/caution_icon.gif\" width=\"10\" height=\"16\" align=\"absmiddle\" />&nbsp;<font color=\"#CC0000\"><span>卑猥で通報しました。</span></font></td></tr></table></td></tr></table>";
               Effect.Appear('nastyalert' + spamid);
               obj.style.display = 'block';
               window.setTimeout('hidenastyalert('+spamid+')', 2000);
            }
         }
      }
   }
   return;
}

function registernasty(spamid, posttype, contentseq, choixerId) {
   url = "/registerspam";
   content = "postOrcomment=" + posttype + "&contentSeq=" + contentseq + "&type=1&choixerId=" + choixerId;
   myxmlhttpNastyRegister[spamid] = new myXMLHttpRequest();

   if (myxmlhttpNastyRegister[spamid]) {
      myxmlhttpNastyRegister[spamid].open("POST",url,true);
      myxmlhttpNastyRegister[spamid].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      myxmlhttpNastyRegister[spamid].send(content);
      myxmlhttpNastyRegister[spamid].onreadystatechange=function() {
         errormatch = new RegExp("^ERROR:");
         if (myxmlhttpNastyRegister[spamid].readyState==4) {
            responsestringNastyRegister[spamid] = myxmlhttpNastyRegister[spamid].responseText;
            if (responsestringNastyRegister[spamid].match(errormatch)) {
               alerttext = responsestringNastyRegister[spamid].replace(/ERROR:/, '');
               alert(alerttext);
            }
            var obj = document.getElementById('nastyalert'+spamid);

            obj.innerHTML = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><table width=\"100%\" height=\"25\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td height=\"25\" background=\"/img/caution_subbg.gif\" style=\"padding-left:10px\" class=\"a11\"><img src=\"/img/caution_icon.gif\" width=\"10\" height=\"16\" align=\"absmiddle\" />&nbsp;<font color=\"#CC0000\"><span>卑猥で通報しました。</span></font></td></tr></table></td></tr></table>";
            window.setTimeout('hidenastyalert('+spamid+')', 2000);
         }
      }
   }
   return;
}

function checkspam(spamid, posttype, contentseq, choixerId) {
   url = "/checkspam";
   content = "postOrcomment=" + posttype + "&contentSeq=" + contentseq + "&type=0&choixerId=" + choixerId;
   myxmlhttpSpamCheck[spamid] = new myXMLHttpRequest();
   if (myxmlhttpSpamCheck[spamid]) {
      myxmlhttpSpamCheck[spamid].open("POST",url,true);
      myxmlhttpSpamCheck[spamid].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      myxmlhttpSpamCheck[spamid].send(content);
      myxmlhttpSpamCheck[spamid].onreadystatechange=function() {
         errormatch = new RegExp("^ERROR:");
         if (myxmlhttpSpamCheck[spamid].readyState==4) {
            responsestringSpamCheck[spamid] = myxmlhttpSpamCheck[spamid].responseText;
            if (responsestringSpamCheck[spamid].match(errormatch)) {
               alerttext = responsestringSpamCheck[spamid].replace(/ERROR:/, '');
               alert(alerttext);
            }
            responsestringSpamCheck[spamid] = parseInt(responsestringSpamCheck[spamid]);
            if (responsestringSpamCheck[spamid] == 0) {
				hidenastyalert(spamid);
				showspamalert(spamid);
			}
            else {
               var obj = document.getElementById('spamalert'+spamid);
               obj.innerHTML = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><table width=\"100%\" height=\"25\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td height=\"25\" background=\"/img/caution_subbg.gif\" style=\"padding-left:10px\" class=\"a11\"><img src=\"/img/caution_icon.gif\" width=\"10\" height=\"16\" align=\"absmiddle\" />&nbsp;<font color=\"#CC0000\"><span>スパムで通報しました。</span></font></td></tr></table></td></tr></table>";
               Effect.Appear('spamalert' + spamid);
               obj.style.display = 'block';
               window.setTimeout('hidespamalert('+spamid+')', 2000);
            }
         }
      }
   }
   return;
}

function registerspam(spamid, posttype, contentseq, choixerId) {
   url = "/registerspam";
   content = "postOrcomment=" + posttype + "&contentSeq=" + contentseq + "&type=0&choixerId=" + choixerId;
   myxmlhttpSpamRegister[spamid] = new myXMLHttpRequest();

   if (myxmlhttpSpamRegister[spamid]) {
      myxmlhttpSpamRegister[spamid].open("POST",url,true);
      myxmlhttpSpamRegister[spamid].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      myxmlhttpSpamRegister[spamid].send(content);
      myxmlhttpSpamRegister[spamid].onreadystatechange=function() {
         errormatch = new RegExp("^ERROR:");
         if (myxmlhttpSpamRegister[spamid].readyState==4) {
            responsestringSpamRegister[spamid] = myxmlhttpSpamRegister[spamid].responseText;
            if (responsestringSpamRegister[spamid].match(errormatch)) {
               alerttext = responsestringSpamRegister[spamid].replace(/ERROR:/, '');
               alert(alerttext);
            }
            var obj = document.getElementById('spamalert'+spamid);

            obj.innerHTML = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><table width=\"100%\" height=\"25\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td height=\"25\" background=\"/img/caution_subbg.gif\" style=\"padding-left:10px\" class=\"a11\"><img src=\"/img/caution_icon.gif\" width=\"10\" height=\"16\" align=\"absmiddle\" />&nbsp;<font color=\"#CC0000\"><span>スパムで通報しました。</span></font></td></tr></table></td></tr></table>";
            window.setTimeout('hidespamalert('+spamid+')', 2000);
         }
      }
   }
   return;
}

function addFriend(friendid) {
   var obj = document.getElementById('friendstatus');

   url = "/addfriends";
   content="friendid="+friendid;
   myxmlhttpFriend = new myXMLHttpRequest();

   if (myxmlhttpFriend) {
	  myxmlhttpFriend.open("POST",url,true);
	  myxmlhttpFriend.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  myxmlhttpFriend.send(content);
	  myxmlhttpFriend.onreadystatechange=function() {
		 errormatch = new RegExp("^ERROR:");
		 if (myxmlhttpFriend.readyState==4) {
			responsestringFriends = myxmlhttpFriend.responseText;
			if (responsestringFriends.match(errormatch)) {
			   alerttext = responsestringFriends.replace(/ERROR:/, '');
			   alert(alerttext);
			}
			obj.innerHTML = responsestringFriends;
		 }
	  }
	}
}

function getThumbnail(addr, postSeq) {
   url = "/getThumbnail";
   content = "url=" + addr + "&postSeq=" + postSeq;
   myxmlhttpThumbnail = new myXMLHttpRequest();

   if (myxmlhttpThumbnail) {
     myxmlhttpThumbnail.open("POST",url,true);
     myxmlhttpThumbnail.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
     myxmlhttpThumbnail.send(content);
     myxmlhttpThumbnail.onreadystatechange=function() {
       errormatch = new RegExp("^ERROR:");
       if (myxmlhttpThumbnail.readyState==4) {
         responsestringThumbnail = myxmlhttpThumbnail.responseText;
         if (responsestringThumbnail.match(errormatch)) {
            alerttext = responsestringThumbnail.replace(/ERROR:/, '');
            alert(alerttext);
         }
       }
     }
   }
}

function getRelatedPosts(postSeq, ord, level, previousResult) {
   url = "/getrelated";
   content = "postSeq=" + postSeq + "&ord=" + ord + "&level=" + level;
   if (previousResult) content += ("&previousResult=" + previousResult);
   myxmlhttpRelated = new myXMLHttpRequest();

   if (myxmlhttpRelated) {
     myxmlhttpRelated.open("POST",url,true);
     myxmlhttpRelated.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
     myxmlhttpRelated.send(content);
     myxmlhttpRelated.onreadystatechange=function() {
       errormatch = new RegExp("^ERROR:");
       if (myxmlhttpRelated.readyState==4) {
         responsestringRelated = myxmlhttpRelated.responseText;
         if (responsestringRelated.match(errormatch)) {
            alerttext = responsestringRelated.replace(/ERROR:/, '');
            alert(alerttext);
         }
         else {
            split91 = new RegExp("~.~");
				c = responsestringRelated.split(split91, 5);
            if (c[1] != "hitori") {
               var relatedObj = document.getElementById("relatedPosts");
               if (relatedObj) {
                  var divobj = relatedObj.lastChild;
                  if (c[4]) {
					divobj.innerHTML = c[4];
					var divobj = document.createElement("Div");
					divobj.innerHTML =
					"<div style='float:left'><img src='/img/loadman.gif'></div><div style='top:0px'><font color='#666666'>searching...</font></div>";
					relatedObj.appendChild(divobj);
				  }
               }
               if (c[1] < 10) relatedposts_timeout_handle = setTimeout("getRelatedPosts(" + postSeq + ", " + c[1] + ", " + c[2] + ", " + c[3] + ")", 1000);
               else {
                  var divobj = relatedObj.lastChild;
                  relatedObj.removeChild(divobj);
               }
            }
            else if (ord == 0) {
               var relatedObj = document.getElementById("relatedPosts");
               if (relatedObj) {
                  var divobj = relatedObj.lastChild;
                  relatedObj.removeChild(divobj);
               }
               var norelatedObj = document.getElementById("norelatedpost");
               if (norelatedObj) norelatedObj.style.display = "block";
            }
				else {
               var relatedObj = document.getElementById("relatedPosts");
               if (relatedObj) {
						var divobj = relatedObj.lastChild;
						relatedObj.removeChild(divobj);
					}
				}
         }
       }
     }
   }
}

function viewCount(id, rowid) {
  	if (viewing == id) return;
   else viewing = id;

  	if (xmlhttp) viewPost(id, rowid);
}

function viewPost(row, id) {
	url = "/viewcount";
	content = "postSeq=" + id;
	myxmlhttpView[row] = new myXMLHttpRequest();

	if (myxmlhttpView[row]) {
		myxmlhttpView[row].open("POST",url,true);
		myxmlhttpView[row].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		myxmlhttpView[row].send(content);
		myxmlhttpView[row].onreadystatechange=function() {
			errormatch = new RegExp("^ERROR:");
			if (myxmlhttpView[row].readyState==4) {
				responsestringView[row] = myxmlhttpView[row].responseText;
				if (responsestringView[row].match(errormatch)) {
					alerttext = responsestringView[row].replace(/ERROR:/, '');
					alert(alerttext);
					myclearTimeout(row);
				}
				else {
					b = parseInt(responsestringView[row]);
					target = getElById("diggs-strong-" + row);
					if (target) {
						if (target.innerHTML < b) target.innerHTML = b;
					}
				}
			}
		}
	}
	return false;
}

function getnewposts(point, clientx) {
   url = "/getnewposts";
   content = "bottomline=" + point + "&clientx=" + clientx;
   myxmlhttpNewposts = new myXMLHttpRequest();

   if (myxmlhttpNewposts) {
      myxmlhttpNewposts.open("POST",url,true);
      myxmlhttpNewposts.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      myxmlhttpNewposts.send(content);

      myxmlhttpNewposts.onreadystatechange=function() {
         if (myxmlhttpNewposts.readyState==4) {
				var loadingdivobj = document.getElementById("loadingdiv");
				if (loadingdivobj) loadingdivobj.style.display = "none";
            responsestringNewposts = myxmlhttpNewposts.responseText;
				target = getElById("newposts");
				if (target) target.innerHTML = responsestringNewposts;
         }
      }
   }
   return false;
}

function getblogpartsposts(posttype, target, postline) {
   postlist = getElById("blogpartsposts");
   var loading = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td align="center" style="padding:30px 0px 0px 0px;"><img src="/img/loading_aact.gif"></td></tr><tr><td align="center" style="padding:0px 0px 30px 10px;">プレビュー作成中…</td></tr></table>';
   if (postlist) postlist.innerHTML = loading;
   url = "/getblogpartspreview";
   content = "posttype=" + posttype + "&target=" + target + "&postline=" + postline;
   myxmlhttpBlogpartsposts = new myXMLHttpRequest();

   if (myxmlhttpBlogpartsposts) {
      myxmlhttpBlogpartsposts.open("POST",url,true);
      myxmlhttpBlogpartsposts.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      myxmlhttpBlogpartsposts.send(content);

      myxmlhttpBlogpartsposts.onreadystatechange=function() {
         if (myxmlhttpBlogpartsposts.readyState==4) {
            var loadingdivobj = document.getElementById("loadingdiv");
            if (loadingdivobj) loadingdivobj.style.display = "none";
            responsestringBlogpartsposts = myxmlhttpBlogpartsposts.responseText;

            var count = 0;
            var posts = "";

            target_count = getElById("blogpartspostscount");

            if (posttype == "category") {
               posts = responsestringBlogpartsposts;
            }
            else {
               split = new RegExp("!#-!");
               arrposts = responsestringBlogpartsposts.split(split);
               var count = arrposts[0];
               var posts = arrposts[1];
               if (target_count) target_count.innerHTML = "で検索した結果 "+count+"件";
            }

            if (postlist) postlist.innerHTML = posts;
            changePreviewColor("title");
            changePreviewColor("summary");
         }
      }
   }
   return false;
}

function bluring() {
   if (event.srcElement.tagName == "A" || event.srcElement.tagName == "IMG") document.body.focus();
}

if (isIE()) document.onfocusin = bluring;


