function getIEversionNumber(){
	var ua = navigator.userAgent;
	var MSIEOffset = ua.indexOf("MSIE ");
	if(MSIEOffset == -1){
		return 0;
	} else {
		return parseFloat(ua.substring(MSIEOffset + 5, ua.indexOf(";",MSIEOffset)));
	}
}

$(function(){
	$.get("/common/js/url_proxy.php",function(d){
		$(d).find("item").each(function(i){
			
			if(i == 3){
				return false;
			}
			var $entry=$(this);
			var $title=$(this).find("title").text();
			var $link=$(this).find("link").text();
			var $imageurl=$(this).find("description").text();
			var $date=$(this).find("dc\\:date").text();
			if($date == ''){$date = $(this).find('date').text();}
			var $creator = $(this).find("dc\\:creator").text();
			if($creator == ''){$creator = $(this).find('creator').text();}
			
			var s='';
			s+='<a href="'+$link+'" target="_blank">';
			s+='<dl class="clearfix">';
			s+='<dt class="phBox_idx_ri02"><img src="'+$imageurl+'" height="41"></dt>';
			s+='<dd class="listBlog01_idx">';
			s+='<span class="dateSet">'+convertDate($date) +'</span>';
			s+='<strong>'+$creator+'</strong>';
			s+='<em class="titleSet">'+limitTitle($title)+'</em>';
			s+='</dd>';
			s+='</dl>';
			s+='</a>';
			
			$('#blogBoxList a:nth-child(1)').css("border-top","none");
			$("#blogBoxList").append($(s));
			
		});
	});
});

function convertDate(nowDate){
	var objDate = new String(nowDate);
	
	var updateYear = objDate.substring(0, 4);
	var updateMonth = objDate.substring(5, 7);
	var setdateMonth = objDate.substring(5, 7)-1;
	var updateDate = objDate.substring(8, 10);
	
	var $date = updateYear + "." + updateMonth + "." + updateDate;
	return $date;
}

function limitTitle(nowTitle){
	
	var refreshTxt = nowTitle;
	var titleLen = refreshTxt.length;
	
	if(titleLen >= 31){
		var reTxt = refreshTxt.substring(0, 30);
		$title = reTxt+"…";
	}else{
		var reTxt = refreshTxt;
		$title = reTxt;
	}
	return $title;
}
function convertImgae(setImage){
	var $imageurl = setImage;
	
	return $imageurl;
}


$.fn.dropDown = function() {
  
  this.each(function() {
    
    function hide() {
		$('ul, li', this).css("display","none");
    }
  
    function show() {
		$('ul, li', this).css("display","block");
    }
    
    $('ul, li', this).hover(show, hide);
    $('li', this).hover(
      function() { $(this).addClass('hover'); },
      function() { $(this).removeClass('hover'); }
    );
    
  });
  
};

$(function(){
	
	setLastChild('#topicsBox div',"border-bottom","0");
	
	var archiveCount = $("ul.archiveList li").length;
	$("ul.archiveList li:nth-child("+archiveCount+")").css("background","none");
	
	$("ul.archiveList_Line li:nth-child(6n+1)").css("padding-left","0");
	$("ul.archiveList_Line li:nth-child(6n+1)").css("margin-left","0");
	$("ul.archiveList li:nth-child(8n+1)").css("padding-left","0");
	
	$("#special ul.archiveList_Line li:nth-child(8n+1)").css("padding-left","0");
	$("#special ul.archiveList_Line li:nth-child(8n+1)").css("margin-left","0");
	$("#special ul.archiveList li:nth-child(8n+1)").css("padding-left","0");
	$("#item ul.archiveList_Line li:nth-child(8n+1)").css("padding-left","0");
	$("#item ul.archiveList_Line li:nth-child(8n+1)").css("margin-left","0");
	
	$("ul.archiveList_thumb li:nth-child(8n)").css("padding-right","0");
	$("ul.archiveList_thumb li:nth-child(8n)").css("margin-right","0");
	$("ul.archiveList_thumb li:nth-child(8n)").css("margin-bottom","20px");
	
	$("#itemBox li:nth-child(2)").css("margin","0 9px");
	
	
	var evenCount = $("div.topicsBox.even").length;
	var oddCount = $("div.topicsBox.odd").length;
	
	if((oddCount == 1)&&(evenCount == 0)){
		$("div.topicsBox:nth-child(1n)").css("border-bottom","0");
	}else if((oddCount == 1)&&(evenCount == 1)){
		$("div.topicsBox.odd:nth-child(1n)").css("border-bottom","0");
		$("div.topicsBox:last").css("border-bottom","0");
	}else if((oddCount == 2)&&(evenCount == 1)){
		$("div.topicsBox.even:nth-child(1n)").css("border-bottom","0");
		$("div.topicsBox:last").css("border-bottom","0");		
	}else if((oddCount == 2)&&(evenCount == 2)){
		$("div.topicsBox.odd:nth-child(2n)").css("border-bottom","0");
		$("div.topicsBox:last").css("border-bottom","0");
	}else if((oddCount == 3)&&(evenCount == 2)){
		$("div.topicsBox.even:nth-child(2n)").css("border-bottom","0");
		$("div.topicsBox:last").css("border-bottom","0");
	}else if((oddCount == 3)&&(evenCount == 3)){
		$("div.topicsBox.odd:nth-child(3n)").css("border-bottom","0");
		$("div.topicsBox:last").css("border-bottom","0");
	}
	
	
	
	$("ul.archiveList_top li:nth-child(1)").css("padding-left","0");
	$("ul.archiveList_top li:nth-child(1)").css("margin-left","0");
	$("ul.archiveList_top li:nth-child(5)").css("background","none");
	
	$(".type03 div.entryPhBox01:nth-child(2)").css("padding","0 20px");
	$(".type03 div.entryPhBox01:nth-child(4)").css("clear","both");
	$(".type03 div.entryPhBox01:nth-child(5)").css("padding","0 20px");
	$(".Free div.entryPhBox01:nth-child(2)").css("padding","0 20px");
	$(".Free div.entryPhBox01:nth-child(4)").css("clear","both");
	$(".Free div.entryPhBox01:nth-child(5)").css("padding","0 20px");
	$("#special div.specialBox_le01:nth-child(4)").css("margin-right","-25px");
	$("#special div.specialBox_le01:nth-child(8)").css("margin-right","-25px");
	$("#special div.specialBox_le01:nth-child(4)").css("margin-bottom","25px");
	
	$("#item div.itemBox_base01:nth-child(6n)").css("margin-right","-47px");
	$("#item div.itemBox_base01:nth-child(6n)").css("margin-bottom","25px");
	
});


//ToolTip
$(function(){
	
	//MonthlyCoordinate
	toolTip("#post01",".icon_zozo","a.link_zozo",-42,-32);
	toolTip("#post01",".icon_pal","a.link_pal",-42,-56);
	toolTip("#post02",".icon_zozo","a.link_zozo",-42,-32);
	toolTip("#post02",".icon_pal","a.link_pal",-42,-56);
	toolTip("#post03",".icon_zozo","a.link_zozo",-42,-32);
	toolTip("#post03",".icon_pal","a.link_pal",-42,-56);
	toolTip("#post04",".icon_zozo","a.link_zozo",-42,-32);
	toolTip("#post04",".icon_pal","a.link_pal",-42,-56);
	toolTip("#post05",".icon_zozo","a.link_zozo",-42,-32);
	toolTip("#post05",".icon_pal","a.link_pal",-42,-56);
	toolTip("#post06",".icon_zozo","a.link_zozo",-42,-32);
	toolTip("#post06",".icon_pal","a.link_pal",-42,-56);
	toolTip("#post07",".icon_zozo","a.link_zozo",-42,-32);
	toolTip("#post07",".icon_pal","a.link_pal",-42,-56);
	toolTip("#post08",".icon_zozo","a.link_zozo",-42,-32);
	toolTip("#post08",".icon_pal","a.link_pal",-42,-56);
	toolTip("#post09",".icon_zozo","a.link_zozo",-42,-32);
	toolTip("#post09",".icon_pal","a.link_pal",-42,-56);
	toolTip("#post10",".icon_zozo","a.link_zozo",-42,-32);
	toolTip("#post10",".icon_pal","a.link_pal",-42,-56);
	
	
	//HotTopics
	toolTip("#postHot01",".icon_zozo","a.link_zozo",-42,-64);
	toolTip("#postHot02",".icon_zozo","a.link_zozo",-42,-64);
	toolTip("#postHot03",".icon_zozo","a.link_zozo",-42,-64);
	toolTip("#postHot04",".icon_zozo","a.link_zozo",-42,-64);
	toolTip("#postHot05",".icon_zozo","a.link_zozo",-42,-64);
	toolTip("#postHot06",".icon_zozo","a.link_zozo",-42,-64);
	toolTip("#postHot01",".icon_pal","a.link_pal",-42,-36);
	toolTip("#postHot02",".icon_pal","a.link_pal",-42,-36);
	toolTip("#postHot03",".icon_pal","a.link_pal",-42,-36);
	toolTip("#postHot04",".icon_pal","a.link_pal",-42,-36);
	toolTip("#postHot05",".icon_pal","a.link_pal",-42,-36);
	toolTip("#postHot06",".icon_pal","a.link_pal",-42,-36);
	
});

//Function:ToolTip
function toolTip(fieldName,filedClass,LinkClass,top,left){
	$(fieldName).css("position","relative");
	$(fieldName + " " + filedClass).css("opacity","0.9");
	$(fieldName + " " + filedClass).css("position","absolute");
	$(fieldName + " " + filedClass).css("display","none");
	
	$(fieldName + " " + LinkClass).mouseover(function(){
       $(fieldName + " " + filedClass).css({
			"display": "block",
            "top":top+"px",
            "left":left+"px"
        });
    }).mouseout(function(){
       $(fieldName + " " + filedClass).css("display","none");
    });
}


//Function:Line Setting
function setFirstChild(setAttr,cssProperty,cssValue){
	$(setAttr+':nth-child(2)').css(cssProperty, cssValue);
}
function setNumChild(setAttr,cssProperty,cssValue){
	$(setAttr+':nth-child(3)').css(cssProperty, cssValue);
}
function setLastChild(setAttr,cssProperty,cssValue){
	$(setAttr+':last-child').css(cssProperty, cssValue);
}

function openWin(theURL) {
	var winX=816;
	var winY=600;
	var winMoveX = (window.screen.width - winX)/2;
	var winMoveY = (window.screen.height - winY)/2;
	win = window.open(theURL,"win","screenX=0,screenY=0,top="+winMoveY+",left="+winMoveX+",toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width="+winX+",height="+winY);
	win.focus();
}

function setNewIcon(y,m,d,limitDays){
	var newday = new Date(y+"/"+m+"/"+d);
	var oldday = new Date();
	var n = (oldday - newday)/(1000*60*60*24);
	if (n <= limitDays){
		$(".date").addClass("new");
	}
}
