jQuery.noConflict();

(function($){//BEGIN jQuery
$(function(){//BEGIN jQuery.ready()
	
	/*main, side*/
	$main = $("#mainContents");
	$side = $("#sidebar");
	
	
	
	/* 共通
	 ***********************************/
	
	
	/*gNav*/
	$("#gNavList")
		.pageInit({
			".siteIndex":	"> li:eq(0)",
			".event":		"> li:eq(1)",
			".launch":		"> li:eq(2)",
			".join":		"> li:eq(3)",
			".archives":	"> li:eq(4)"
		}, function(){
			$(this).addClass("active");
		})
		.chimg({autoActive:true});
	
	
	/*langNav*/
	$("#langNav")
		.find("a:eq(0)")
			.addClass("active")
		.end()
		.chimg({autoActive:true});
	
	
	/*ftrLink*/
	$("#ftrLink")
		.pageInit({
			".about":		"> a:eq(0)",
			".team":		"> a:eq(1)",
			".portfolio":	"> a:eq(2)"
		}, function(){
			$(this).addClass("active");
		});
	
	
	
	/*toPageTop*/
	$("div.toPageTop a")
		.click(function(){
			$("html,body").animate({
				scrollTop: 0
			}, 500);
			return false;
		});
	
	
	
	/* siteIndex
	 ***********************************/
	
	/*indexNewsTbl*/
	if(jQuery.feeds && jQuery.feeds["ivs"] && $("#indexNewsTbl").length){
		var feed = jQuery.feeds["ivs"];
		var entries = feed.entry;
		var entries_html = '';
		$.each(entries, function(i, entry){
			if(i > 4) return false;//break
			
			entries_html += '<tr>'
			               + '	<td class="date"><div>' + entry.published.match(/\d+-\d+-\d+/) + '</div></td>'
			               + '	<td class="title"><a href="' + entry.link + '">' + entry.title + '</a></td>'
			               + '</tr>';
			
		});
		$("#indexNewsTbl").append($(entries_html));
	}
	
	
	/*indexMovieBox
	window.onYouTubePlayerReady = function(playerId){
		var indexmovie = window.indexmovie = document.getElementById("movie-player");
		
		if(indexmovie){
			$("#indexMovieBox")
				.each(function(){
					var $movie_box = $(this);
					var $btn_play = $("#movie-ctrl-play", $movie_box);
					var $btn_prev = $("#movie-ctrl-prev", $movie_box);
					var $btn_next = $("#movie-ctrl-next", $movie_box);
					var $btn_volume = $("#movie-ctrl-volume", $movie_box);
					
					var video_list = [
						"HZBUbXj2C54",
						"yCCx7zANsGE",
						"qEsnxQAWOCw",
						"x2rj1VQl30o",
						"OUgOSPuhsHo",
						"CYz1LIVzDEM"
					];
					//var video_list_len = video_list.length;
					var now_video = 0;
					
					
					var startNewVideo = function(id, start_sec){
						indexmovie.loadVideoById(id, start_sec);
						chg_play_btn("pause");
					};
					var setNewVideo = function(id, start_sec){
						indexmovie.cueVideoById(id, start_sec);
					};
					
					var chg_play_btn = function(state){
						var src = $btn_play.attr("src");
						
						var is_pause = state ? (state == "play" ? true : false) : !!src.match("_pause");
						if(is_pause){ //playに
							$btn_play.attr("src", src.replace("_pause", "_play"));
						}else{ //pauseに
							$btn_play.attr("src", src.replace("_play", "_pause"));
						}
						return is_pause;
					};
					
					var chk_exists_video = function(){
						var prev_video = now_video - 1;
						var next_video = now_video + 1;
						
						var action = function(video, $elm){
							if(!video){
								$elm.attr("src", $.srcReplace($elm.attr("src"), '', '_null')).css("cursor", "default").addClass("null");
							}else{
								if($elm.is(".null"))
									$elm.attr("src", $elm.attr("src").replace('_null', '')).css("cursor", "pointer").removeClass("null");
							}
						};
						
						action(video_list[prev_video], $btn_prev);
						action(video_list[next_video], $btn_next);
					};
					
					
					//init
					setNewVideo(video_list[now_video], 0);
					chk_exists_video();
					
					//attach
					$btn_play
						.click(function(){
							if(chg_play_btn()){
								indexmovie.pauseVideo();
							}else{
								indexmovie.playVideo();
							}
						});
					$btn_prev
						.click(function(){
							if($btn_prev.is(".null")) return;
							startNewVideo(video_list[--now_video], 0);
							chk_exists_video();
						});
					$btn_next
						.click(function(){
							if($btn_next.is(".null")) return;
							startNewVideo(video_list[++now_video], 0);
							chk_exists_video();
						});
					$btn_volume
						.click(function(){
							var src = $btn_volume.attr("src");
							if(src.match("_mute")){
								indexmovie.unMute();
								$btn_volume.attr("src", src.replace('_mute', ''));
							}else{
								indexmovie.mute();
								$btn_volume.attr("src", $.srcReplace(src, '', '_mute'));
							}
						});
				});
		}
	};
	*/
	
	
	/* join
	 ***********************************/
	
	/*form*/
	$("#joinForm")
		.each(function(){
			var $form = $(this);
			var $inputs = $form.find("input.text, textarea");
			
			var class_focus = "focus";
			
			$inputs
				.focus(function(){
					$(this).addClass(class_focus);
				})
				.blur(function(){
					$(this).removeClass(class_focus);
				})
			
			
			//attach
			$form
				.submit(function(){
					
				});
			
		});
	
	
	
	
	
});//END jQuery.ready()
})(jQuery);//END jQuery



/* TypePadJsonCallback
 ***********************************/
var TypePadJsonCallback = function(feed){
	if(!jQuery.feeds) jQuery.feeds = {};
	jQuery.feeds["ivs"] = feed;
};
