// JavaScript Document

<!--
$(function(){
    $("h2#casestudy a").mouseover(function(){
        setOnImg("h2#casestudy a img","-on");
    });    
    $("h2#casestudy a").mouseout(function(){
        setOffImg("h2#casestudy a img","-on");
    });
    $("h2#staffblog a").mouseover(function(){
        setOnImg("h2#staffblog a img","-on");
    });    
    $("h2#staffblog a").mouseout(function(){
        setOffImg("h2#staffblog a img","-on");
    });
    $("h2#shopinfo a").mouseover(function(){
        setOnImg("h2#shopinfo a img","-on");
    });    
    $("h2#shopinfo a").mouseout(function(){
        setOffImg("h2#shopinfo a img","-on");
    });
    $("h2#links a").mouseover(function(){
        setOnImg("h2#links a img","-on");
    });    
    $("h2#links a").mouseout(function(){
        setOffImg("h2#links a img","-on");
    });
    $("h2#case01 a").mouseover(function(){
        setOnImg("h2#case01 a img","-on");
    });    
    $("h2#case01 a").mouseout(function(){
        setOffImg("h2#case01 a img","-on");
    });
    $("h2#case02 a").mouseover(function(){
        setOnImg("h2#case02 a img","-on");
    });    
    $("h2#case02 a").mouseout(function(){
        setOffImg("h2#case02 a img","-on");
    });
    $("h2#case03 a").mouseover(function(){
        setOnImg("h2#case03 a img","-on");
    });    
    $("h2#case03 a").mouseout(function(){
        setOffImg("h2#case03 a img","-on");
    });
    $("h2#case04 a").mouseover(function(){
        setOnImg("h2#case04 a img","-on");
    });    
    $("h2#case04 a").mouseout(function(){
        setOffImg("h2#case04 a img","-on");
    });
    $("h2#case05 a").mouseover(function(){
        setOnImg("h2#case05 a img","-on");
    });    
    $("h2#case05 a").mouseout(function(){
        setOffImg("h2#case05 a img","-on");
    });
    
    
    $("h2#casestudy a").click(function(){
        setSlideToggle("h2#casestudy a img", ".openCase");
    });
    $("h2#staffblog a").click(function(){
        setSlideToggle("h2#staffblog a img", ".openblog");
    });
    $("h2#shopinfo a").click(function(){
        setSlideToggle("h2#shopinfo a img", ".openinfo");
    });
    $("h2#links a").click(function(){
        setSlideToggle("h2#links a img", ".openlinks");
    });
    $("h2#case01 a").click(function(){
        setSlideToggle("h2#case01 a img", ".opencase01");
    });
    $("h2#case02 a").click(function(){
        setSlideToggle("h2#case02 a img", ".opencase02");
    });
    $("h2#case03 a").click(function(){
        setSlideToggle("h2#case03 a img", ".opencase03");
    });
    $("h2#case04 a").click(function(){
        setSlideToggle("h2#case04 a img", ".opencase04");
    });
    $("h2#case05 a").click(function(){
        setSlideToggle("h2#case05 a img", ".opencase05");
    });
       
    

    function setSlideToggle(clickTarget, target) {
        $(target).slideToggle("200",function() {
        });

        var src = $(clickTarget).attr("src");
        if( src.match("open") ){
            $(clickTarget).attr("src", src.replace("open","close"));
        }else{
            $(clickTarget).attr("src", src.replace("close","open"));
        }    
    }
    function setOnImg(target, postfix){
       postfix = postfix || '-on';
       var img = $(target);
       var src = img.attr('src');
       var src_change = [
           src.substr(0, src.lastIndexOf('.')),
           src.substring(src.lastIndexOf('.'))
       ].join(postfix);
       $(img).attr('src', src_change);
    }
    function setOffImg(target, postfix){
       postfix = postfix || '-on';
       var img = $(target);
       var src = img.attr('src');
       img.attr("src", src.replace(postfix,""));
    }
    
});
// -->

