$(function(){

    // rollover
    
    var img_cache = new Object();
    $("#header .Contact dd.Last img,#address .Contact .Last img,#sub .Contact .Last img,#mainContact dd.Last a img,#main.interview .Interview li img").not('[src*="_o"]').each(function(){
        var imgsrc = this.src;
        var imgsrc_non_filetype = this.src.lastIndexOf('.');
        var imgsrc_over = this.src.substr(0,imgsrc_non_filetype)+'_o'+this.src.substr(imgsrc_non_filetype,4);
        img_cache[this.src] = new Image();
        img_cache[this.src].src = imgsrc_over;
        $(this).hover(
            function (){
                this.src = imgsrc_over;
            },
            function (){
                this.src = imgsrc;
            }
        );
    });
    


    // globalNav addClass Current
    $('#globalNav li a').each(function(){
        var url = document.URL.split('/');
        // demo:4; real:3;
        if(url[4]){
            $('#globalNav li [href*='+url[4]+']').parent().addClass("Current");
        }
    });

    // external link
    $('a[href^="http"]').not('a[href^="http://localhost/"],a[href^="http://www.shanon.co.jp/"],a[href="https://shanon.smartseminar.jp/public/"],a[href^="https://shanon.smartseminar.jp/public/application/add/"]').click(function(){
        window.open(this.href, '');
        return false;
    });
    
    $('a[href^="http"]').not('a[href^="http://localhost/"],a[href^="http://www.shanon.co.jp/"],a[href="https://shanon.smartseminar.jp/public/"],a[href^="https://shanon.smartseminar.jp/public/application/add/"]').addClass("ExLink");


    $("#content a.ExLink").not("a:has(img)").wrapInner("<span></span>").append('<img src="/demo/shared/img/icn_exlink.png" alt="" />');
    
    // page scroll
    jQuery.easing.quart = function(x, t, b, c, d){
        return -c * ((t=t/d-1)*t*t*t - 1) + b;
    };
    
    $('#return a').click(function(){
        $('html,body').animate({
            scrollTop:0
        }, 500, 'quart');
        return false;
    });



    // pdf icn add
    $("ul.Link li.Pdf a").append('<img src="/shared/img/icn_pdf.gif" alt="PDF" />');


    // page

    var pageURL = document.URL;
    var urlArray = pageURL.split("/", 10);
    urlArray = urlArray.reverse();
    var fileNameArray = urlArray[0].split(".", 10);
    if (fileNameArray == ""){
        $("#subNav dd ul li a."+urlArray[1]).addClass("Current");
    } else {
        $("#subNav dd ul ul li."+fileNameArray[0]).addClass("Current");
    }

});

    