$(document).ready(function(){
	var glnavi = $('#globalNavi > li');
	$(glnavi).mouseover(function(){
		$(this).children('a').children('span').show();
	});
	$(glnavi).mouseout(function(){
		$(this).children('a').children('span').hide();
	});
});
	
$(document).ready(function(){
	var cat = $("body").attr("id");
	var catClass = $("body").attr("class");
	if(cat){
		if(cat != "home" || cat !=undefined){
			if(Boolean(document.getElementById('globalNavi'+cat))){
				document.getElementById('globalNavi'+cat).setAttribute('class', 'on');
				document.getElementById('globalNavi'+cat).setAttribute('className', 'on');
			}
			if(Boolean(document.getElementById('subNavi'+cat))){
				document.getElementById('subNavi'+cat).setAttribute('class', 'on');
				document.getElementById('subNavi'+cat).setAttribute('className', 'on');
			}
		}
	}
	if(catClass){
		if(Boolean($(".cal"+catClass))){
			$(".cal"+catClass).addClass('on');
		}
	}
});

$(document).ready(function(){
		var defKeyword ="キーワードを入力してください";
		$("form .fld").attr("value",defKeyword);
		
		$("form .fld").focus(function () {
				if($(this).attr("value") == defKeyword){
				this.value = "";
				}
		});
		$("form").submit(function() {
			if($(this).attr("id") != "twitter_form"){
				linkUrl = '/search/';
				fncKeyword = $(this).children("input[name='search']").val();
				if(fncKeyword !== defKeyword){
						if(fncKeyword !== ""){
						location.href = linkUrl + fncKeyword;
				
						}
				}
				return false;
			}
		});
});

var palsystem = {}
palsystem.RollOverImage = {
	init : function(){
		var conf = 
		{
			className: 'rollover',
			postfix : '_f2'
		};
		var imgNodeList = $('.rollover');
		var node;
		var len = imgNodeList.length;
		for(var i = 0; i < len; i++)
		{
			node = imgNodeList[i];
			node.originalSrc = node.src;
			if(node.originalSrc.indexOf('_f2.') != -1){
				continue;
			}
			node.rolloverSrc = node.originalSrc.replace(/(\.gif|\.jpg|\.png)/, conf.postfix + "$1");
			$(node).unbind('mouseover');
			$(node).unbind('mouseout');
			$(node).mouseover(function(){
				this.src = this.rolloverSrc;
			});
			$(node).mouseout(function(){
				this.src = this.originalSrc;
			});
			this.preload(node.rolloverSrc);
		}
	},
	preload : function(url){
		var l = this.images.length;
		this.images[l] = new Image();
		this.images[l].src = url;
	},
	images: new Array()
}



$(function(){
	palsystem.RollOverImage.init();
});


function showPlagin(idno){
	pc = ('PlagClose' + (idno));
	po = ('PlagOpen' + (idno));
	if( document.getElementById(pc).style.display == "none" ) {
		document.getElementById(pc).style.display = "block";
		document.getElementById(po).style.display = "none";
	}else{
		document.getElementById(pc).style.display = "none";
		document.getElementById(po).style.display = "block";
	}
}


window.onload=autoPOP;

function autoPOP(){
	var x = document.getElementsByTagName('a');
	for (var i=0;i<x.length;i++){
		if (x[i].getAttribute('className') == 'popup' || x[i].getAttribute('class') == 'popup'){
			x[i].onclick = function () {
			return winOpen(this.href)
			}
			x[i].title += '(Popup)';
		}
	}
};

function winOpen(url) {
	window.open(
		url,
		'popup',
		'width=550,height=360,scrollbars=0,resizable=0'
	);

	return false;
};

