/**
*
* Okidai calass
* jquery , jquery.pingfix
*
**/

//constructor
var Okidai = function() {};


//OkidaiClass
Okidai.prototype = {

	
	isIE6:($.browser.msie && $.browser.version < 7)? true : false,
	
	isMacOpera:(navigator.userAgent.indexOf("Mac")!=-1 && $.browser.opera)? true : false,
	
	init:function(){
		this.pngfix();
		imgs = $("#header ul img").not(".not");
		this.preloadImages(imgs);
		this.setOverAction(imgs);
		this.setScroll();
	},
	
    pngfix:function(){
   		$(".png").pngfix();
    },
	
   	preloadImages:function(imgs){
		$(imgs).each(function(){
			var preload = new Image;
			var img = $("img",this);
			preload.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1_over$2");
		})
	},
	
	setOverAction:function(imgs){
		$(imgs)
			.bind("mouseover",function(){
				this.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1_over$2");
			})
			.bind("mouseout",function(){
				this.src = this.src.replace(/^(.+)_over(\.[a-z]+)$/, "$1$2");
			})
			.pngfix({mouseover:true,overimagePath:"_over"});
	},
	
	
    setScroll:function(){
	    $('#pagetoplink')
	    	.bind("click",function(){$('html,body').animate({ scrollTop: 0 },500);});
	    $('#pagetoplink a').attr("href","javascript:");
    }
    
};

$(document).ready(function(){
	okidai = new Okidai();
	okidai.init();
});
