// JavaScript Document
$(function(){
     $('a img').hover(function(){
        $(this).attr('src', $(this).attr('src').replace('_off', '_on'));
          }, function(){
             if (!$(this).hasClass('currentPage')) {
             $(this).attr('src', $(this).attr('src').replace('_on', '_off'));
        }
   });
});

$(function(){
     $(".goto_top a").click(function(){
     $('html,body').animate({ scrollTop: $($(this).attr("href")).offset().top }, 'slow','swing');
     return false;
     })
});
$(function(){
     $(".biggerlink").click(function(){
         window.location=$(this).find("a").attr("href");
         return false;
    });
});
$(function() {
   $('#accordion dd').hide();
   $('#accordion dt a').click(function(){
       $('#accordion dd').slideUp();
       $(this).parent().next().slideDown();
       return false;
   });
});



// colorbox

$(document).ready(function(){
			//Examples of how to assign the ColorBox event to elements
			$("a[rel='example1']").colorbox();
			$("a[rel='lightbox']").colorbox({transition:"fade"});
			$("a[rel='example3']").colorbox({transition:"none", width:"75%", height:"75%"});
			$("a[rel='example4']").colorbox({slideshow:true});
			$(".example5").colorbox();
			$(".example6").colorbox({iframe:true, innerWidth:425, innerHeight:344});
			$(".example7").colorbox({width:"80%", height:"80%", iframe:true});
			$(".example8").colorbox({width:"50%", inline:true, href:"#inline_example1"});
			$(".example9").colorbox({
				onOpen:function(){ alert('onOpen: colorbox is about to open'); },
				onLoad:function(){ alert('onLoad: colorbox has started to load the targeted content'); },
				onComplete:function(){ alert('onComplete: colorbox has displayed the loaded content'); },
				onCleanup:function(){ alert('onCleanup: colorbox has begun the close process'); },
				onClosed:function(){ alert('onClosed: colorbox has completely closed'); }
			});
			
			//Example of preserving a JavaScript event for inline calls.
			$("#click").click(function(){ 
				$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
				return false;
			});
		});

// tab

		    $(function(){  
        var handler = $('ul#nav li a');  
        var url = document.URL;  
        var urlId = url.substr(url.lastIndexOf('#'));  
        var urlIdJudgment = urlId.lastIndexOf('#');  
        $('ul#nav').each(function(){  
            $('#tab-box > div:first').show();  
                var imgSrc = $('ul#nav li:first img').attr('src');  
                var imgDot = imgSrc.lastIndexOf('.');  
                var onSrc = imgSrc.substr(0, imgDot) + '_o' + imgSrc.substr(imgDot, 4);  
                $('ul#nav li:first img').attr('src',onSrc).addClass('tab-on');  
        });  

        handler.click(function() {  
  
            var imgSrc = $(this).children('img').attr('src').replace(/_o/g, "");  
            var imgDot = imgSrc.lastIndexOf('.');  
            var onSrc = imgSrc.substr(0, imgDot) + '_o' + imgSrc.substr(imgDot, 4);  
            $(this).children('img').attr('src',onSrc);  
 
            var imgOff = $('ul#nav li img.tab-on').attr('src').replace(/_o/g, "");  
            $('ul#nav li img.tab-on').attr('src',imgOff);  
            $('ul#nav li img').removeClass('tab-on');  
            $(this).children('img').addClass('tab-on');  
 
            var clickAttr = $(this).attr('href');  
            var showAttr = '#' + $('#tab-box > div:visible').attr('id');  
            if(clickAttr !== showAttr) {  
                $('#tab-box > div:visible').hide();  
                var showDiv = '#tab-box div' + clickAttr;  
                $(showDiv).show();  
                return false;  
            }  
            else {  
  
                var imgSrc = $(this).children('img').attr('src').replace(/_o/g, "");  
                var imgDot = imgSrc.lastIndexOf('.');  
                var onSrc = imgSrc.substr(0, imgDot) + '_o' + imgSrc.substr(imgDot, 4);  
                $(this).children('img').attr('src',onSrc);  
                return false;  
            }  
        })  
  
        handler.hover(function() {  
            var classJudgment = $(this).children('img').attr('class');  
            if(classJudgment != 'tab-on') {  
                var imgSrc = $(this).children('img').attr('src');  
                var imgDot = imgSrc.lastIndexOf('.');  
                var onSrc = imgSrc.substr(0, imgDot) + '_o' + imgSrc.substr(imgDot, 4);  
                $(this).children('img').attr('src',onSrc);  
            }  
        }, function() {  
            var classJudgment = $(this).children('img').attr('class');  
            if(classJudgment != 'tab-on') {  
                var imgOff = $(this).children('img').attr('src').replace(/_o/g, "");  
                $(this).children('img').attr('src',imgOff);  
            }  
        });  
    });  

