$(function(){

	/* クロスブラウザなフォーカス */
	$("input[type='text'],textarea").focus(function(){
		$(this).css("background","#ff6600");
		$(this).css("color","#ffffff");
	});
	$("input[type='text'],textarea").blur(function(){
		$(this).css("background","#ffffff");
		$(this).css("color","#000000");
	});
	
	/* クロスブラウザなゼブラテーブル */
	$("table tr:nth-child(even)").css("background","#dbd49e");
	
	/* ウィンク効果 */
	$(".home h1,#header h1 a img, #logo a img, #global-nav a, .gallery #mainContent a img").hover(function(){
		$(this).css("opacity", "0.2");
		$(this).css("filter"," alpha(opacity=20)");
		$(this).fadeTo("slow", "1.0");
		});
		
	/* タブパネル */
		$("ul.tab li:first-child").addClass("selected");
		$("ul.panel li:not(:first-child)").css("display","none");
		$("ul.tab li").click(function(){
			$("ul.tab li").removeClass("selected");
			$(this).addClass("selected");
			$("ul.panel li").css("display","none");
			$("ul.panel li:eq("+$("ul.tab li").index(this)+")").css("display","block");
	});
	
	/* スライドショー */
	$("ul.control li:first-child").addClass("selected");
	$("ul.visual li:not(:first-child)").css("display","none");
	$("ul.control li").click(function(){
		$("ul.control li").removeClass("selected");
		$(this).addClass("selected");
		$("ul.visual li").css("display","none");
		$("ul.visual li:eq("+$("ul.control li").index(this)+")").css("display", "block");
		$("ul.visual li:eq("+$("ul.control li").index(this)+")").css("opacity", "0.2");
		$("ul.visual li:eq("+$("ul.control li").index(this)+")").css("filter", "alpha(opacity=20)");
		$("ul.visual li:eq("+$("ul.control li").index(this)+")").fadeTo("slow", 1.0);
	});
});	
	
/* jQuery Easing */
 
	jQuery.easing.quart = function (x, t, b, c, d) {
	    return -c * ((t=t/d-1)*t*t*t - 1) + b;
	};  

	$(function () {
 	   $('.link_to_top').click(function () {
    	    $('html,body').animate({ scrollTop: 0 }, 500, 'quart');
    	});
	});
	

/* エクスターナル */	

function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
if (anchor.getAttribute("href") &&
anchor.getAttribute("rel") == "external")
anchor.target = "_blank";
 }
 }
 window.onload=externalLinks;
 
 
 /* Vtip */

this.vtip = function() {    
    this.xOffset = 30; // x distance from mouse
    this.yOffset = -10; // y distance from mouse       
    
    $(".vtip").unbind().hover(    
        function(e) {
            this.t = this.title;
            this.title = ''; 
            this.top = (e.pageY + yOffset); this.left = (e.pageX + xOffset);
            
            $('body').append( '<p id="vtip"><img id="vtipArrow" />' + this.t + '</p>' );
                        
            $('p#vtip #vtipArrow').attr("src", 'http://nin-nin.net/common/images/vtip_arrow.png');
            $('p#vtip').css("top", this.top+"px").css("left", this.left+"px").fadeIn("slow");
            
        },
        function() {
            this.title = this.t;
            $("p#vtip").fadeOut("slow").remove();
        }
    ).mousemove(
        function(e) {
            this.top = (e.pageY + yOffset);
            this.left = (e.pageX + xOffset);
                         
            $("p#vtip").css("top", this.top+"px").css("left", this.left+"px");
        }
    );            
    
};

jQuery(document).ready(function($){vtip();}) 


/**
 * Simple rollover 2
 * 
 * Copyright (c) 2009 Kyosuke Nakamura (kyosuke.jp)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 */

$(function(){
	$('.roll').each(function(){
		this.originalSrc = $(this).attr('src');
		this.rolloverSrc = this.originalSrc.replace(/(\.gif|\.jpg|\.png)$/, '_on'+"$1");
		this.mainOriginalSrc = $('#main img').attr('src');
		this.mainRolloverSrc = this.originalSrc.replace(/(\.gif|\.jpg|\.png)$/, '_main.jpg');
		this.rolloverImg = new Image();
		this.rolloverImg.src = this.rolloverSrc;
		this.mainRolloverImg = new Image();
		this.mainRolloverImg.src = this.mainRolloverSrc;
	}).hover(function(){
		$(this).attr('src',this.rolloverSrc);
		$('#main img').attr('src',this.mainRolloverSrc);
	},function(){
		$(this).attr('src',this.originalSrc);
		$('#main img').attr('src',this.mainOriginalSrc);
	});
});
