﻿/*------------------------------------- 
Rollover
-------------------------------------*/
function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");

		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_off."))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
				}
			}
		}
	}
}

if(window.addEventListener) {
	window.addEventListener("load", smartRollover, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", smartRollover);
}

/*------------------------------------- 
selectbox
-------------------------------------*/
jQuery(function($){
	$(".simpleBox").jQselectable({
		style: "simple",
		set: "fadeIn",
		out: "fadeOut",
		setDuration: 150,
		outDuration: 150,
		height: 150
	});
	
	var callback = $("#callback").jQselectable({
		style: "simple",
		set: "fadeIn",
		out: "fadeOut",
		height: 150,
		width: 220,
		callback: function(){
			if($(this).val().length>0) window.location = $(this).val();
		}
	});
	var callback = $("#archive").jQselectable({
		style: "simple",
		set: "fadeIn",
		out: "fadeOut",
		height: 150,
		width: 150,
		callback: function(){
			if($(this).val().length>0) window.location = $(this).val();
		}
	});
});


/*------------------------------------- 
 scroll
-------------------------------------*/
jQuery.easing.quart = function (x, t, b, c, d) { 
    return -c * ((t=t/d-1)*t*t*t - 1) + b; 
}; 

jQuery(document).ready(function(){ 
   
    jQuery('a[href*=#]').click(function() { 
        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { 
            var $target = jQuery(this.hash); 
            $target = $target.length && $target || jQuery('[name=' + this.hash.slice(1) +']'); 
            if ($target.length) { 
                var targetOffset = $target.offset().top; 
                jQuery('html,body').animate({ scrollTop: targetOffset }, 600, 'quart'); 
                return false; 
            } 
        } 
    }); 
  
});

/*------------------------------------- 
 print
-------------------------------------*/
$(document).ready(function(){  

    $(".printer").click(function(){  

        $("body").addClass("print");  

        window.print();  

        var timeout = setTimeout(function(){  

            $("body").removeClass("print");  

        }, 1000);  

        return false;  

    });  

}); 

