/*  ================================================================================
PhotoGallery
================================================================================  */

$(document).ready( function () {
$("#bid-products div.photoGallery li:nth-child(5n)").css("margin-right","0");
});

$(function(){
	$('#bid-products div.photoGallery li').hide();
});

var i = 0;
var int=0;

$(window).bind("load", function() {
	var int=setInterval("doFade(i)",40);
});

function doFade() {
	var list = $('#bid-products div.photoGallery li').length;
	if (i >= list) {
		clearInterval(int);
	}
	$('#bid-products div.photoGallery li').eq(i).fadeIn(250);
		i++;
}


/*  ================================================================================
menu Active
================================================================================  */
$(function($) {
var href = location.href.split('#')[0];
$('#menuCol li a').each(function() {
if (href == this.href)$(this).addClass('active');
});
});

//guild
$(function($) {
var href = location.href.split('#')[0];
$('#header a').each(function() {
if (href == this.href)$(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() })});

/*  ================================================================================
テキスト画像連動hover
================================================================================  */
$(function(){
	$(".prItem dl dt").addClass("autoHover");
	$(".whatsNew dl dd.icon").addClass("autoHover");
	$(".blogNews dl dd.icon").addClass("autoHover");
	imageOverOut();
});
function imageOverOut()
{
	$(".autoHover").mouseover(function(){
		var prt = $(this).parent().get();
		$(prt).addClass("over");
	});
	
	$(".autoHover").mouseout(function(){
		var prt = $(this).parent().get();
		$(prt).removeClass("over");
  });
}

/*  ================================================================================
イメージロールオーバー
================================================================================  */
/* フィールター版　*/
$(document).ready(function(){
  $('#bid-products div.photoGallery li a,.guild #globalNavi a')
    .load(function(){
        $(this).animate({opacity: 0}, 'slow');
    })
	.mouseover(function(){
        $(this).animate({opacity: 0.7}, 'fast');
    })
    .mouseout(function(){
        $(this).animate({opacity: 1.0}, 'fast');
    });
});

/* スワップ版 */ 
/**
 * jQuery.rollover
 *
 * @version    1.0.3
 * @author     Hiroshi Hoaki <rewish.org@gmail.com>
 * @copyright  2010 Hiroshi Hoaki
 * @license    http://rewish.org/license/mit The MIT License
 * @link       http://rewish.org/javascript/jquery_rollover_plugin
 *
 * Usage:
 * jQuery(document).ready(function($) {
 *   // <img>
 *   $('#nav a img').rollover();
 *
 *   // <input type="image">
 *   $('form input:image').rollover();
 *
 *   // set suffix
 *   $('#nav a img').rollover('_over');
 * });
 */
jQuery.fn.rollover = function(suffix) {
	suffix = suffix || '_o';
	var check = new RegExp(suffix + '\\.\\w+$');
	return this.each(function() {
		var img = jQuery(this);
		var src = img.attr('src');
		if (check.test(src)) return;
		var _o = src.replace(/\.\w+/, suffix + '$&');
		jQuery('<img>').attr('src', _o);
		img.hover(
			function() { img.attr('src', _o); },
			function() { img.attr('src', src); }
		);
	});
};
jQuery(function($) {
	// 基本
	//$('#nav a img').rollover();

	// inputもいける
	$('form input:image').rollover();

	// 複数指定も楽々
	//$('#nav a img, form input:image').rollover();

	// 引数で _on の部分を指定できる
	//$('#nav a img').rollover('_over');
});



/*  ================================================================================
ポップアップ
================================================================================  */
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;
};

/* scroll easing */
$(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}, 500);
    return false;
   }
 }
  });
});

/*  ================================================================================
(R)(TM)をマークに置換
================================================================================ container */
$(document).ready(function(){
//$('#container, #container *').contents().each(function() {
$('html, html *').contents().each(function() {
	if (this.nodeType == 3) this.nodeValue = this.nodeValue.replace(/\(R\)/g,'®');
    if (this.nodeType == 3) this.nodeValue = this.nodeValue.replace(/\(TM\)/g,'™');
    if (this.nodeType == 3) this.nodeValue = this.nodeValue.replace(/（R）/g,'®');
    if (this.nodeType == 3) this.nodeValue = this.nodeValue.replace(/（TM）/g,'™');
    if (this.nodeType == 3) this.nodeValue = this.nodeValue.replace(/（Ｒ）/g,'®');
    if (this.nodeType == 3) this.nodeValue = this.nodeValue.replace(/（ＴＭ）/g,'™');
    if (this.nodeType == 3) this.nodeValue = this.nodeValue.replace(/\(r\)/g,'®');
    if (this.nodeType == 3) this.nodeValue = this.nodeValue.replace(/\(tm\)/g,'™');
    if (this.nodeType == 3) this.nodeValue = this.nodeValue.replace(/（ｒ）/g,'®');
    if (this.nodeType == 3) this.nodeValue = this.nodeValue.replace(/（ｔｍ）/g,'™');
    if (this.nodeType == 3) this.nodeValue = this.nodeValue.replace(/\(ｒ\)/g,'®');
    if (this.nodeType == 3) this.nodeValue = this.nodeValue.replace(/\(ｔｍ\)/g,'™');
});
});
/*--------------------------------------------------------------------------*
 *  
 *  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);
}
--------------------------------------------------------------------------*/

/*
CSS Browser Selector v0.3.5 (Feb 05, 2010)
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',o='opera',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);

/* domready function 
function load_lib () {if(typeof Event=="undefined"){Event=new Object()}Event.domReady={add:function(b){if(Event.domReady.loaded){return b()}var e=Event.domReady.observers;if(!e){e=Event.domReady.observers=[]}e[e.length]=b;if(Event.domReady.callback){return}Event.domReady.callback=function(){if(Event.domReady.loaded){return}Event.domReady.loaded=true;if(Event.domReady.timer){clearInterval(Event.domReady.timer);Event.domReady.timer=null}var j=Event.domReady.observers;for(var f=0,h=j.length;f<h;f++){var g=j[f];j[f]=null;g()}Event.domReady.callback=Event.domReady.observers=null};var d=!!(window.attachEvent&&!window.opera);var a=navigator.userAgent.indexOf("AppleWebKit/")>-1;if(document.readyState&&a){Event.domReady.timer=setInterval(function(){var f=document.readyState;if(f=="loaded"||f=="complete"){Event.domReady.callback()}},50)}else{if(document.readyState&&d){var c=(window.location.protocol=="https:")?"://0":"javascript:void(0)";document.write('<script type="text/javascript" defer="defer" src="/common/js/'+c+'" onreadystatechange="if (this.readyState == \'complete\') '+name_space+'.Event.domReady.callback();"><\/script>')}else{if(window.addEventListener){document.addEventListener("DOMContentLoaded",Event.domReady.callback,false);window.addEventListener("load",Event.domReady.callback,false)}else{if(window.attachEvent){window.attachEvent("onload",Event.domReady.callback)}else{var b=window.onload;window.onload=function(){Event.domReady.callback();if(b){b()}}}}}}}};};*/
