
// submitボタンの表示変動処理用
  function process(parts) {
     if ( parts.SUBMIT.value != '処理中' ) {
        parts.SUBMIT.value = '処理中';
     }else{
        return false;
     }
     if ( parts.SUBMIT2.value != '処理中' ) {
        parts.SUBMIT2.value = '処理中';
     }else{
        return false;
     }
        return true;
  }
  function process2(parts) {
     if ( parts.SUBMIT.value != '処理中' ) {
        parts.SUBMIT.value = '処理中';
     }else{
        return false;
     }
        return true;
  }

// 検索ロボット避け対策のリンクボタン
   function renew(url) {
		window.open(url, "_self");
  }

// 「このページを友達にメールする」用
//  locationはユーザビリティーの観点より必要
  function friend_mail(url) {
		window.open(url,"mail","width=500,height=500,location=yes,status=yes,_blank");
  }

// Amazon画像がない場合に別の画像を表示する
  function checkImages()
  {
    var imagesArr = new Array();
    imagesArr = document.getElementsByTagName("img");
    for (var i=0; i < imagesArr.length; i++)
    {
      if (imagesArr[i].width=="")
      {
        imagesArr[i].src = base_path+"/img/now_printing.gif";
      }
    }
  }
  
  
// global flag
var isIE = false;

// global request and XML document objects
var req;

// retrieve XML document (reusable generic function);
// parameter is URL string (relative or complete) to
// an .xml file whose Content-Type is a valid XML
// type, such as text/xml; XML source must be from
// same domain as HTML file
function loadXMLDoc(url) {
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open("GET", url, true);
        req.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange;
            req.open("GET", url, true);
            req.send();
        }
    }
}

// handle onreadystatechange event of req object
function processReqChange() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            //clearTopicList();
            buildTopicList();
         } else {
            alert("There was a problem retrieving the XML data:\n" + req.statusText);
         }
    }
}

function loadDoc(data) {
    // equalize W3C/IE event models to get event object

    if (data) {

            try {
				//var url = "http://www5.keizaireport.com/rss.php/-/category="+data+"/";	
				//document.myFORM.add.disabled = true;
				//var url = "/output.php";

               data = data.replace("&", "＆");
              // data = data.replace(".", "");

				var url = "/bookmark2.php?string="+encodeURI(data)+"";
            	loadXMLDoc(url);
            }
            catch(e) {
                var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
                alert("Unable to get XML data:\n" + msg);
                return;
            }
    }
}
// retrieve text of an XML document element, including
// elements using namespaces
function getElementTextNS(prefix, local, parentElem, index) {
    var result = "";
    if (prefix && isIE) {
        // IE/Windows way of handling namespaces
        result = parentElem.getElementsByTagName(prefix + ":" + local)[index];
    } else {
        // the namespace versions of this method 
        // (getElementsByTagNameNS()) operate
        // differently in Safari and Mozilla, but both
        // return value with just local name, provided 
        // there aren't conflicts with non-namespace element
        // names
        result = parentElem.getElementsByTagName(local)[index];
    }
    if (result) {
        // get text, accounting for possible
        // whitespace (carriage return) text nodes 
        if (result.childNodes.length > 1) {
            return result.childNodes[1].nodeValue;
        } else {
            return result.firstChild.nodeValue;    		
        }
    } else {
        return "n/a";
    }
}

// empty Topics content
function clearTopicList() {
    document.getElementById("details").innerHTML = "";
}
// fill Topics select list with items from
// the current XML document
function buildTopicList() {
    var items = req.responseXML.getElementsByTagName("response");
	var data = getElementTextNS("", "string", items[0], 0);
   //document.getElementById("details").innerHTML = data;
	alert(data);
	//if(data=="NO"){ document.myFORM.add.disabled = false; }
}

  window.onload=checkImages;
