// JavaScript Document
$(function () {

    //ターゲットブランク
    $("a.blank").click(function () {
        window.open(this.href);
        return false;
    });


    //スムーススクロール
    $("a[href^=#]").click(function () {
        var hash = this.hash;
        if (!hash || hash == "#") return false;
        $($.browser.safari ? 'body' : 'html').animate({
            scrollTop: $(hash).offset().top
        }, 500, "swing");
        return false;
    });

//Mac 調整
    if ($.os.name == 'mac') {
		
		if($('#domainPop')[0]){
			$('#domainPop a').css({
                'font-size': '10px'
            });
			
		}
		
		
        if ($('#system')[0]) {
            $('#rightContents #imageBox').css({
                'width': '514px'
            });

            $('#leftContents table').css({
                'font-size': '9px'
            });

            $('#leftContents p').css({
                'left': '-300px'
            });

            $('#priceList table').css({
                'font-size': '9px'
            });

            $('#schedule').css({
                'font-size': '9px'
            });
        }

        if ($('#blog')[0]) {
            $('#blogBody ul#profileList').css({
                'font-size': '9px'
            });

            $('#schedule').css({
                'font-size': '9px'
            });
			$('.blogFooter').css({
                'font-size': '9px'
            });
			
			
        }
		$('#footer').css({"font-size":"10px"})
    }

    if ($('#salon')[0]) {
        var z = 0;
        var inAnimation = false;

        $('#pictures img').each(function () {
            z++;
            $(this).css('z-index', z);
        });

        function swapFirstLast(isFirst) {
            if (inAnimation) return false;
            else inAnimation = true;

            var processZindex, direction, newZindex, inDeCrease;

            if (isFirst) {
                processZindex = z;
                direction = '-';
                newZindex = 1;
                inDeCrease = 1;
            } else {
                processZindex = 1;
                direction = '';
                newZindex = z;
                inDeCrease = -1;
            }

            $('#pictures img').each(function () {
                if ($(this).css('z-index') == processZindex) {
                    $(this).animate({
                        'top': direction + $(this).height() + 'px',
                        'opacity': '0'
                    }, 'slow', function () {
                        $(this).css('z-index', newZindex).animate({
                            'top': '0'
                        }, 'slow', function () {
                            inAnimation = false;
                        }).animate({
                            'opacity': '1'
                        });
                    });
                } else {
                    $(this).animate({
                        'top': '0'
                    }, 'slow', function () {
                        $(this).css('z-index', parseInt($(this).css('z-index')) + inDeCrease);
                    });
                }
            });
            return false;
        }
        $('#next a').click(function () {
            return swapFirstLast(false);
        });
        $('#prev a').click(function () {
            return swapFirstLast(true);
        });
    }

    if ($('#sitepolicy')[0]) {
        $('#site_policy div#scroll').jScrollPane({
/*
		verticalDragMinHeight: 120,
		verticalDragMaxHeight: 120
		*/
        });
    }

    //blog
    if ($("#blog")[0]) {
        $('.blogComment').hide();
        $('.comeentR a').click(function () {
            $(this).parent().parent().next().toggle('fast');
        });
    }


    $(function () {
        if (!$("#blog")[0] && $("#news_box")[0]) {
            $("ul.news_body").liScroll();
        }
    });

    //map
    if ($("#system")[0]) {

        var check_flame_set = function () {
                if (!parent.document.getElementById("TB_window")) {
                    clearInterval(timerID);
                    show_map();
                } else if (parent.document.getElementById("TB_window").style.display == "block") {
                    clearInterval(timerID);
                    show_map();
                }
            }
        var timerID = setInterval(check_flame_set, 500);

        var show_map = function () { /*google API ver2使用 MAP表示*/
                $("#googleMap").gMap({
                    markers: [{
                        latitude: 35.663506,
                        longitude: 139.734228,
                        html: '<span style="font-size:12px;font-weight:bold;color:#454545;">ドレス立川</span><br /><span style="font-size:12px;">東京都港区六本木3-8-18<br />瀬里奈ビレッジB2F</span>',
                        popup: false
                    }],
                    zoom: 16
                });
            }


    }

    if (!$('#recruit')[0]) {
        $(".lightBox").fancybox({
            'overlayColor': '#000000',
            'overlayOpacity': 0.5
        });

        var _memberPop = (function () {
            if ($.os.name == 'win' && $.browser.name == 'msie' && $.browser.version == 6) {
                $('.memberPop').fancybox({
                    'padding': 0,
                    'titleShow': false,
                    'autoScale': false,
                    'transitionIn': 'none',
                    'transitionOut': 'none',
                    'type': 'iframe',
                    'centerOnScroll': true,
                    'scrolling': 'no',
                    'overlayShow': true,
                    'overlayOpacity': 0.5,
                    'overlayColor': '#000',
                    'enableEscapeButton': true,
                    'width': 320,
                    'height': 221
                });
            } else {
                $('.memberPop').fancybox({
                    'padding': 0,
                    'titleShow': false,
                    'autoScale': false,
                    'transitionIn': 'none',
                    'transitionOut': 'none',
                    'type': 'iframe',
                    'scrolling': 'no',
                    'overlayShow': true,
                    'overlayOpacity': 0.5,
                    'overlayColor': '#000',
                    'enableEscapeButton': true,
                    'width': 320,
                    'height': 221
                });
            }
            $("#memberPop").css({
                "width": "320px"
            });
        })();

        var _regPop = (function () {
            if ($.os.name == 'win' && $.browser.name == 'msie' && $.browser.version == 6) {
                $('.regPop').fancybox({
                    'padding': 0,
                    'titleShow': false,
                    'autoScale': false,
                    'transitionIn': 'none',
                    'transitionOut': 'none',
                    'type': 'iframe',
                    'centerOnScroll': true,
                    'scrolling': 'no',
                    'overlayShow': true,
                    'overlayOpacity': 0.5,
                    'overlayColor': '#000',
                    'enableEscapeButton': true,
                    'width': 320,
                    'height': 170
                });
            } else {
                $('.regPop').fancybox({
                    'padding': 0,
                    'titleShow': false,
                    'autoScale': false,
                    'transitionIn': 'none',
                    'transitionOut': 'none',
                    'type': 'iframe',
                    'scrolling': 'no',
                    'overlayShow': true,
                    'overlayOpacity': 0.5,
                    'overlayColor': '#000',
                    'enableEscapeButton': true,
                    'width': 320,
                    'height': 170
                });
            }
            $("#regPop").css({
                "width": "320px"
            });
        })();


        var _mypagePop = (function () {
            if ($.os.name == 'win' && $.browser.name == 'msie' && $.browser.version == 6) {
                $('.mypagePop').fancybox({
                    'padding': 0,
                    'titleShow': false,
                    'autoScale': false,
                    'transitionIn': 'none',
                    'transitionOut': 'none',
                    'type': 'iframe',
                    'centerOnScroll': true,
                    'scrolling': 'no',
                    'overlayShow': true,
                    'overlayOpacity': 0.5,
                    'overlayColor': '#000',
                    'enableEscapeButton': true,
                    'width': 541,
                    'height': 665
                });
            } else {
                $('.mypagePop').fancybox({
                    'padding': 0,
                    'titleShow': false,
                    'autoScale': false,
                    'transitionIn': 'none',
                    'transitionOut': 'none',
                    'type': 'iframe',
                    'scrolling': 'no',
                    'overlayShow': true,
                    'overlayOpacity': 0.5,
                    'overlayColor': '#000',
                    'enableEscapeButton': true,
                    'width': 541,
                    'height': 665
                });
            }
        })();
    }
    if ($("#blog")[0]) {
        var _blogWPop = (function () {
            if ($.os.name == 'win' && $.browser.name == 'msie' && $.browser.version == 6) {
                $('.blogWPop').fancybox({
                    'padding': 0,
                    'titleShow': false,
                    'autoScale': false,
                    'transitionIn': 'none',
                    'transitionOut': 'none',
                    'type': 'iframe',
                    'centerOnScroll': true,
                    'scrolling': 'no',
                    'overlayOpacity': 0.5,
                    'enableEscapeButton': true,
                    'width': 490,
                    'height': 340
                });
            } else {
                $('.blogWPop').fancybox({
                    'padding': 0,
                    'titleShow': false,
                    'autoScale': false,
                    'transitionIn': 'none',
                    'transitionOut': 'none',
                    'type': 'iframe',
                    'scrolling': 'no',
                    'enableEscapeButton': true,
                    'width': 490,
                    'height': 340
                });
            }
        })();
    }
    //画面切り替え
    if ($('#profileBox')[0]) {
        var imgArray2 = [];
        $("#imageGallery li.image").each(function (i) {
            i = i + 1
            var img = "#image" + i;
            $(this).hover(function () {
                $("#image img").each(function (i) {
                    $(this).removeClass("selected");
                })
                $(img).addClass("selected");
                $(this).children().children().stop(true, false).fadeTo(1, 0.33);
            }, function () {
                $(this).children().children().stop(true, false).fadeTo(1, 1.0);

            })
        })
        //member画像透過
        $(".privatePhoto .image").each(function () {
            $(this).hover(function () {
                $(this).children().stop(true, false).fadeTo(1, 0.5);
            }, function () {
                $(this).children().stop(true, false).fadeTo(1, 1.0);
            })
        })

        $("#imageGallery li.image  a").fancybox({
            'overlayOpacity': 0.7,
            'overlayColor': '#000000',
            'titlePosition': 'inside',
            'speedIn': 600,
            'speedOut': 200,
            'overlayShow': true
        });

        $("a.lightBox").fancybox({
            'overlayOpacity': 0.7,
            'overlayColor': '#000000',
            'titlePosition': 'inside',
            'speedIn': 600,
            'speedOut': 200,
            'overlayShow': true
        });



        //中央寄せ
        if ($.os.name == 'win' && $.browser.name == 'msie' && $.browser.version == 6 || $.browser.version == 7) {
            $("div.image a").center({
                ie: true
            });
//        } else {
//            $("div.image a").center();
        }

    }
	if ($("#coupon")[0]) {
		if ($.os.name == 'win' && $.browser.name == 'msie' && $.browser.version == 6 || $.browser.version == 7) {
        	$("#nomal span").center({
                ie: true
            });
        	$("#member span").center({
                ie: true
            });
    	}else{
			$("#nomal span").center();
        	$("#member span").center();
		}
	}

    //recruit画面切り替え
    if ($('#recruit')[0]) {
        var imgArray = [];

        $("#shopImageR li img").each(function (i) {
            imgArray.push($(this))
            $(imgArray[i]).hover(function () {
                img = "#shopImageL img." + $(this).attr("id")
                $("#shopImageL img:first").removeClass("selected");
                $(img).addClass("selected");
                //console.log(img)
            }, function () {
                $(img).removeClass("selected");
                $("#shopImageL img:first").addClass("selected");
            })
        })
    }
  if($(".showCaption")[0]){
	$(".scrollbar").css({"margin-bottom":"0px"});
	$(".position").css({"margin":"0 0 0 0"});
	
	//ie6用
	$('.ContentFlow .flow .item .label').remove()
  }	
  
   //ロールオーバー（フェード）

  $(".fade").each(function () {
	    $(this).hover(function () {
			$(this).stop(true, false).fadeTo(100, 0.5);
		}, function () {
			$(this).stop(true, false).fadeTo(100, 1.0);
  })

});

});
