function init(){
	menuRollOver();
	newsLoad();
	setPng();
}

if (window.addEventListener){
	window.addEventListener("load",init,false);
}else if(window.attachEvent){
	window.attachEvent("onload",init);
}else{
	window.onload = init;
}

function menuRollOver() {
	
	if(!$("#access")[0]){
		return;
	}
	var menuUl = $("#access")[0].getElementsByTagName("div");
	
	for(i=0;i<menuUl.length;i++){
		
		menuUl[i].onmouseover = function(){
			this.style.overflow = "visible";
			/*this.style.height = "auto";*/
		}
		liList = menuUl[i].getElementsByTagName("li");
		
		for(s=0;s<liList.length;s++){
			liList[s].onmouseout = function(){
				this.parentNode.parentNode.style.overflow = "hidden";
			}
		}
	}
	

}


function newsLoad(){

	$.ajax({
		url:"./?feed=rss2&cat=41",
		type:"GET",
		dataType:"xml",
		success: function(xmlData){

			ulTag = document.createElement("ul");
			
			itemList = $("item",xmlData);
			
			if(itemList.length < 5){
				loopTime = itemList.length;
			}else{
				loopTime = 5;
			}
			
			for(i=0;i<loopTime;i++){

				//titleValue = $("title",itemList[i])[0].text;
				//linkValue = $("link",itemList[i])[0].text;
				
				titleValue = $(itemList[i]).find("title").text();
				linkValue = $(itemList[i]).find("link").text();
				
				bytes = 0;
				output = "";
				for(t=0;t<titleValue.length;t++){
				
					n = escape(titleValue.charAt(t));
					if(n.indexOf("%u") != -1){
						bytes += 3;
					}else{
						bytes += 1;
					}
					if(bytes <= 42){
						output += titleValue.substr(t,1);
					}
				}
				if(bytes > 42){
					output += "...";
				}

				liTag = document.createElement("li");
				aTag = document.createElement("a");
				aTag.setAttribute("href",linkValue);
				aTag.innerHTML = output;
				
				liTag.appendChild(aTag);
				ulTag.appendChild(liTag);
			}
			
			$("#news_list").html(ulTag);
		}
	});

}


function setPng(){

	if(navigator.userAgent.indexOf("MSIE 6") == -1){
		return;
	}
	var imgList = $("img");
	
	for(i=0;i<imgList.length;i++){
	
		if(imgList[i].src.indexOf("png") == -1){
			continue;
		}
		var tagetNode = imgList[i].parentNode;
		tagetNode.src = imgList[i].src;
		
		if(imgList[i].className == "rollover"){
		
			tagetNode.onmouseover = function(){
				var newSrc = this.src.split(".png"); 
				this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='noscale',src='"+newSrc[0]+"_.png');";
			}
			tagetNode.onmouseout = function(){
				this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='noscale',src='"+this.src+"');";
			}
		}

		tagetNode.style.display = "block";
		tagetNode.style.width = imgList[i].width+"px";
		tagetNode.style.height = imgList[i].height+"px";
		tagetNode.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=noscale,src='"+imgList[i].src+"');";
		imgList[i].style.display = "none";
		
		if(tagetNode.tagName == "A"){
			tagetNode.style.cursor = "pointer";
		}
	}
}
