/*画像入れ替え*/
/* amazon対応 ヴァルアップ変更 */
ImageHost = "http://front.book.nihonvogue.co.jp/";

//function changeImages (imgId, imgSrc) {
//    if (document.getElementById) {
//        document.getElementById(imgId).src = imgSrc;
//    }
//}
String.prototype.trim= function(){  
   return this.replace(/(^\s*)|(\s*$)/g, "");
}
function closeUl(code){
  alert(code);
  var list = document.getElementsByTagName("li");
  for(var i=0;i<list.length;i++){
   var curLi = list[i].id;
   if(curLi.indexOf(code) != -1 && curLi.length != code.length && curLi.startWith(code)){
    alert(curLi);
    if(document.getElementById(curLi).style.display == "none"){
     if(curLi.length == code.length+5){
      document.getElementById(curLi).style.display = "block";
     }
    }else{
     document.getElementById(curLi).style.display = "none";
    }
   }
  }
 }
 String.prototype.endWith=function(str){
  if(str==null||str==""||this.length==0||str.length>this.length)
     return false;
  if(this.substring(this.length-str.length)==str)
     return true;
  else
     return false;
  return true;
 }

 String.prototype.startWith=function(str){
  if(str==null||str==""||this.length==0||str.length>this.length)
   return false;
  if(this.substr(0,str.length)==str)
     return true;
  else
     return false;
  return true;
 }

function changeImages (imgId, imgSrc) {
	var path = location.href;
	path = path.substring(path.indexOf("/", 8), path.lastIndexOf("/"));
	if (path.trim().length == 0 || path.trim() == "/") {
		path = "/";
	}
	var returnStr = "";
	if (imgSrc.startWith("/")) {
		returnStr = ImageHost + imgSrc.substring(1);
	} else if (imgSrc.startWith("../") || imgSrc.startWith("./")){
		var thisSrc = imgSrc;
		while (thisSrc.startWith("../") || thisSrc.startWith("./")) {
			if (thisSrc.startWith("../")) {
				thisSrc = thisSrc.substring(3);
				if (path.indexOf("/") != -1) {
					path = path.substring(0, path.lastIndexOf("/"));
				} else {
					path = "";
				}
			} else {
				thisSrc = thisSrc.substring(2);
			}
		}
		
		if (path.startWith("/")) {
			path = path.substring(1);
		}
		if (path.length > 0 && !path.endWith("/")) {
			path = path + "/";
		}
		returnStr = ImageHost + path + thisSrc;
	} else if (imgSrc.startWith("http")) {
		returnStr = imgSrc.replace('http://book.nihonvogue.co.jp/', ImageHost)
	} else {
		if (path.startWith("/")) {
			path = path.substring(1);
		}
		if (path.length > 0 && !path.endWith("/")) {
			path = path + "/";
		}
		returnStr = ImageHost + path + imgSrc;
	}
	MM_preloadImages(returnStr);
    if (document.getElementById) {
		document.getElementById(imgId).src = returnStr;
    }
}


/*画像のプリロード*/
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

/*ウィンドウを閉じる*/
function closewin() {
	window.close();
}

/*ポップアップウインドウ*/
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/*ポップアップウインドウ 02 */
//onclick="popup('URL')"
function popup(url){
var win1=window.open(url,'','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,width=520,height=750');
}

