/*  ================================================================================
================================================================================  */
$(document).ready(function(){

$('#brum ul li:last').addClass('end');

var str = $("body").attr("id");

if (str=='home'){
$('#home #cont #rightCont div.information dl dd:last').addClass('end');
};

if(str=='styling'){
imagePreview();
$('#styling #cont ul').find('li:last').addClass('end').end()
.find('a').mouseover(function(){
$(this).animate({opacity:0.01},300).end();
}).mouseout(function(){
$(this).animate({opacity: 1.0},300).end();
});
$('#preview').mouseover(function(){
$(this).remove().end();
});
};

if(str=='styling_detail'){
	if($('#styling_detail ul.imgs li').size()>1){
	$("#styling_detail #loading").css('display','none').fadeIn(300);
	$('#styling_detail ul.imgs li:gt(0)').hide();
	$('#styling_detail ul.imgs li:first-child').css('display','block');
	timer = setInterval(function(){$('#styling_detail ul.imgs li:first-child').fadeOut(500).next('li').fadeIn(500).end().appendTo('#styling_detail ul.imgs');},4000); 
}else{
	$('#styling_detail ul.imgs li:first-child').css('display','block');
}
$('a.close,a#sb-nav-close').click(function(){clearInterval(timer);});
$('li.next a').click(function(){$("#styling_detail #loading").fadeOut(300); clearInterval(timer);});
$('li.prev a').click(function(){$("#styling_detail #loading").fadeOut(300); clearInterval(timer);});
};

if(str=='pickup'){
$("#pickup #cont ul.indexList li:nth-child(5n)").addClass('turn');
$('#pickup #cont ul.indexList li').append('<span class="mask">&nbsp;</span><span class="mask1">&nbsp;</span>');
$('#pickup #cont ul.indexList li span.mask').mouseover(function(){$(this).parent().find('img').animate({opacity:0.8},'fast');}).mouseout(function(){$(this).parent().find('img').animate({opacity: 1.0},'fast');});
$('#pickup #cont ul.indexList li span.mask').mouseover(function(){$(this).parent().find('span.mask1').animate({'top':'0px','left':'0px','height':'166px','width':'166px'},200);}).mouseout(function(){$(this).parent().find('span.mask1').animate({'top':'-8px','left':'-8px','height':'182px','width':'182px'},200);});
//$('#pickup #cont ul.indexList li span.mask').mouseover(function(){$(this).parent().find('span.mask1').addClass('bgLoad');}).mouseout(function(){$(this).parent().find('span.mask1').removeClass('bgLoad');});
//$('#pickup #cont ul.indexList li span.mask').mouseover(function(){$(this).parent().append('<span class="mask1"></span>');}).mouseout(function(){$(this).parent().find('span.mask1').remove();});
$('#pickup #cont ul.indexList li span.mask').click(function(){var href = $(this).parent().find('a').attr('href'); location.href = href;});
};

if(str=='pickupDetail'){
$('#pickupDetail #cont ul li:last').addClass('end');
$('#pickupDetail #cont #rightCol ul.thumbs li a').mouseover(function(){$(this).animate({opacity:0.8},'fast');}).mouseout(function(){$(this).animate({opacity: 1.0},'fast');});
var speed=800;
var main ="#pickupDetail #cont #rightCol ul.mainImg li";
var thumb ="#pickupDetail #cont #rightCol ul.thumbs li";
function firstChk(){
$(main+":first").addClass('now').fadeIn(speed);
$(main+" a").each (function(i){i=i+1;$(this).attr("rel",i);});
$(thumb+" a").each(function(i){i=i+1;$(this).attr("rel",i);});
};
function activeChk(){var now = $(main+".now").find("a").attr('rel');
$(thumb+" a").each(function(){
var rel = $(this).attr('rel');
if(rel == now){$(this).parent().append("<span></span>");
}
});
};
function thumbClick(){
$(thumb+' a').click(function(){
var tr = $(this).attr('rel');
var tn = $(main+".now").find("a").attr('rel');
if(tr!==tn){
$(main+".now").fadeOut(speed).removeClass('now');
$(main+" a").each(function(){
var rel = $(this).attr('rel');
if(rel == tr){
$(this).parent().fadeIn(speed).addClass('now');
};
});
$(thumb+" a img").each(function(){
$(this).parent().parent().find("span").remove();
});
$(thumb+" a").each(function(){
var rel = $(this).attr('rel');
if(rel == tr){
$(this).parent().append("<span></span>");
};
});
return false;
};
});
};
$(window).load(function(){
firstChk();activeChk();thumbClick();facebook();
});
};

if ($.browser.msie && $.browser.version == 6.0){
setInterval("ie6_mv()",100);
};
//END
});

function ie6_mv(){
var winW = $(window).width();
if(980 > winW){
$('#mv').css('width',980);
$('#footer').css('width',980);
}
};


/*  ================================================================================
FaceBook
================================================================================  */
function facebook(){
var url = encodeURIComponent(location.href);
var width =250;
var height =21;
var tag = '<iframe src="http://www.facebook.com/plugins/like.php?href=' + url + '&amp;layout=button_count&amp;show_faces=true&amp;width=' + width + '&amp;action=like&amp;font&amp;colorscheme=light&amp;height=' + height + '" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:' + width + 'px; height:' + height + 'px;" allowTransparency="true"></iframe>';
$('#facebook').append(tag);
};

/*  ================================================================================
Tooltip
================================================================================  */
this.imagePreview = function(){	
xOffset = 30;
yOffset = 10;
$("#styling #cont ul li").mouseover(function(e){
$("body").append("<p id='preview'><img src='images/tooltip.gif' alt='Visual Detail' /></p>");
$("#preview").css("top",(e.pageY - xOffset)).css("left",(e.pageX + yOffset)).show();
}).mouseout(function(){$("#preview").hide().remove();});	
$("#styling #cont ul li a").mousemove(function(e){
$("#preview").css("top",(e.pageY - xOffset)).css("left",(e.pageX + yOffset));
});	

/* 相対
var x = e.pageX - $('#hoge').position().left;
var y = e.pageY - $('#hoge').position().top;
*/
};

/*  ================================================================================
・blank
・IE クリックライン消
・イメージロールオーバー　テキスト＆背景画像用
================================================================================  */
$(document).ready(function () {
$('.blank').click(function(){window.open(this.href, '_blank');return false;});
$("a").focus(function(){$(this).blur();});
$('a img.rollover,a.rollover').mouseover(function(){$(this).animate({opacity: 0.8}, 'fast');}).mouseout(function(){$(this).animate({opacity: 1.0}, 'fast');});
});

/*  ================================================================================
イメージロールオーバー スワップ
================================================================================  */
var preLoadImg = new Object();
function initRollOvers(){
$("a img.imgRollover,#footer ul li a img").each(function(){
var imgSrc = this.src;
var sep = imgSrc.lastIndexOf('.');
var onSrc = imgSrc.substr(0, sep) + '_o' + imgSrc.substr(sep, 4);
preLoadImg[imgSrc] = new Image();
preLoadImg[imgSrc].src = onSrc;
$(this).hover(
function() { this.src = onSrc; },
function() { this.src = imgSrc; }
);
});
}
$(function(){
initRollOvers();
});


/*-----------------------------------------------------
スムーズスクロール
-----------------------------------------------------*/
jQuery.fn.extend({
scrollTo : function(speed, easing) {
if(!$(this)[0].hash || $(this)[0].hash == "#") {
return false;
}
return this.each(function() {
var targetOffset = $($(this)[0].hash).offset().top;
$('html,body').animate({scrollTop: targetOffset}, speed, easing);
});
}
});

$(document).ready(function(){
$('#pageTop a').click(function() {
$(this).scrollTo(1000);
return false;
});
});

/*  ================================================================================
ポップアップ
================================================================================  */
(function($) {
$.fn.openwin = function(settings) {
settings = jQuery.extend({
option		: {
width		: false,
height		: false,
top			: false,
left		: false,
menubar		: "no",
toolbar		: "no",
location	: "no",
status		: "no",
resizable	: "no",
scrollbars	: "no",
directories	: "no",
titlebar	: "yes",
fullscreen	: "no"
},
target		: "_blank",
blur		: false,
focus		: false
}, settings);

this.click(function() {
var options = [];
if($(this).attr("rel")) {
var rel = $(this).attr("rel").split(",");
var reloption = {};
for(var i in rel) {
var a = rel[i].split("=");
reloption[a[0]] = a[1];
}
}
for(var k in settings.option) {
var v = settings.option[k];
if(reloption) {
if(reloption[k]) {
v = reloption[k];
}
}
if(v != false) {
options.push(k + "=" + v);
}
}
var target = settings.target;
if(reloption) {
if(reloption["target"]) {
target = reloption["target"];
}
}
var win = window.open($(this).attr("href"), target, options.join(","));
if(settings.blur == true) {
win.blur();
}
if(settings.focus == true) {
win.focus();
}
return false;
});
}
})(jQuery);

$(document).ready(function() {
$('a.shop_popup').openwin({option:{width:673,height:500,scrollbars:"yes",location:"no",directories:"no"},target:"popup",focus:true});
/*if ($.browser.msie ){
$('a.shop_popup').openwin({option:{width:673,height:500,scrollbars:"yes",location:"no",directories:"no"},target:"popup",focus:true});
}else{
$('a.shop_popup').openwin({option:{width:673,height:500,scrollbars:"yes",location:"no",directories:"no"},target:"popup",focus:true});
};
*/
});


/*
CSS Browser Selector v0.4.0 (Nov 02, 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',m='mobile',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.6')?g+' ff3 ff3_6':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('blackberry')?m+' blackberry':is('android')?m+' android':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?m+' j2me':is('iphone')?m+' iphone':is('ipod')?m+' ipod':is('ipad')?m+' ipad':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win'+(is('windows nt 6.0')?' vista':''):is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);
*/

/*
Google Map
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
$(function(){
$('#boxID').gmap('43.0550852','141.3412251');
});
(function($){
  $.fn.gmap = function(lat, lng) {
    var mapdiv = $(this).get(0);
    var myOptions = {
      zoom: 16,
      center: new google.maps.LatLng(lat,lng),
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      scaleControl: true,
      mapTypeControl: true
    };
    var map = new google.maps.Map(mapdiv, myOptions);
    var marker = new google.maps.Marker({
      position: myOptions.center,
      map: map
    });
  };
})(jQuery);
*/

/*

画像順次表示

$(function(){
//ページ上の画像をすべて隠す
$('#cont img').hide();
});
// 初期化
var i = 0;
// IEは固定
var int=0;
$(window).bind("load", function() {
// ページが完全に読み込まれたときにロードイベント発生
// 画像を0.5秒間隔でフェードイン表示
var int=setInterval("doThis(i)",100);
});
function doThis() {
// 画像数
var imgs = $('#cont img').length;
if (i >= imgs) {
// 最後の画像でタイマークリア
clearInterval(int);
}
// 0.5秒間隔で隠していた画像をフェードイン表示
$('#cont img:hidden').eq(0).fadeIn(100);
i++;
}
*/


