function checkBrouser() {
  var ret = "";
  var strUA = "";
  strUA = navigator.userAgent.toLowerCase();

  if(strUA.indexOf("safari") != -1){		ret = "sf"; }
  else if(strUA.indexOf("firefox") != -1){	ret = "ff"; }
  else if(strUA.indexOf("opera") != -1){	ret = "op"; }
  else if(strUA.indexOf("netscape") != -1){	ret = "nn"; }
  else if(strUA.indexOf("msie") != -1){		ret = "ie"; }
  else if(strUA.indexOf("mozilla/4") != -1){	ret = "nn4"; }
  return ret;
}
function GetPicup(inDiv,inSeq,inGenre,inSite,inUID,inToku,inPattern,inSize,inColor){
  outdiv = inDiv;
  if(window.XMLHttpRequest) {
    ajax = new XMLHttpRequest();
  } else if(window.ActiveXObject) {
    try {
      ajax = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
      ajax = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  //非同期open
  if ("ff" == checkBrouser()) {
    ajax.onload = statusCheck;
  } else {
    ajax.onreadystatechange = statusCheck;
  }

  var now = new Date();
  var dt = now.getYear()+'/'+(now.getMonth()+1)+"/"+now.getDate()+" "+now.getHours()+now.getMinutes()+now.getSeconds();

  ajaxurl = "picup-relay.php?ajax="+encodeURIComponent("1")+"&seq="+encodeURIComponent(inSeq)+"&genre="+encodeURIComponent(inGenre)+"&site="+encodeURIComponent(inSite)+"&uid="+encodeURIComponent(inUID)+"&toku="+encodeURIComponent(inToku)+"&pattern="+encodeURIComponent(inPattern)+"&size="+encodeURIComponent(inSize)+"&color="+encodeURIComponent(inColor)+"&dt="+encodeURIComponent(dt);

  ajax.open("GET", ajaxurl,false);
  ajax.send("");
}
function statusCheck() {
  if (ajax.readyState == 4 && ajax.status == 200) {
    var res = ajax.responseText;
    res = res.replace(/,/g," ");
    res = res.replace(/\n/g," ");

    // document.writeを退避
    (function() {
      var s = document.write;
      el = document.getElementById(outdiv);
      document.write = function(t) {
        el.innerHTML += t;
      };

      // 退避したdocument.writeを戻す関数
      document.write.res = function() {
        document.write = s;
      }
    })();

    document.write(res);

    // document.writeを元に戻す
    document.write.res();

  }

}

