function accessMap(){

	var u		= document.URL;
	var slug	= u.replace(/http:\/\/(.*)\.astamuse\.com\//, "$1");
	var params, req;
	var h		= slug.match(/product|software|service|inventor|corporation|patentoffice|attorney/);
	if( slug.match(/product|software|service|inventor|corporation|patentoffice|attorney/) ){
		params = { content_type : slug };
		req		= 'http://astamuse.com/analytics/api/content_access_by_date.json';
	}else{
		params 	= { content_category_type : slug };
		req		= 'http://astamuse.com/analytics/api/content_category_access_by_date.json';
	}
	
	$.ajax({
		url		: req,
		data	: params,
		dataType: 'jsonp',
		jsonp	: 'callback',
		success	: function(res){
			var maxValue = 0;
			var values = '';
			var tarDay;
			var dates = '';
			var entry;
			if( res.status == 'success' ){
				for( var i = 0 ; i < res.result.entries.length; i++ ){
					entry	 = res.result.entries[i];
					values	+= ',' + entry.visits;
					tarDay	= ( entry.date.slice(6,7) == 0 ) ? entry.date.slice(7) : entry.date.slice(6);
					dates	+= ( i % 10 != 0 ) ? '|' : '|' + entry.date.slice(4,6) + "/" + tarDay;
					maxValue = Math.max(entry.visits, maxValue);
				}
				
				values	= values.slice(1);
				dates	= dates.slice(1);
				
				maxValue = Math.floor(maxValue/10*1.2) * 10;
				maxValue = ( maxValue == 0 ) ? 20 : maxValue;
				var halfValue = maxValue/2;
				
				var today = res.result.entries[29].date;
				today = ( today.slice(6,7) == 0 ) ? today.slice(4,6) + "/" + today.slice(7) : today.slice(4,6) + "/" + today.slice(6);
				//googleChartAPIを利用して作成されるimgをappendする	
				$("#accessChart .loading").replaceWith($("<img src='http://chart.apis.google.com/chart?"
							 + "chxt=x,y"
							 + "&amp;chxl=0:|" + dates + today + "|1:|0|" + halfValue + "|" + maxValue
							 + "&amp;cht=lc"
							 + "&amp;chs=260x200"
							 + "&amp;chxt=x,y"
							 + "&amp;chm=s,FF9904,0,-1,3"
							 + "&amp;chg=23.1,50,1,5"
							 + "&amp;chd=t:" + values 
							 + "&amp;chds=0," + maxValue + "'/>"));
			}else{
				$("#accessChart .loading").replaceWith("<p style='text-align:center; padding:30px;'>まだデータが蓄積されていません。</p>");
			}
		}
	});
}


/* ***************************************
 * indexドロップダウン notFix 
 */

this.setChildListDrop = function(){
	var sti;
	$(".parentCategory").hover(function(){
		var obj = $(this);
		
		sti = setTimeout(function(){
			$("#idxServiceChildeCat ul").css("display", "none");
			var u 		= obj.attr("id"); // リンクのＵＲＬを格納
			var c 		= "." + u + "div";
			$(c).fadeIn("fast", function(){
				$("#idxServiceChildeCat ul").not(c).css("display", "none");
			}).css("background", "#d4dde4");
		},100);
	},function(){
		clearTimeout(sti);
	});
}



$(document).ready(function(){
	setChildListDrop();
	accessMap();
	$("#selectInput").corner("4px");
	$("#ipcInput").corner("4px");
	$("#indexTextSearch").corner("4px");
	$("#ipcNavi").corner("4px");
});

