/**
 * レガロJava Script
 * http://wwww.webproduction.jp/
*/

/**
 * 著作権について * 
 * このシステムは、有限会社レガロによって制作されています。
 * 有限会社レガロは、このシステムの著作を保持しています。
 * 無断で複製、改変、販売することは出来ません。
*/


// ブラウザの判別

if( navigator.appName.charAt(0)=="N" ){
    if(navigator.appVersion.charAt(0)==2){ USERAGENT = "NN"; }
    if(navigator.appVersion.charAt(0)==3){ USERAGENT = "NN";}
    if(navigator.appVersion.charAt(0)==4){ USERAGENT = "NN"; }
    if(navigator.appVersion.charAt(0)==5){ 
        if (navigator.userAgent.indexOf("Netscape6/") != -1){ USERAGENT = "NN"; }
        else {
            if (navigator.userAgent.indexOf("Netscape/7") != -1){ USERAGENT = "NN"; }
            else {
                if (navigator.userAgent.indexOf("Netscape/8") != -1){ USERAGENT = "NN"; }
                else {
                    if (navigator.userAgent.indexOf("Safari") != -1){ USERAGENT = "Safari";}
                    else {
                        if (navigator.userAgent.indexOf("Firefox/3") != -1){ USERAGENT = "FireFox3"; }
			else {
			    if (navigator.userAgent.indexOf("Firefox/2") != -1){ USERAGENT = "FireFox2"; }
                             else { USERAGENT = "Mozila"; }
			}
                    }
                }
            }
        }
    }
}
if( navigator.appName.charAt(0)=="M" && navigator.userAgent.indexOf("Opera") == -1){
    if(navigator.appVersion.charAt(0)==2){ USERAGENT = "IE3"; }
    if(navigator.appVersion.charAt(0)==3){ USERAGENT = "IE3"; }
    if(navigator.appVersion.charAt(0)==4){
        if (navigator.appVersion.indexOf("MSIE 5") != -1){ USERAGENT = "IE5"; }
        else {
            if (navigator.appVersion.indexOf("MSIE 6") != -1){ USERAGENT = "IE6"; }
            else { 
            	if (navigator.appVersion.indexOf("MSIE 7") != -1){ USERAGENT = "IE7"; }
           	 else { 
                 if (navigator.appVersion.indexOf("MSIE 8") != -1){ USERAGENT = "IE8"; }
                else { USERAGENT = "IE4"; }
		}
            }
        }
    }
}
if (navigator.userAgent.indexOf("Opera") != -1){ USERAGENT = "Opera"; }


//在庫チェックファンクション
function __SALESCHECK(IDARRAY){
	for(i=0; i < IDARRAY.length; i++){
		// Ajaxでデータ接続
		informationReq = false;
		//　データ抽出プログラム
		uri = "/cgi-bin/salecheck.php?id=" + IDARRAY[i];

		if(window.XMLHttpRequest){
			informationReq = new XMLHttpRequest();
		}else if(window.ActiveXObject){
			try{
				informationReq = new ActiveXObject("Msxml2.XMLHTTP");
			}catch(e){
				informationReq = new ActiveXObject("Microsoft.XMLDOM");
			}
		}
		//ブラウザによって読み込みスクリプトを選択
		if(USERAGENT.match(/FireFox/i) || USERAGENT.match(/Safari/i) || USERAGENT.match(/Opera/i)){ 
			if(!informationReq) return;
			informationReq.open('GET',uri);
			informationReq.send(null);
			informationReq.onreadystatechange = function () {
			if(informationReq.readyState != 4){
				document.getElementById(IDARRAY[i]).style.display = "block";
			}
			if(informationReq.readyState == 4 && informationReq.status == 200){
				var XML_Data = informationReq.responseXML;
				var SelFLAG = XML_Data.getElementsByTagName("zaiko")[0].firstChild.nodeValue;
				if(SelFLAG == 0){
					document.getElementById(IDARRAY[i]).innerHTML = "<span class='kanbai_msg'>完売しました！</span>";
				}
				if(SelFLAG == 1){
					document.getElementById(IDARRAY[i]).innerHTML = "<span class='waiting_msg'>入荷待ち</span>";
				}
				if(SelFLAG == 2){
					document.getElementById(IDARRAY[i]).style.display = "none";
				}
			}
		}
		}else{
		var obXML = new ActiveXObject("Microsoft.XMLDOM");
		obXML.async = false;
		obXML.load(uri);
		var XML_Data = obXML.documentElement;
			var SelFLAG = XML_Data.getElementsByTagName("zaiko")[0].firstChild.nodeValue;
			if(SelFLAG == 0){
				document.getElementById(IDARRAY[i]).innerHTML = "<span class='kanbai_msg'>完売しました！</span>";
			}
			if(SelFLAG == 1){
				document.getElementById(IDARRAY[i]).innerHTML = "<span class='kanbai_msg'>入荷待ち</span>";
			}
			if(SelFLAG == 2){
				document.getElementById(IDARRAY[i]).style.display = "none";
			}

		}// ブラウザ振り分け
	}
}




//商品ページの在庫チェックファンクション
function __CHECK_ITEMSTOCK(ITEMID){
		// Ajaxでデータ接続
		informationReq = false;
		//　データ抽出プログラム
		uri = "/cgi-bin/salecheck.php?id=" + ITEMID;

		if(window.XMLHttpRequest){
			informationReq = new XMLHttpRequest();
		}else if(window.ActiveXObject){
			try{
				informationReq = new ActiveXObject("Msxml2.XMLHTTP");
			}catch(e){
				informationReq = new ActiveXObject("Microsoft.XMLDOM");
			}
		}
		//ブラウザによって読み込みスクリプトを選択
		if(USERAGENT.match(/FireFox/i) || USERAGENT.match(/Safari/i) || USERAGENT.match(/Opera/i)){ 
			if(!informationReq) return;
			informationReq.open('GET',uri);
			informationReq.send(null);
			informationReq.onreadystatechange = function () {
			if(informationReq.readyState != 4){
				document.getElementById("stock_box").style.display = "block";
			}
			if(informationReq.readyState == 4 && informationReq.status == 200){
				var XML_Data = informationReq.responseXML;
				var SelFLAG = XML_Data.getElementsByTagName("zaiko")[0].firstChild.nodeValue;
				if(SelFLAG == 0){
					document.getElementById("stock_box").innerHTML = "<span class='kanbai_msg'>完売しました！</span>";
				}
				if(SelFLAG == 1){
					document.getElementById("stock_box").innerHTML = "<span class='waiting_msg'>入荷待ち</span>";
				}
			}
		}
		}else{
		var obXML = new ActiveXObject("Microsoft.XMLDOM");
		obXML.async = false;
		obXML.load(uri);
		var XML_Data = obXML.documentElement;
			var SelFLAG = XML_Data.getElementsByTagName("zaiko")[0].firstChild.nodeValue;
			if(SelFLAG == 0){
				document.getElementById("stock_box").innerHTML = "<span class='kanbai_msg'>完売しました！</span>";
			}
			if(SelFLAG == 1){
				document.getElementById("stock_box").innerHTML = "<span class='kanbai_msg'>入荷待ち</span>";
			}

		}// ブラウザ振り分け
}//商品ページの在庫チェックファンクション


// 商品ページの売り上げランキング表示
function selectSIDEHITSALES(id){

	// Ajaxでデータ接続
	hitsalesReq = false;
	//　データ抽出プログラム
	uri = "/cgi-bin/select_hitsales.php?id=" + id;

		if(window.XMLHttpRequest){
			hitsalesReq = new XMLHttpRequest();
		}else if(window.ActiveXObject){
			try{
				hitsalesReq = new ActiveXObject("Msxml2.XMLHTTP");
			}catch(e){
				hitsalesReq = new ActiveXObject("Microsoft.XMLDOM");
			}
		}
		//ブラウザによって読み込みスクリプトを選択
		if(USERAGENT.match(/FireFox/i) || USERAGENT.match(/Safari/i) || USERAGENT.match(/Opera/i)){ 
			if(!hitsalesReq) return;
			hitsalesReq.open('GET',uri);
			hitsalesReq.send(null);
			hitsalesReq.onreadystatechange = function () {
			if(hitsalesReq.readyState != 4){
				document.getElementById("hitsidebox").innerHTML = "<img src=\"/images/image/mov_loading.gif\" width=\"16\" height=\"22\" hspace=\"20\" border\"0\" align=\"absmiddle\" />読み込み中...";
			}
			if(hitsalesReq.readyState == 4 && hitsalesReq.status == 200){
				var HIT_XML = hitsalesReq.responseXML;
				if(HIT_XML != null){
					HITHTML_Data = changeHITSALESXML(HIT_XML);
				}else{
					HITHTML_Data = "新着情報はありません";
				}
				document.getElementById("hitsidebox").innerHTML = HITHTML_Data;
			}
		}
		}else{
		var obXML = new ActiveXObject("Microsoft.XMLDOM");
		obXML.async = false;
		obXML.load(uri);
		var HIT_XML = obXML.documentElement;
			if(HIT_XML != null){
				HITHTML_Data = changeHITSALESXML(HIT_XML);
			}else{
				HITHTML_Data = "新着情報はありません";
			}
			document.getElementById("hitsidebox").innerHTML = HITHTML_Data;
		}// ブラウザ振り分け

}// 商品ページの売り上げランキング表示



//XML解析、HTML変換
function changeHITSALESXML(HIT_XML){

var ITEM_LIST = HIT_XML.getElementsByTagName("item");
var ITEM_TITLE = HIT_XML.getElementsByTagName("title");
var ITEMLDESC = HIT_XML.getElementsByTagName("description");
var ITEM_ID = HIT_XML.getElementsByTagName("itemid");
var ITEM_IMAGECODE = HIT_XML.getElementsByTagName("imagecode");
var ITEM_PRICE = HIT_XML.getElementsByTagName("shopprice");

var html = "";


	html = "<h2 class=\"sideh2\">売れ筋ランキング</h2>";
var ri = 1;
	for(var i=0; ITEM_LIST.length > i;i++){
		var tcount = i+1;
		var item_name = ITEM_TITLE[tcount].firstChild.nodeValue;
		var item_desc = ITEMLDESC[tcount].firstChild.nodeValue;
		var item_id = ITEM_ID[i].firstChild.nodeValue;
		var item_imagecode = ITEM_IMAGECODE[i].firstChild.nodeValue;
		var item_price = ITEM_PRICE[i].firstChild.nodeValue;

		html += "<div class='siderankbox'><img src='/images/image/icon_rank" + ri + ".gif' width='30' height='18' hspace='5' align='center' border='0' alt='人気ランキング" + ri + "位' /><br />";
		html += "<a href='/item/" + item_id + ".html'><img src='http://image.moshimo.com/item_image/" + item_imagecode + "/1/m.jpg' border='0' hspace='10' vspace='10' align='left' alt=' + item_name + ' />" + item_name + "</a><br />";
		html += item_desc + "<br />";
		html += "<span class='item_price'>" + item_price + "</span>円(税込)<br clear='both' />";
		html += "</div>";
	++ri;
	}//for Loop end

return html;
}// changeHITSALESXML


//もしもページへジャンプ
function view_cart(){
	window.open("http://cart.mp.moshimo.com/mp/cart/index?shop_id=457336&signature=","SHOPPINGCART","left=10,top=30,scrollbars=yes,location=yes,menubar=no");
}

function add_to_cart(id){
	window.open("http://www.moshimo.com/cart/add?shop_id=457336&article_id=" + id,"SHOPPINGCART","left=10,top=30,scrollbars=yes,location=yes,menubar=no");
}

function add_contact(id){
	window.open("http://www.mp.moshimo.com/mp/www/inquiry/shopping?shop_id=457336&article_id=" + id,"CONTACTFORM","left=10,top=30,scrollbars=yes,location=yes,menubar=no");
}


function view_kiyaku(){
	window.open("http://www.mp.moshimo.com/mp/www/msm/member?shop_id=457336&signature=","MEMBER","left=10,top=30,scrollbars=yes,location=yes,menubar=no");
}

function view_privacy(){
	window.open("http://www.mp.moshimo.com/mp/www/msm/privacy?shop_id=457336&signature=","PRIVACY","left=10,top=30,scrollbars=yes,location=yes,menubar=no");
}

function view_faq(){
	window.open("http://www.mp.moshimo.com/mp/www/msm/faq?shop_id=457336&signature=","FAQ","left=10,top=30,scrollbars=yes,location=yes,menubar=no");
}

function go_writereview(id){
	window.open("http://www.moshimo.com/articles/review/post?article_id=" + id + "&shop_id=457336","FAQ","left=10,top=30,scrollbars=yes,location=yes,menubar=no");
}

