// rollover

function over() {
	if (!document.getElementById) return
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');
	var aAll = document.getElementsByTagName('a');
	
//aクリック時の枠を消去	
	if(aAll){
		for (var i = 0; i < aAll.length; i++) {
			var Parel = aAll[i].getAttribute('rel');
			aAll[i].onfocus = function() {
				this.blur();	
			}
		
			if (aAll[i].className == 'popup') {
				aAll[i].onclick = function(){
					var pAlink = this.getAttribute('href');
					var newWin=window.open(pAlink,"puwindow","width=414,height=575,scrollbars=no");
					newWin.focus();
					return false;
				}
			}
		
		}	
	
	}

	
	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'over') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_ov'+ftype);
			aImages[i].setAttribute('hsrc', hsrc);
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_ov'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

function GnavActiveChange() {
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById) return false;
	var Body = document.getElementsByTagName('body')[0].id;
	var asrc = Body +"Nav";
	var abtn = document.getElementById(asrc);	
	if(!abtn) return;
	var src = abtn.firstChild.firstChild.getAttribute('src');
	var ftype = src.substring(src.lastIndexOf('.'), src.length);
	var hsrc = src.replace(ftype, '_ov'+ftype);
	abtn.firstChild.firstChild.setAttribute('src', hsrc);
}

window.onload = function(){
		over();	
    GnavActiveChange();
};




/*--------------------------------------------------------------------------
 *  Smooth Scroller Script, version 1.0.1
 *  (c) 2007 Dezinerfolio Inc. <midart@gmail.com>
 *  For details, please check the website : http://dezinerfolio.com/
/*--------------------------------------------------------------------------*/

Scroller = {
	speed:10,
	gy: function (d) {
		gy = d.offsetTop
		if (d.offsetParent) while (d = d.offsetParent) gy += d.offsetTop
		return gy
	},
	scrollTop: function (){
		body=document.body
	    d=document.documentElement
	    if (body && body.scrollTop) return body.scrollTop
	    if (d && d.scrollTop) return d.scrollTop
	    if (window.pageYOffset) return window.pageYOffset
	    return 0
	},
	add: function(event, body, d) {
	    if (event.addEventListener) return event.addEventListener(body, d,false)
	    if (event.attachEvent) return event.attachEvent('on'+body, d)
	},
	end: function(e){
		if (window.event) {
			window.event.cancelBubble = true
			window.event.returnValue = false
      		return;
    	}
	    if (e.preventDefault && e.stopPropagation) {
	      e.preventDefault()
	      e.stopPropagation()
	    }
	},
	scroll: function(d){
		i = window.innerHeight || document.documentElement.clientHeight;
		h=document.body.scrollHeight;
		a = Scroller.scrollTop()
		if (d>a) {
			if (d>h-i) d = h-i;
			a += Math.ceil((d-a)/Scroller.speed);
		}
		else
			a = a+(d-a)/Scroller.speed;
		window.scrollTo(0,a)
	  	if(a==d || Scroller.offsetTop==a)clearInterval(Scroller.interval)
	  	Scroller.offsetTop=a
	},
	init: function(){
		Scroller.add(window,'load', Scroller.render)
	},

	render: function(){
		a = document.getElementsByTagName('a');
		Scroller.end(this);
		window.onscroll
	    for (i=0;i<a.length;i++) {
	      l = a[i];
	      if(l.href && l.href.indexOf('#') != -1 && ((l.pathname==location.pathname) || ('/'+l.pathname==location.pathname)) ){
	      	Scroller.add(l,'click',Scroller.end)
	      		l.onclick = function(){
	      			Scroller.end(this);
		        	l=this.hash.substr(1);
			a = document.getElementById(l);
			if (a) {
				clearInterval(Scroller.interval);
				Scroller.interval=setInterval('Scroller.scroll('+Scroller.gy(a)+')',10);
				}
			}
	      	}
		}
	}
}

Scroller.init();

/*CSS Browser Selector v0.2.9Rafael Lima (http://rafael.adm.br)http://rafael.adm.br/css_browser_selectorLicense: http://creativecommons.org/licenses/by/2.5/Contributors: http://rafael.adm.br/css_browser_selector#contributors*/

var css_browser_selector = function() {
    var ua = navigator.userAgent.toLowerCase(),
    is = function(t) {
        return ua.indexOf(t) != -1;
    },
    h = document.getElementsByTagName('html')[0],
    b = (!(/opera|webtv/i.test(ua)) && /msie\s(\d)/.test(ua)) ? ('ie ie' + RegExp.$1) : is('firefox/2') ? 'gecko ff2': is('firefox/3') ? 'gecko ff3': is('gecko/') ? 'gecko': is('opera/9') ? 'opera opera9': /opera\s(\d)/.test(ua) ? 'opera opera' + RegExp.$1: is('konqueror') ? 'konqueror': is('chrome') ? 'chrome webkit safari': is('applewebkit/') ? 'webkit safari': is('mozilla/') ? 'gecko': '',
    os = (is('x11') || is('linux')) ? ' linux': is('mac') ? ' mac': is('win') ? ' win': '';
    var c = b + os + ' js';
    h.className += h.className ? ' ' + c: c;
} ();



