$j = jQuery.noConflict();

$j(document).ready(function()
{
    // Flash button text
    $j("#hos-flash a").text(" ");
    $j("#hos-flash-jp a").text(" ");

    // Brach Search Text
    $j('.hint-text').focus(function(srcc)
    {
        if($j(this).val() == $j(this)[0].title)
        {
            $j(this).removeClass("hint-text-active");
            $j(this).val("");
        }
    });
    $j('.hint-text').blur(function()
    {
        if($j(this).val() == "")
        {
            $j(this).addClass("hint-text-active");
            $j(this).val($j(this)[0].title);
        }
    });
    $j('.hint-text').blur();

    if($j.fn.fancybox)
    {
        // Menu Page
        $j("a.mc-blocks").fancybox({
        'cyclic' : true,
        'titleShow' : false,
        'width' : 500
        });
        
        // Branch Information Page
        $j("a.google-map-btn").fancybox({
        'cyclic': true
        });
        
        $j("a.bibl-img-add").fancybox({
            
        });
        
        // OOTOYA Secret Flash
//        $j("#hos-flash a").fancybox({
//            'width' : 800,
//            'height' : 500
//            
//        });
        
        $j("#hos-flash a").fancybox({
            'width' : 600,
            'height' : 400
            
        });
        $j("#hos-flash-jp a").fancybox({
            'width' : 600,
            'height' : 400
            
        });
        
        // News and Promotions Page
        $j(".npcb-img a").fancybox({
            
        });
    }
    
    if($j.fn.mobilyslider)
    {
        // Home Page (Main Slideshow)
        $j('.htc-slides').mobilyslider({
            autoplay: true,
            autoplaySpeed: 10000,
            arrows: false,
            transition: 'fade',
            animationSpeed: 1000,
            pauseOnHover: true
        });

        // Home Page (New Release)
        $j('.hnr-slides').mobilyslider({
            autoPlay: false,        
            transition: 'vertical',
            arrows: false,
            animationSpeed: 400
        });

        // News & Promotions
        $j('.nb-slides').mobilyslider({
            autoplay: true,
            autoplaySpeed: 10000,
            arrows: false,
            transition: 'fade'
        });
    }
    
    // Branch Page - Quick Search
    $j('input#search-branch').quicksearch('.bi-blocks');
    
    //$j('.mcb-img img').hide().fadeIn(800);
    
    
    $j("a.google-map-btn").hover(function(){
        $j(this).stop().fadeTo(300, 1);
        return false;
    }, function(){
        $j(this).stop().fadeTo(300, 0.5);
        return false;
    });
    
    $j('#hp-slideshow .sliderBullets').fadeTo(100, 0.3);
    $j("#hp-slideshow .slider").hover(function(){
        $j('#hp-slideshow .sliderBullets').fadeTo(300, 1);
        return false;
    }, function(){
        $j('#hp-slideshow .sliderBullets').fadeTo(300, 0.3);
        return false;
    });
    
    $j('#npf-banner .sliderBullets').fadeTo(100, 0.3);
    $j('#npf-banner').hover(function(){
        $j('#npf-banner .sliderBullets').fadeTo(300, 1);
        return false;
    }, function(){
        $j('#npf-banner .sliderBullets').fadeTo(300, 0.3);
        return false;
    });
    
    // Back To Top Button
    $j('a.back-to-top-btn').click(function(){
        $j('html, body').animate({scrollTop: '0px'}, 800);
        return false;
    });
    
    
    // Download Job Application Form
    $j('#cpt-download-job-app-form a').text(" ");
    
    
    // Top 5 Menu    
    $j('div.ht5mi-slides:eq(0)').show();
    $j('div.ht5mt-blocks:nth-child(1)').addClass('ht5mt-block-current');
    
    for(i=1; i < 6; i++)
    {
        $j('div.ht5mt-blocks:nth-child('+i+')').click(function(){
            var sIndex = $j('.ht5mt-blocks').index(this);
            $j('div.ht5mi-slides').hide();
            $j('div.ht5mt-blocks').removeClass('ht5mt-block-current');
            $j('div.ht5mi-slides:eq('+sIndex+')').show();
            $j(this).addClass('ht5mt-block-current');
            
        });
    }
    
    // Survey Form
    $j('.quiz-5 input').click(function(){
        var newsletter_value = $j(this).val();
        
        console.log(newsletter_value);
        
        if(newsletter_value == 'ต้องการ' || newsletter_value == '欲しい')
        {
            $j('.quiz-block .newsletter').fadeIn().css('display', 'block');
        }
        else
        {
            $j('.quiz-block .newsletter').fadeOut();
        }
            
    });
    
    
    
    
    
    
    
});

