
// index list
$(function(){
	var indCon = $('body#index div.contents');
	$(indCon).children('h2:first').css('font-size','200%');
	$(indCon).children('h2:gt(0)').css('font-size','150%');
	$(indCon).children('h2:gt(3)').css('font-size','120%');
});


// stripe code
$(function(){
 $('.htmlcode').each(function() {
  var lis = $(this).children();
  $(lis).find('li:odd').addClass('odd');
 });
 $('.csscode').each(function() {
  var lis = $(this).children();
  $(lis).find('li:odd').addClass('odd');
 });
 $('.jscode').each(function() {
  var lis = $(this).children();
  $(lis).find('li:odd').addClass('odd');
 });
});

$(function(){
 $('.archiveList').each(function() {
  var arclis = $(this).children();
  $(arclis).find('li:odd').addClass('odd');
 });
});


$(function(){
 $('.pagesNav > li:empty').each(function() {
  $(this).remove();
 });
});


// blanker
$(function(){
	var domain = "[@href^=\"http://"+location.hostname+"/\"]";
	$('a[@href^="http"]').not(domain).click(function() {
		$(this).attr('target','_blank');
	});
});

// auto smoose scllorer
$(function(){	var url = "http://" + location.hostname + location.pathname;
	$('a[@href*="#"]').click(function() {
		var id = this.href.substring(this.href.indexOf('#'),this.href.length);
		var hrefUrl = this.href.split(id);
		if(hrefUrl[0] == url) {
			if(id == '#header') {
				$('body').addClass('body');
				$('.body').ScrollTo('slow');
				$('body').removeClass();
				return false;
			}else{
				$(id).ScrollTo('slow');
				return false;
			}
		}
	});
});
	


//comments
$(function(){
	var commentOpen = '<input type="button" value="コメントする" id="commentOpen" class="submit" \/>';
	$('#commentsInput').css('display','none');
	$('#yourcomment').after(commentOpen);
	$('#commentOpen').one('click',function() {
		$('#commentOpen').remove();
		$('#commentsInput').show('slow');
	});
});





//archive list toggle
$(function(){
	$('dl.archiveList dd').css('display','none');
	$('.archiveList dt').toggle(function(){
    $(this).css('background',' #ebebe5 url(/common/images/ico_hide.gif) 5px center no-repeat');
    $(this).next().show('fast');
	}, function(){
    $(this).css('background',' #ebebe5 url(/common/images/ico_add.gif) 5px center no-repeat');
    $(this).next().hide('fast');
	});
});



//code display
$(function(){
	var span = '<span class=\"plain\">Plain Text<\/span>';
	$('dl.csscode dt').append(span);
	$('dl.htmlcode dt').append(span);
	$('dl.jscode dt').append(span);
	$('dl.csscode dt span').text("Plain Text");
	$('dl.htmlcode dt span').text("Plain Text");
	$('dl.jscode dt span').text("Plain Text");
	$('.plain').toggle(function () {
			var basecode = $(this).parent().next().html();
			var basecode = basecode.replace('<ol>', '', 'g')
			.replace('<\/ol>', '', 'g')
			.replace('<code>', '', 'g')
			.replace('<\/code>', '', 'g')
			.replace('<li>', '', 'g')
			.replace('<li class="odd">', '', 'g')
			.replace('<\/li>', '<br />', 'g');
			$(this).parent().next().css('display','none');
			$(this).parent().next().after('<dd><\/dd>');
			$(this).parent().next().next().html(basecode);
			$(this).text("Rich Text");
	},
	function () {
			$(this).parent().next().next().css('display','none');
			$(this).parent().next().css('display','block');
			$(this).text("Plain Text");
	});
});





//zoom img
$(function(){
	$('img[@class="zoom"]').hover(function(){
		$(this).css('cursor','pointer');
	},function(){
		$(this).css('cursor','inherit');
	});
	$('img[@class="zoom"]').click(function(){
		var i = this;
		var iWid = i.width;
		var iHei = i.height;
		var ext = this.src.substring(this.src.length-4,this.src.length);
		var zSrc = this.src.substring(0,this.src.length-6)+ext;
		var zoomi = new Image();
		$(i).before(zoomi);
		zoomi.src = zSrc;	zoomi.width = iWid; zoomi.height = iHei; zoomi.className = 'zoomi';
		var lWid = iWid * 2;
		var lHei = iHei * 2;
		$('.zoomi').animate({ width: lWid,height: lHei}, 500 );
		 zoomi.className = 'zoomii';
		$('img[@class="zoomii"]').click(function(){
			var i = this;
			$(i).animate({ width: iWid,height: iHei}, 500 );
			var zoomOff = function(){ $(i).remove();};
			setTimeout(zoomOff,500);
		});
	});
});


// EOF
