//メイン関数
function rssReader_myclo(ids,url){
	var xml = new JKL.ParseXML(url);	// JKL.ParseXMLオブジェクトを生成
	var func = function(data){
		onloaded_myclo(ids,data);
	}
	xml.async(func);
	xml.parse();
}

function onloaded_myclo(ids,xml){
	var data = "";
	var j = 0;

	if(xml['rdf:RDF'].Items.Item != undefined && xml['rdf:RDF'].Items.Item[0] == undefined){
		img_num = xml['rdf:RDF'].Items.Item.photo_main;
		img = xml['rdf:RDF'].Items.Item.photo_1;
		if(img_num == 1){ img = xml['rdf:RDF'].Items.Item.photo_1;}
		else if(img_num == 2){ img = xml['rdf:RDF'].Items.Item.photo_2;}
		else if(img_num == 3){ img = xml['rdf:RDF'].Items.Item.photo_3;}
		data += '<div class="brandItemImgBox">';
		data += '<div class="blandItemImg">';
		data += '<a href="http://www.mycloz.com/closet/'+xml['rdf:RDF'].Items.Item.user_id+'/'+xml['rdf:RDF'].Items.Item.photo_id+'" target="_brank">';
		data += '<img src="http://www.mycloz.com/app/webroot/uploads/photo/'+img+'" width="85" />';
		data += '</a>';
		data += '</div>';
		data += '<div class="brandItemInfo"><table cellspacing="0" cellpadding="0" border="0"><tr>';
		data += '<td class="pointGood">'+xml['rdf:RDF'].Items.Item.rating+'</td>';
		data += '<td class="pointComment">'+xml['rdf:RDF'].Items.Item.comment+'</td>';
		data += '<td class="pointAccess">'+xml['rdf:RDF'].Items.Item.photo_access+'</td>';
		data += '</tr></table></div>';
		data += '</div>';
		var aobj = document.getElementById('myclo_xml_more');
		aobj.style.display = 'inline';
	}else if(xml['rdf:RDF'].Items.Item != undefined){
		for(i = 0;i < xml['rdf:RDF'].Items.Item.length; i++){
			img_num = xml['rdf:RDF'].Items.Item[i].photo_main;
			img = xml['rdf:RDF'].Items.Item[i].photo_1;
			if(img_num == 1){ img = xml['rdf:RDF'].Items.Item[i].photo_1;}
			else if(img_num == 2){ img = xml['rdf:RDF'].Items.Item[i].photo_2;}
			else if(img_num == 3){ img = xml['rdf:RDF'].Items.Item[i].photo_3;}
			data += '<div class="brandItemImgBox">';
			data += '<div class="blandItemImg">';
			data += '<a href="http://www.mycloz.com/closet/'+xml['rdf:RDF'].Items.Item[i].user_id+'/'+xml['rdf:RDF'].Items.Item[i].photo_id+'" target="_brank">';
			data += '<img src="http://www.mycloz.com/app/webroot/uploads/photo/'+img+'" width="85" />';
			data += '</a>';
			data += '</div>';
			data += '<div class="brandItemInfo"><table cellspacing="0" cellpadding="0" border="0"><tr>';
			data += '<td class="pointGood">'+xml['rdf:RDF'].Items.Item[i].rating+'</td>';
			data += '<td class="pointComment">'+xml['rdf:RDF'].Items.Item[i].comment+'</td>';
			data += '<td class="pointAccess">'+xml['rdf:RDF'].Items.Item[i].photo_access+'</td>';
			data += '</tr></table></div>';
			data += '</div>';
			j++;
			if(j == xml['rdf:RDF'].Items.Item.length){
				break;
			}
		}
		var aobj = document.getElementById('myclo_xml_more');
		aobj.style.display = 'inline';
	}else{
		data += 'データが取得できませんでした。';
	}

	//出力
	document.getElementById(ids).innerHTML = data;
}

//メイン関数
function rssReader_yahoo(ids,url){
	url = url.replace('+','');
	var xml = new JKL.ParseXML('http://www.mycloz.com/toolAdmin/xml_take.php?url='+url );	// JKL.ParseXMLオブジェクトを生成
	var func = function(data){
		onloaded_yahoo(ids,data);
	}
	xml.async(func);
	xml.parse();
}

function onloaded_yahoo(ids,xml){
	var data = "";
	var j = 0;
	var k = 0;
	var dates = new Date();
	var day = dates.getDate();
	var month = dates.getMonth();
	var hour = dates.getHours();
	var min = dates.getMinutes();
	if(hour.length == 1){
		hour = '0'+hour;
	}
	if(min.length == 1){
		min = '0'+min;
	}
	if(xml["AuctionSearchResult"].item != undefined && xml["AuctionSearchResult"].item[0] == undefined){
		price = xml["AuctionSearchResult"].item.price;
		price = price.replace(',','');
		price = price.replace('円','');
		temp_time = xml["AuctionSearchResult"].item.endtime;
		temp_time = temp_time.replace('時','');
		temp_time = temp_time.replace('分','');
		temp_time = temp_time.replace('日','');
		temp_time = temp_time.replace('月','');
		time = temp_time.split(' ');
		for(k;k < 4;k++){
			if(time[k].length == 1){
				time[k] = '0'+time[k];
			}
		}
		if(day != parseInt(time[1])){
			time_left = 2400 + parseInt(''+time[2]+time[3]) - parseInt(''+hour+min);
		}else{
			time_left = parseInt(''+time[2]+time[3]) - parseInt(''+hour+min);
		}
		data += '<div class="brandItemImgBox">';
		data += '<div class="blandItemImg">';
		data += '<a href="'+xml["AuctionSearchResult"].item.url+'" target="_brank">';
		data += '<img src="'+xml["AuctionSearchResult"].item.img+'" width="85" />';
		data += '</a>';
		data += '</div>';
		data += '<div class="brandItemInfo">';
		data += '<ul>';
		data += '<li>'+price+'</li>';
		data += '<li>残り'+time_left+'分</li>';
		data += '</ul>';
		data += '</div>';
		data += '</div>';
		var aobj = document.getElementById('yahoo_xml_more');
		aobj.style.display = 'inline';
	}else if(xml["AuctionSearchResult"].item != undefined){
		for(i = 0;i < xml['AuctionSearchResult'].item.length;i++){
			price = xml["AuctionSearchResult"].item[i].price;
			price = price.replace(',','');
			price = price.replace('円','');
			temp_time = xml["AuctionSearchResult"].item[i].endtime;
			temp_time = temp_time.replace('時','');
			temp_time = temp_time.replace('分','');
			temp_time = temp_time.replace('日','');
			temp_time = temp_time.replace('月','');
			time = temp_time.split(' ');
			for(k;k < 4;k++){
				if(time[k].length == 1){
					time[k] = '0'+time[k];
				}
			}
			if(day != parseInt(time[1])){
				time_left = 2400 + parseInt(''+time[2]+time[3]) - parseInt(''+hour+min);
			}else{
				time_left = parseInt(''+time[2]+time[3]) - parseInt(''+hour+min);
			}
			data += '<div class="brandItemImgBox">';
			data += '<div class="blandItemImg">';
			data += '<a href="'+xml["AuctionSearchResult"].item[i].url+'" target="_brank">';
			data += '<img src="'+xml["AuctionSearchResult"].item[i].img+'" width="85" />';
			data += '</a>';
			data += '</div>';
			data += '<div class="brandItemInfo">';
			data += '<ul>';
			data += '<li>'+price+'</li>';
			data += '<li>残り'+time_left+'分</li>';
			data += '</ul>';
			data += '</div>';
			data += '</div>';
			j++;
			if(j == 3){
				break;
			}
		}
		var aobj = document.getElementById('yahoo_xml_more');
		aobj.style.display = 'inline';
	}else{
		data += 'データが取得できませんでした。';
	}

	//出力
	document.getElementById(ids).innerHTML = data;
}

//メイン関数
function rssReader_rakuten(ids,url){
	var xml = new JKL.ParseXML('http://www.mycloz.com/toolAdmin/xml_take.php?url='+url );	// JKL.ParseXMLオブジェクトを生成
	var func = function(data){
		onloaded_rakuten(ids,data);
	}
	xml.async(func);
	xml.parse();
}

function onloaded_rakuten(ids,xml){
	var data = "";
	var j = 0;
	var title = "";

	if(xml.Response.Body != undefined && xml.Response.Body.ItemSearch.Items != undefined && xml.Response.Body.ItemSearch.Items.Item[0] == undefined){
		title = xml.Response.Body.ItemSearch.Items.Item.itemName.substr(0,16);
		data += '<div class="brandItemImgBox">';
		data += '<div class="blandItemImg">';
		data += '<a href="'+xml.Response.Body.ItemSearch.Items.Item.itemUrl+'" target="_brank">';
		data += '<img src="'+xml.Response.Body.ItemSearch.Items.Item.mediumImageUrl+'" width="85" />';
		data += '</a>';
		data += '</div>';
		data += '<div class="brandItemInfo">';
		data += '<p>'+title+'...</p>';
		data += '</div>';
		data += '</div>';
		var aobj = document.getElementById('rakuten_xml_more');
		aobj.style.display = 'inline';
	}else if(xml.Response.Body != undefined && xml.Response.Body.ItemSearch.Items != undefined){
		for(i = 0;i < xml.Response.Body.ItemSearch.Items.Item.length;i++){
			title = xml.Response.Body.ItemSearch.Items.Item[i].itemName.substr(0,16);
			data += '<div class="brandItemImgBox">';
			data += '<div class="blandItemImg">';
			data += '<a href="'+xml.Response.Body.ItemSearch.Items.Item[i].itemUrl+'" target="_brank">';
			data += '<img src="'+xml.Response.Body.ItemSearch.Items.Item[i].mediumImageUrl+'" width="85" />';
			data += '</a>';
			data += '</div>';
			data += '<div class="brandItemInfo">';
			data += '<p>'+title+'...</p>';
			data += '</div>';
			data += '</div>';
			j++;
			if(j == 3){
				break;
			}
		}
		var aobj = document.getElementById('rakuten_xml_more');
		aobj.style.display = 'inline';
	}else{
		data += 'データが取得できませんでした。';
	}
	//出力
	document.getElementById(ids).innerHTML = data;
}

//メイン関数
function rssReader_amazon(ids,url){
	url = url.replace('+','|');
	var xml = new JKL.ParseXML('http://www.mycloz.com/toolAdmin/xml_take.php?url='+url );	// JKL.ParseXMLオブジェクトを生成
	var func = function(data){
		onloaded_amazon(ids,data);
	}
	xml.async(func);
	xml.parse();
}

function onloaded_amazon(ids,xml){
	var data = "";
	var j = 0;

	data += "<table>";
	if(xml.ItemSearchResponse.Items.Item != undefined && xml.ItemSearchResponse.Items.Item[0] == undefined){
		if('MediumImage' in xml.ItemSearchResponse.Items.Item){
			data += '<tr>';
			data += '<td valign="top" class="border">';
			data += '<a href="'+xml.ItemSearchResponse.Items.Item.DetailPageURL+'" target="_brank">';
			data += '<img src="'+xml.ItemSearchResponse.Items.Item.MediumImage.URL+'" width="85" />';
			data += '</a>';
			data += '</td>';
			data += '<td class="pa5Left">';
			data += xml.ItemSearchResponse.Items.Item.ItemAttributes.Title+'<br />';
			if('CustomerReviews' in xml.ItemSearchResponse.Items.Item){
				data += '<img src="/app/webroot/image/amazon_rank'+xml.ItemSearchResponse.Items.Item.CustomerReviews.AverageRating+'.gif" /><br />';
			}
			data += xml.ItemSearchResponse.Items.Item.ItemAttributes.Binding;
			data += '</td>';
			data += '</tr>';
		}else{
			data += '<tr>';
			data += '<td>';
			data += 'データが取得できませんでした。';
			data += '</td>';
			data += '</tr>';
		}
	}else if(xml.ItemSearchResponse.Items.Item != undefined){
		for(i = 0;i < xml.ItemSearchResponse.Items.Item.length; i++){
			if('MediumImage' in xml.ItemSearchResponse.Items.Item[i]){
				data += '<tr>';
				data += '<td valign="top" class="border">';
				data += '<a href="'+xml.ItemSearchResponse.Items.Item[i].DetailPageURL+'" target="_brank">';
				data += '<img src="'+xml.ItemSearchResponse.Items.Item[i].MediumImage.URL+'" width="85" />';
				data += '</a>';
				data += '</td>';
				data += '<td class="pa5Left">';
				data += xml.ItemSearchResponse.Items.Item[i].ItemAttributes.Title+'<br />';
				if('CustomerReviews' in xml.ItemSearchResponse.Items.Item[i]){
					data += '<img src="/app/webroot/image/amazon_rank'+xml.ItemSearchResponse.Items.Item[i].CustomerReviews.AverageRating+'.gif" /><br />';
				}
				data += xml.ItemSearchResponse.Items.Item[i].ItemAttributes.Binding;
				data += '</td>';
				data += '</tr>';
				j++;
				if(j == 3){
					break;
				}
			}
		}
	}else{
		data += '<tr>';
		data += '<td>';
		data += 'データが取得できませんでした。';
		data += '</td>';
		data += '</tr>';
	}
	data += "</table>";
	//出力
	document.getElementById(ids).innerHTML = data;
}

//メイン関数
function rssReader_kizasi(ids,url){
	url = url.replace('+','');
	var xml = new JKL.ParseXML('http://www.mycloz.com/toolAdmin/xml_take.php?url='+url );	// JKL.ParseXMLオブジェクトを生成
	var func = function(data){
		onloaded_kizasi(ids,data);
	}
	xml.async(func);
	xml.parse();
}

function onloaded_kizasi(ids,xml){
	var data = "";
	var j = 0;

	if(xml.rss.channel.item != undefined && xml.rss.channel.item[0] == undefined){
		data += '<a class="fcLightBlue fwBold" href="'+xml.rss.channel.item.link+'" target="_brank">'+xml.rss.channel.item.title+'</a><br/>';
		if(xml.rss.channel.item.pubData != undefined){
			data += '<span class="fcGray">'+chgMessHalf(xml.rss.channel.item.pubData)+'</span><br/>';
		}
		data += '<p>'+xml.rss.channel.item.description.substr(0,60)+'...</p>';
		data += '<ul class="link">';
	}else if(xml.rss.channel.item != undefined){
		data += '<a class="fcLightBlue fwBold" href="'+xml.rss.channel.item[0].link+'" target="_brank">'+xml.rss.channel.item[0].title+'</a><br/>';
		if(xml.rss.channel.item[0].pubData != undefined){
			data += '<span class="fcGray">'+chgMessHalf(xml.rss.channel.item[0].pubData)+'</span><br/>';
		}
		data += '<p>'+xml.rss.channel.item[0].description.substr(0,60)+'...</p>';
		data += '<ul class="link">';
		for(i = 0;i < xml.rss.channel.item.length;i++){
			if(j == 0){
			}else if(j != 0){
				if(xml.rss.channel.item[i].title != undefined){
					data += '<li>';
					data += '<a href="'+xml.rss.channel.item[i].link+'" target="_brank">';
					data += xml.rss.channel.item[i].title;
					data += '</a>';
					data += '</li>';
				}
			}
			j++;
			if(j == 6){
				break;
			}
		}
	}else{
		data += 'データが取得できませんでした。';
	}
	data += '</ul>';
	//出力
	document.getElementById(ids).innerHTML = data;
}

//メイン関数
function rssReader_cj(ids,url){
	var xml = new JKL.ParseXML('http://www.mycloz.com/toolAdmin/xml_take.php?url='+url );	// JKL.ParseXMLオブジェクトを生成
	var func = function(data){
		onloaded_cj(ids,data);
	}
	xml.async(func);
	xml.parse();
}

function onloaded_cj(ids,xml){
	var data = "";
	var j = 0;

	if(xml.syohin != undefined && xml.syohin.brand != undefined && xml.syohin.brand.detail[0] == undefined){
		title = xml.syohin.brand.detail.syohinname.substr(0,16);
		data += '<div class="brandItemImgBox">';
		data += '<div class="blandItemImg">';
		data += '<a href="http://www.crownjewel.co.jp'+xml.syohin.brand.detail.url+'" target="_brank">';
		data += '<img src="http://www.crownjewel.co.jp'+xml.syohin.brand.detail.gazou+'" width="85" />';
		data += '</a>';
		data += '</div>';
		data += '<div class="brandItemInfo">';
		data += '<p>'+title+'...</p>';
		data += '</div>';
		data += '</div>';
		var aobj = document.getElementById('cj_xml_more');
		aobj.setAttribute('href','http://www.crownjewel.co.jp/women_item_detail_search.command?request=search&BRAND='+cjid);
		aobj.style.display = 'inline';
	}else if(xml.syohin != undefined && xml.syohin.brand != undefined && xml.syohin.brand.detail[0] != undefined){
		for(i = 0; i < xml.syohin.brand.detail.length;i++){
			title = xml.syohin.brand.detail[i].syohinname.substr(0,16);
			data += '<div class="brandItemImgBox">';
			data += '<div class="blandItemImg">';
			data += '<a href="http://www.crownjewel.co.jp'+xml.syohin.brand.detail[i].url+'" target="_brank">';
			data += '<img src="http://www.crownjewel.co.jp'+xml.syohin.brand.detail[i].gazou+'" width="85" />';
			data += '</a>';
			data += '</div>';
			data += '<div class="brandItemInfo">';
			data += '<p>'+title+'...</p>';
			data += '</div>';
			data += '</div>';
			j++;
			if(j == 3){
				break;
			}
		}
		var aobj = document.getElementById('cj_xml_more');
		var cjid = aobj.getAttribute('href');
		aobj.setAttribute('href','http://www.crownjewel.co.jp/women_item_detail_search.command?request=search&BRAND='+cjid);
		aobj.style.display = 'inline';
	}else{
		data += 'データが取得できませんでした。';
	}

	
	//出力
	document.getElementById(ids).innerHTML = data;
}

function chgMessHalf(mesg){
	//文字定義
	half = "0123456789";
	half += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	half += "abcdefghijklmnopqrstuvwxyz";
	half += "-+_@., /";
	half += "アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲンァィゥェォッャュョー";
	halfArr = new Array("ヴ","ガ","ギ","グ","ゲ","ゴ","ザ","ジ","ズ","ゼ","ゾ","ダ","ヂ","ヅ","デ","ド","バ","ビ","ブ","ベ","ボ","パ","ピ","プ","ペ","ポ");

	full = "０１２３４５６７８９";
	full += "ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ";
	full += "ａｂｃｄｅｆｇｈｉｊｋｌｍｎｏｐｑｒｓｔｕｖｗｘｙｚ";
	full += "－＋＿＠．，　／";
	full += "ｱｲｳｴｵｶｷｸｹｺｻｼｽｾｿﾀﾁﾂﾃﾄﾅﾆﾇﾈﾉﾊﾋﾌﾍﾎﾏﾐﾑﾒﾓﾔﾕﾖﾗﾘﾙﾚﾛﾜｦﾝｧｨｩｪｫｯｬｭｮｰ";
	fullArr = new Array("ｳﾞ","ｶﾞ","ｷﾞ","ｸﾞ","ｹﾞ","ｺﾞ","ｻﾞ","ｼﾞ","ｽﾞ","ｾﾞ","ｿﾞ","ﾀﾞ","ﾁﾞ","ﾂﾞ","ﾃﾞ","ﾄﾞ","ﾊﾞ","ﾋﾞ","ﾌﾞ","ﾍﾞ","ﾎﾞ","ﾊﾟ","ﾋﾟ","ﾌﾟ","ﾍﾟ","ﾎﾟ");

	var messIn = mesg;
	var messOut = "";

	//半角カナ用
	for(i=0; i<halfArr.length; i++){
		reg = new RegExp(fullArr[i],"g"); 
		messIn = messIn.replace(reg, halfArr[i]);
	}

	for(i=0; i<messIn.length; i++){
		oneStr = messIn.charAt(i);
		num = full.indexOf(oneStr,0);
		oneStr = num >= 0 ? half.charAt(num) : oneStr;
		messOut += oneStr;
	}

	return messOut;
}


