﻿$(document).ready(function(){
	
	$('.page-navi li').each(function(){
		var text = $(this).find('a').text()
		$(this).append('<span>'+ text +'</span>'); 
	});
	
	$('ol .depth-1').each(function(){
		$(this).find('img:first').css({ height:"45px", width:"45px" }); 
	});

	var thisAh = $('.menu a:first').attr('href');
	$('.ajaxBox').hide().load(thisAh + ' .ajaxBox' , function(){
		$(this).animate({opacity:'show' },500)													   
	}); 
	$('.menu li:first').addClass('one current_page_item');

	$(".menu li A").click(function(){
		var ajaxUrl = $(this).attr("href");
		$('.ajaxBox').animate({opacity:'hide' },300).load(ajaxUrl + ' .ajaxBox' , function(){
			$(this).animate({opacity:'show' },500)													   
		}); 
		$('.menu li').removeClass('current_page_item');
		$(this).parent('li').addClass('current_page_item');
		return false;
	});
	
	$(".loading").ajaxStart(function(){
	$(this).show();
	}); 	
	$(".loading").ajaxStop(function(){
	$(this).hide();
	}); 
	
	/*$('ul.list li a').hover(function(){
		$(this).animate({paddingLeft: '20px',width: '203px'},{queue:false,duration:100});
	}, function(){
		$(this).animate({paddingLeft: '3px',width: '223px'},{queue:false,duration:100});
	});*/
	
	var labelText = $("#s").next('label').remove().text();
	$("input#s").val(labelText)
	.focus(function(){
		if (this.value == labelText){
			$(this).val("");
		};		
	}).blur(function(){
		if (this.value == ""){
			$(this).val(labelText)
		};
	});

	$("input,textarea").focus(function(){
		$(this).addClass('on');		
	}).blur(function(){
		$(this).removeClass('on');
	});

});

addComment = {
	moveForm : function(commId, parentId, respondId, postId) {
		var t = this, div, comm = t.I(commId), respond = t.I(respondId), cancel = t.I('cancel-comment-reply-link'), parent = t.I('comment_parent'), post = t.I('comment_post_ID');
		if ( ! comm || ! respond || ! cancel || ! parent )
			return;
		t.respondId = respondId;
		postId = postId || false;
		if ( ! t.I('wp-temp-form-div') ) {
			div = document.createElement('div');
			div.id = 'wp-temp-form-div';
			div.style.display = 'none';
			respond.parentNode.insertBefore(div, respond);
		}
		comm.parentNode.insertBefore(respond, comm.nextSibling);
		if ( post && postId )
			post.value = postId;
		parent.value = parentId;
		cancel.style.display = '';
		cancel.onclick = function() {
			var t = addComment, temp = t.I('wp-temp-form-div'), respond = t.I(t.respondId);
			if ( ! temp || ! respond )
				return;
			t.I('comment_parent').value = '0';
			temp.parentNode.insertBefore(respond, temp);
			temp.parentNode.removeChild(temp);
			this.style.display = 'none';
			this.onclick = null;
			return false;
		}
		try { t.I('comment').focus(); }
		catch(e) {}
		return false;
	},
	I : function(e) {
		return document.getElementById(e);
	}
}
