// JavaScript Document
jQuery.noConflict();
var j$ = jQuery;

j$(function () {

    //ターゲットブランク
    j$("a.blank").click(function () {
        window.open(this.href);
        return false;
    });


    //スムーススクロール
    j$("a[href^=#]").click(function () {
        var hash = this.hash;
        if (!hash || hash == "#") return false;
        j$(j$.browser.safari ? 'body' : 'html').animate({
            scrollTop: j$(hash).offset().top
        }, 500, "swing");
        return false;
    });

    //ロールオーバー
    var preLoad = new Object();
    j$('img.rollOver,input.rollOver').not("[src*='_on.']").each(function () {
        var imgSrc = this.src;
        var fType = imgSrc.substring(imgSrc.lastIndexOf('.'));
        var imgName = imgSrc.substr(0, imgSrc.lastIndexOf('.'));
        var imgOver = imgName + '_on' + fType;
        preLoad[this.src] = new Image();
        preLoad[this.src].src = imgOver;
        j$(this).hover(

        function () {
            this.src = imgOver;
        }, function () {
            this.src = imgSrc;
        });
    });

    //Mac 調整
    if (j$.os.name == 'mac') {
		
		if (j$('#subNavi')[0]) {
            j$('#subNavi').css({
                'font-size': '10px'
            });
        }		
		
        if (j$('#system')[0]) {
            j$('#rightContents #imageBox').css({
                'width': '495px'
            });

            j$('#leftContents table').css({
                'font-size': '9px'
            });

            j$('#blogBody ul#profileList').css({
                'font-size': '9px'
            });

            j$('#schedule').css({
                'font-size': '9px'
            });
        }

        if (j$('#blog')[0]) {
            j$('#blogBody ul#profileList').css({
                'font-size': '9px'
            });

            j$('#schedule').css({
                'font-size': '9px'
            });
        }
		
		if (j$('#copy')[0]){
				j$('#copy').css({
                'font-size': '10px'
            });
		}
    }


    if (j$('#home')[0]) {
        j$('#mainV').coinslider({
            width: 1203,
            height: 437,
            links: false,
            navigation: false
        });

        j$('#menuBar li').click(function () {
            var url = j$(this).find('a').attr('href');
            document.location.href = url;

        });
    }
    j$('#menuBar li').hover(function () {
        j$(this).find('.menuInfo').stop("true", "true").slideDown();
    }, function () {
        j$(this).find('.menuInfo').stop("true", "true").slideUp();

    });

    var z_index;
    var cl
    j$("#clickBoard ul li").hover(

    function () {
        cl = "." + j$(this).attr("class");
        z_index = j$(this).css("z-index");
        j$("#clickBoard ul li").css({
            opacity: 0.4
        });
        j$(this).css({
            "z-index": "99",
            opacity: 1
        });


        j$("#imageBoard ul li").css({
            opacity: 0.1
        });
        j$(cl).css({
            "z-index": "99",
            opacity: 1
        });

    }, function () {
        j$("#clickBoard ul li").css({
            opacity: 1
        });
        j$(this).css({
            "z-index": z_index,
            opacity: 1
        });
        j$("#imageBoard ul li").css({
            opacity: 1
        });
    });




    j$(function () {
        if (!j$("#blog")[0] && !j$("#cast")[0] && !j$("#recruit")[0]) {
            j$("ul.news_body").liScroll();
        }
    });

    if (!j$("#recruit")[0]) {

        j$(".lightBox").fancybox({
            'overlayColor': '#000000',
            'overlayOpacity': 0.5
        });


        var _memberPop = (function () {
            if (j$.os.name == 'win' && j$.browser.name == 'msie' && j$.browser.version == 7) {
                j$('.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': 324,
                    'height': 175
                });
            } else {
                j$('.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': 324,
                    'height': 221
                });
            }
            j$("#memberPop").css({
                "width": "320px"
            });
        })();

        var _regPop = (function () {
            if (j$.os.name == 'win' && j$.browser.name == 'msie' && j$.browser.version == 6) {
                j$('.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 {
                j$('.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
                });
            }
        })();

        var _mypagePop = (function () {
            if (j$.os.name == 'win' && j$.browser.name == 'msie' && j$.browser.version == 6) {
                j$('.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': 645
                });
            } else {
                j$('.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': 645
                });
            }
        })();


    }

    //map
    if (j$("#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表示*/
                j$("#googleMap").gMap({
                    markers: [{
                        latitude: 35.663267,
                        longitude: 139.734134,
                        html: '<span style="font-size:12px;font-weight:bold;color:#454545;">ビゼ六本木</span><br /><span style="font-size:12px;">東京都港区六本木3-8-15<br />瀬里奈ビレッジB2F</span>',
                        popup: false
                    }],
                    zoom: 16
                });
            }


    }
//system 地図表示
/*    j$("#rightContents p span img").toggle(function () {
        j$("#mapBox").css({
            "z-index": "1"
        });
        j$("#imageBox").css({
            "z-index": "0"
        });
    }, function () {
        j$("#mapBox").css({
            "z-index": "0"
        });
        j$("#imageBox").css({
            "z-index": "1"
        });
    });*/



    if (j$("#coupon")[0]) {
        j$("#nomal span").center();
        j$("#member span").center();
    }

    //画面切り替え
    if (j$('#cast')[0]) {
        var imgArray2 = [];
        j$("#imageGallery li.image").each(function (i) {
            i = i + 1
            var img = "#image" + i;
            j$(this).hover(function () {
                j$("#image img").each(function (i) {
                    j$(this).removeClass("selected");
                })
                j$(img).addClass("selected");
                j$(this).children().children().stop(true, false).fadeTo(1, 0.33);
            }, function () {
                j$(this).children().children().stop(true, false).fadeTo(1, 1.0);

            })
        })
        //member画像透過
        j$(".privatePhoto .image").each(function () {
            j$(this).hover(function () {
                j$(this).children().stop(true, false).fadeTo(1, 0.5);
            }, function () {
                j$(this).children().stop(true, false).fadeTo(1, 1.0);
            })
        })

        j$("#imageGallery li.image  a").fancybox({
            'overlayOpacity': 0.7,
            'overlayColor': '#000000',
            'titlePosition': 'inside',
            'speedIn': 600,
            'speedOut': 200,
            'overlayShow': true
        });

        j$("a.lightBox").fancybox({
            'overlayOpacity': 0.7,
            'overlayColor': '#000000',
            'titlePosition': 'inside',
            'speedIn': 600,
            'speedOut': 200,
            'overlayShow': true
        });



        //中央寄せ
        if (j$.os.name == 'win' && j$.browser.name == 'msie' && j$.browser.version == 6 || j$.browser.version == 7) {
            j$("div.image a").center({
                ie: true
            });
//        } else {
//            j$("div.image a").center();
        }

    }

    if (j$("#cast_list")[0]) {
        j$(".scrollbar").css({
            "margin-bottom": "0px"
        });
        j$(".position").css({
            "margin": "0 0 0 0"
        });

        //ie6用
        j$('.ContentFlow .flow .item .label').remove()
    }
    //blog
    if (j$("#blog")[0]) {
        j$('.blogComment').hide();
        j$('.comeentR a').click(function () {
            j$(this).parent().parent().next().toggle('fast');
        });
    }


    //loginPop
    if (j$("#blog")[0]) {
        var _blogWPop = (function () {
            if (j$.os.name == 'win' && j$.browser.name == 'msie' && j$.browser.version == 6) {
                j$('.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 {
                j$('.blogWPop').fancybox({
                    'padding': 0,
                    'titleShow': false,
                    'autoScale': false,
                    'transitionIn': 'none',
                    'transitionOut': 'none',
                    'type': 'iframe',
                    'scrolling': 'no',
                    'enableEscapeButton': true,
                    'width': 490,
                    'height': 340
                });
            }
        })();
    }

    if (j$('#sitepolicy')[0]) {
        j$('#site_policy div#scroll').jScrollPane({
/*
		verticalDragMinHeight: 120,
		verticalDragMaxHeight: 120
		*/
        });
    }

    //recruit画面切り替え
    if (j$('#recruit')[0]) {
        var imgArray = [];

        j$("#shopImageR li img").each(function (i) {
            imgArray.push(j$(this))
            j$(imgArray[i]).hover(function () {
                img = "#shopImageL img." + j$(this).attr("id")
                j$("#shopImageL img:first").removeClass("selected");
                j$(img).addClass("selected");
                //console.log(img)
            }, function () {
                j$(img).removeClass("selected");
                j$("#shopImageL img:first").addClass("selected");
            })
        })
    }

    //PIE	
    //    if (j$.os.name == 'win') {
    //        if (j$.browser.name == 'msie') {
    //            //マップページ
    //            j$('.menuInfo').each(function () {
    //                PIE.attach(this);
    //            });
    //        }
    //    }
});
