﻿/*
---------------------------------------------------------
	smartRollover
	*Modify smartRollover.js
	*http://css-happylife.com/log/javascript/000157.shtml
---------------------------------------------------------
*/

(function(onLoad) {
    try {
        window.addEventListener('load', onLoad, false);
    } catch (e) {
        window.attachEvent('onload', onLoad);
    }
})(function() {
    var url = location.pathname
    var directory = url.split("/");
    if(directory[1]==''){
        var currentDirectory = "home";
    }else{
        var currentDirectory = directory[1];
    }
    currentDirectory = currentDirectory + "_";
    var tags = ["img"];
    for( var i=0, len=tags.length; i<len; i++ ) {
        var over = function() { this.src = this.src.replace('_off.', '_on.'); };
        var out  = function() { this.src = this.src.replace('_on.', '_off.'); };
        var el = document.getElementsByTagName(tags[i]);
        for (var j=0, len2=el.length; j<len2; j++) {
            var attr = el[j].getAttribute('src');
            if (!el[j].src.match(/_off\./)&&attr) continue;
            if (el[j].src.match(currentDirectory)){
                el[j].src = el[j].src.replace('_off.', '_on.');
            }else{
                el[j].onmouseover = over;
                el[j].onmouseout  = out;
            }
        }
    }
});
/*

function smartOver() {
    smartRollover('wrapper'); //ロールオーバーを適用させたい箇所のIDを指定
}

function smartRollover(idName) {
    if (document.getElementsByTagName) {
        var images = document.getElementById(idName).getElementsByTagName("img");
        for (var i = 0; i < images.length; i++) {
            if (images[i].getAttribute("src").match(/_off\./)) {
                fileName =  new Array(images[i].getAttribute("src").replace("_off.", "_on."));
                preImages =  new Array();
                for (j = 0; j < fileName.length; j++) {
                    preImages[j] =  new Image();
                    preImages[j].src = fileName[j]; //「_on」の画像をプリロード
                }
                images[i].onmouseover = function () {
                    this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on.")); //マウスオーバーで_off→_on
                }
                images[i].onmouseout = function () {
                    this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off.")); //マウスが離れたら_on→_off
                }
            }
        }
    }
}

if (window.addEventListener) {
    window.addEventListener("load", smartOver, false);
    //実行
}
else if (window.attachEvent) {
    window.attachEvent("onload", smartOver);
}
else {
    window.onload = smartOver;
}
*/

/*
---------------------------------------------------------
検索ボックスにデフォルトで文字を設定し、入力時に文字を消す
---------------------------------------------------------
*/
$(function(){
	var obj = "input.searchText";
	var keyword = "キーワードを入れて下さい";
	
	$(obj).val(keyword).css("color","#CCCCCC");
	$(obj).focus(function(){
		if(this.value == keyword){
			$(this).val("").css("color","#000000");
		}
	});
	$(obj).blur(function(){
		if(this.value == ""){
			$(this).val(keyword).css("color","#CCCCCC");
		}
		if(this.value != keyword){
			$(this).css("color","#000000");
		}
	});
});

/* 詳細検索 */
$(function(){
	var obj = "input.searchKeyword";
	var keywords = new Array("作品名を入力","ミニシリーズを入力","著者/コミックス著者を入力","その他のキーワードを入力");	
	$(obj).each(function(i) {
		$(this).val(keywords[i]).css("color","#CCCCCC");

	});
	$(obj).focus(function(){
		var index = $(obj).index(this);
		if(this.value == keywords[index]){
			$(this).val("").css("color","#000000");
		}
	});
	$(obj).blur(function(){
		var index = $(obj).index(this);
		if(this.value == ""){
			$(this).val(keywords[index]).css("color","#CCCCCC");
		}
		if(this.value != keyword[index]){
			$(this).css("color","#000000");
		}
	});
});


/*
---------------------------------------------------------
検索ボックスにデフォルトで文字を設定し、入力時に文字を消す
---------------------------------------------------------
*/

$(function(){
	$("input.searchText").val("キーワードを入れて下さい")
	   .css("color","#CCCCCC");
	$("input.searchText").focus(function(){
		if(this.value == "キーワードを入れて下さい"){
			$(this).val("").css("color","#000");
		}
	});
	$("input.searchText").blur(function(){
		if(this.value == ""){
			$(this).val("キーワードを入れて下さい")
			     .css("color","#CCCCCC");
		}
		if(this.value != "キーワードを入れて下さい"){
			$(this).css("color","#000000");
		}
	});
});


/*
---------------------------------------------------------
タブの切り替え
---------------------------------------------------------
*/
function dd(obj){
	if(document.getElementById) {
		document.getElementById(obj).style.display=='none'?document.getElementById(obj).style.display='':document.getElementById(obj).style.display='none';
	}
}
function btntop(main_category,obj,obj2,img,img2){
	img_header = "index_";
	img_footer = "_off.gif";

	img_path = "/user_data/packages/default/img/" + main_category + "/";
	
	if(document.getElementById) {
		if (document.getElementById(obj).style.display=='none') {
			document.getElementById(obj).style.display='';
			document.getElementById(obj2).style.display='none';
		} else {
			document.getElementById(obj2).style.display='none';
		}		
		document.getElementById(img).childNodes[0].style.backgroundImage = "url(" + img_path + img_header + img + img_footer + ")";
		document.getElementById(img2).childNodes[0].style.backgroundImage = "url(" + img_path + img_header + img2 + img_footer + ")";
		document.getElementById(img).childNodes[0].className = "active";
		document.getElementById(img2).childNodes[0].className = "";
	}
}
preImages =  new Array();
fileName =  new Array("new05btn_on","new20btn_on","new05btn","new20btn","thisbtn_on","nextbtn_on","thisbtn","nextbtn");
for (i = 0; i < fileName.length; i++) {
	preImages[i] =  new Image();
	preImages[i].src = "index_" + fileName[i] + ".gif"; //「_on」の画像をプリロード
	if(document.getElementById(fileName[i])){
		document.getElementById(fileName[i]).childNodes[0].style.backgroundImage = "url(img_path + index_" + fileName[i]+ ".gif)";
			
	}
	
}


function linkchange() {
	url = document.intlForm.list.options[document.intlForm.list.selectedIndex].value;
	if (url != "-" )  location.href = url;
}

function jump(sel) {
  if (sel.options[sel.selectedIndex].value) {
    location.href = sel.options[sel.selectedIndex].value;
  }
}

/*
---------------------------------------------------------
スムーズスクロール
---------------------------------------------------------
*/
// Easingの追加
jQuery.easing.quart = function (x, t, b, c, d) {
    return -c * ((t=t/d-1)*t*t*t - 1) + b;
};
 
/*-------------------------------------
 ページ読み込み中
-------------------------------------*/
jQuery(document).ready(function(){
 
    //
    // <a href="#***">の場合、スクロール処理を追加
    //
    jQuery('a[href*=#]').click(function() {
        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
            var $target = jQuery(this.hash);
            $target = $target.length && $target || jQuery('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
                jQuery('html,body').animate({ scrollTop: targetOffset }, 1000, 'quart');
                return false;
            }
        }
    });
 
});

jQuery(document).ready(function(){
 
    //
    // <a href="#***">の場合、スクロール処理を追加
    //
    jQuery('area[href*=#]').click(function() {
        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
            var $target = jQuery(this.hash);
            $target = $target.length && $target || jQuery('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
                jQuery('html,body').animate({ scrollTop: targetOffset }, 1000, 'quart');
                return false;
            }
        }
    });
 
});


/*
---------------------------------------------------------
アコーディオン
---------------------------------------------------------
*/

$(document).ready(function() {
	$(".ac dt").hover(function(){
		$(this).css("cursor","pointer"); 
	},function(){
		$(this).css("cursor","default"); 
		});
	$(".ac dd").css("display","none");
	$(".ac dt").click(function(){
		$(this).next().slideToggle("slow");
		});
});

    //
    // FAQページ用アコーディオン
    //
$(document).ready(function() {
	$(".acc h5").hover(function(){
		$(this).css("cursor","pointer"); 
	},function(){
		$(this).css("cursor","default"); 
		});
	$(".acc h6").css("display","none");
	$(".acc h5").click(function(){
		$(this).next().slideToggle("slow");
		});
});

