﻿/*  ================================================================================
擬似クラスをクラスに#article .section.productMod div
================================================================================  */
$(function(){
$("#footer ul#footLink li:last-child").addClass("last-child");
$("#footer ul#footLink li:first-child").addClass("first-child");
$("#aside ul.localNav li:last-child").addClass("last-child");
$("#intro ul li:nth-child(4)").addClass("turn");
$("#intro ul li:nth-child(8)").addClass("turn");
$("#intro ul li:nth-child(12)").addClass("turn");
$("#intro ul li:nth-child(16)").addClass("turn");
$(".section.half .col:nth-child(even)").addClass("even");
$(".section.half .col:nth-child(odd)").addClass("odd");
$("#article ul.pageAnchor li:first-child").addClass("first-child");
$("#article ul.pageAnchor li:last-child").addClass("last-child");
$("#productMain .mainInfo ul.productSwitch li:last-child").addClass("last-child");
$("#productSpec ul li:nth-child(even)").addClass("even");
$("#productSpec ul li:nth-child(odd)").addClass("odd");
$("ul.imageList.quad li:last-child").addClass("last-child");
$("ul.imageList.hex li:last-child").addClass("last-child");
$(".multi.dual .col:nth-child(even)").addClass("even");
$(".multi.dual .col:nth-child(odd)").addClass("odd");
});

/*  ================================================================================
Fade action
================================================================================  */
$(function(){
	$('.pagination li,#imageSlider .container .slides div img,.galleryIndex li,#imgGallery li').hide();
});

var i = 0;
var int=0;

$(window).bind("load", function() {
	var int=setInterval("doFade(i)",50);
});

function doFade() {
	var list = $('.pagination li,#imageSlider .container .slides div img,.galleryIndex li,#imgGallery li').length;
	if (i >= list) {
		clearInterval(int);
	}
	$('.pagination li,#imageSlider .container .slides div img,.galleryIndex li,#imgGallery li').eq(i).fadeIn(500);
		i++;
}

/*  ================================================================================
menu Active
================================================================================  */
$(document).ready(function() {
if(location.pathname != "/") {
$('#globalNav ul li a[href^="/' + location.pathname.split("/")[1] + '"]').addClass('active');
} else $('#globalNav ul li a:eq(0)').addClass('active');
});

$(function(){
	$("#aside ul.localNav li a").each(function(){
	var current = $(this).attr("href");
		if(current == location.pathname){
		$(this).addClass("active");
		}
	});
});

$(function(){
	$("#aside ul.localNavDo li a").each(function(){
	var current = $(this).attr("href");
		if(current == location.pathname){
		$(this).addClass("active");
		}
	});
});


/*  ================================================================================
blank(JQ版）
================================================================================  */
$(document).ready( function () {
    $('.blank').click(function(){
        window.open(this.href, '_blank');
        return false;
    });
});

/*  ================================================================================
wordBreak
================================================================================  */

$(function(){
    var $targetElement = '#feed dl dd a';
    if($.browser.msie) {
        $($targetElement).css('word-break', 'break-all');
    } else {
        $($targetElement).each(function(){
            if(navigator.userAgent.indexOf('Firefox/2') != -1) {
                $(this).html($(this).text().split('').join('<wbr />'));
            } else {
                $(this).html($(this).text().split('').join(String.fromCharCode(8203)));
            }
        });
    }
});


/*  ================================================================================
IE クリックライン消
================================================================================  */
$(function(){$("a").focus(function(){ $(this).blur() })});

/*  ================================================================================
イメージロールオーバー
================================================================================  */
/* フィールター版　*/
$(document).ready(function(){
  $('ul#headNav li a,ul#funcNav li a,#globalNav ul li a,.slide a,ul.pagination li a,#intro ul li a,ul.conversion li a,#bidWorks ul.works li a')
    .load(function(){
        $(this).animate({opacity: 0}, 'slow');
    })
	.mouseover(function(){
        $(this).animate({opacity: 0.5}, 'fast');
    })
    .mouseout(function(){
        $(this).animate({opacity: 1.0}, 'fast');
    });
});

/*imgロールオーバー(opacity animate)*/
$(function(){
	$("#inquiryBtn img,#ranking a img,#topics a img").mouseover(function(){
		$(this).animate({ opacity : 0.7 });
	}).mouseout(function(){
		$(this).animate({ opacity : 1.0 });
	});
});

/*  ================================================================================
ポップアップ
================================================================================  */
window.onload = function (){
	var node_a = document.getElementsByTagName('a');
		for (var i in node_a) {
			if(node_a[i].className == 'popup'){
				node_a[i].onclick = function() {
					return winOpen(this.href, this.rel)
				};
			}
		}
} ;

function winOpen(url, rel) {
	var split = rel.split(',') ;
	window.open(
	url,'popup',
	'width='+ split[0] +',height='+ split[1] +',toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes');

	return false;
};

/*  ================================================================================
スクロールイージング
================================================================================  */
$(document).ready(function(){
  $('a[href*=#]').click(function() {
 if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
 && location.hostname == this.hostname) {
   var $target = $(this.hash);
   $target = $target.length && $target
   || $('[name=' + this.hash.slice(1) +']');
   if ($target.length) {
  var targetOffset = $target.offset().top;
  $('html,body')
  .animate({scrollTop: targetOffset}, 1100);
    return false;
   }
 }
  });
});


/*--------------------------------------------------------------------------*
 *  
 *  heightLine JavaScript Library beta4
 *  
 *  MIT-style license. 
 *  
 *  2007 Kazuma Nishihata 
 *  http://www.webcreativepark.net
 *  
--------------------------------------------------------------------------*/
new function(){
	
	function heightLine(){
	
		this.className="heightLine";
		this.parentClassName="heightLineParent"
		reg = new RegExp(this.className+"-([a-zA-Z0-9-_]+)", "i");
		objCN =new Array();
		var objAll = document.getElementsByTagName ? document.getElementsByTagName("*") : document.all;
		for(var i = 0; i < objAll.length; i++) {
			var eltClass = objAll[i].className.split(/\s+/);
			for(var j = 0; j < eltClass.length; j++) {
				if(eltClass[j] == this.className) {
					if(!objCN["main CN"]) objCN["main CN"] = new Array();
					objCN["main CN"].push(objAll[i]);
					break;
				}else if(eltClass[j] == this.parentClassName){
					if(!objCN["parent CN"]) objCN["parent CN"] = new Array();
					objCN["parent CN"].push(objAll[i]);
					break;
				}else if(eltClass[j].match(reg)){
					var OCN = eltClass[j].match(reg)
					if(!objCN[OCN]) objCN[OCN]=new Array();
					objCN[OCN].push(objAll[i]);
					break;
				}
			}
		}
		
		//check font size
		var e = document.createElement("div");
		var s = document.createTextNode("S");
		e.appendChild(s);
		e.style.visibility="hidden"
		e.style.position="absolute"
		e.style.top="0"
		document.body.appendChild(e);
		var defHeight = e.offsetHeight;
		
		changeBoxSize = function(){
			for(var key in objCN){
				if (objCN.hasOwnProperty(key)) {
					//parent type
					if(key == "parent CN"){
						for(var i=0 ; i<objCN[key].length ; i++){
							var max_height=0;
							var CCN = objCN[key][i].childNodes;
							for(var j=0 ; j<CCN.length ; j++){
								if(CCN[j] && CCN[j].nodeType == 1){
									CCN[j].style.height="auto";
									max_height = max_height>CCN[j].offsetHeight?max_height:CCN[j].offsetHeight;
								}
							}
							for(var j=0 ; j<CCN.length ; j++){
								if(CCN[j].style){
									var stylea = CCN[j].currentStyle || document.defaultView.getComputedStyle(CCN[j], '');
									var newheight = max_height;
									if(stylea.paddingTop)newheight -= stylea.paddingTop.replace("px","");
									if(stylea.paddingBottom)newheight -= stylea.paddingBottom.replace("px","");
									if(stylea.borderTopWidth && stylea.borderTopWidth != "medium")newheight-= stylea.borderTopWidth.replace("px","");
									if(stylea.borderBottomWidth && stylea.borderBottomWidth != "medium")newheight-= stylea.borderBottomWidth.replace("px","");
									CCN[j].style.height =newheight+"px";
								}
							}
						}
					}else{
						var max_height=0;
						for(var i=0 ; i<objCN[key].length ; i++){
							objCN[key][i].style.height="auto";
							max_height = max_height>objCN[key][i].offsetHeight?max_height:objCN[key][i].offsetHeight;
						}
						for(var i=0 ; i<objCN[key].length ; i++){
							if(objCN[key][i].style){
								var stylea = objCN[key][i].currentStyle || document.defaultView.getComputedStyle(objCN[key][i], '');
									var newheight = max_height;
									if(stylea.paddingTop)newheight-= stylea.paddingTop.replace("px","");
									if(stylea.paddingBottom)newheight-= stylea.paddingBottom.replace("px","");
									if(stylea.borderTopWidth && stylea.borderTopWidth != "medium")newheight-= stylea.borderTopWidth.replace("px","")
									if(stylea.borderBottomWidth && stylea.borderBottomWidth != "medium")newheight-= stylea.borderBottomWidth.replace("px","");
									objCN[key][i].style.height =newheight+"px";
							}
						}
					}
				}
			}
		}
		
		checkBoxSize = function(){
			if(defHeight != e.offsetHeight){
				changeBoxSize();
				defHeight= e.offsetHeight;
			}
		}
		changeBoxSize();
		setInterval(checkBoxSize,1000)
		window.onresize=changeBoxSize;
	}
	
	function addEvent(elm,listener,fn){
		try{
			elm.addEventListener(listener,fn,false);
		}catch(e){
			elm.attachEvent("on"+listener,fn);
		}
	}
	addEvent(window,"load",heightLine);
}
