/*--------------------------------------------------------------------------*
 *  win / mac
 *--------------------------------------------------------------------------*/

j$(function(){
	var UA = navigator.userAgent;
	if(UA.match(/[Ww]in/)) {
		j$('body').addClass('win');
	} else if(UA.match(/[Mm]ac/)) {
		j$('body').addClass('mac');
	}
});


/*--------------------------------------------------------------------------*
 *  pagetop
 *--------------------------------------------------------------------------*/

j$(document).ready(function(){
	if(navigator.userAgent.indexOf("MSIE") != -1){
		j$('a[href*=#]').click(function() {
			if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
			&& location.hostname == this.hostname) {
				var $target = j$(this.hash);
				$target = $target.length && $target
				|| j$('[name=' + this.hash.slice(1) +']');
				if ($target.length) {
					var targetOffset = $target.offset().top;
					j$('html,body').animate({scrollTop: targetOffset}, 1000);
					
					return false;
				}
			}
		});
	}

	else{
	j$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname) {
			var $target = j$(this.hash);
			$target = $target.length && $target
			|| j$('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				j$('html').animate({scrollTop: targetOffset}, 1000);
				
				return false;
			}
		}
  });
	}

});


j$(function() {
if (navigator.appVersion.indexOf("Safari")) {
		j$('a[href*=#]').click(function() {
			if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
			&& location.hostname == this.hostname) {
				var $target = j$(this.hash);
				$target = $target.length && $target
				|| j$('[name=' + this.hash.slice(1) +']');
				if ($target.length) {
					var targetOffset = $target.offset().top;
					j$('body').animate({scrollTop: targetOffset}, 1000);
					
					return false;
				}
			}
		});
}
});


j$(function () {

		if(navigator.userAgent.indexOf("MSIE") != -1){
			j$('a[href*=#]').click(function () {
							j$('html,body').animate({ targetOffset: 0 }, 300, 'quart');
				});
		}

		else{
			j$('a[href*=#]').click(function () {
							j$('html').animate({ targetOffset: 0 }, 300, 'quart');
			});
		}

});



/*--------------------------------------------------------------------------*
 *  rollover
 *--------------------------------------------------------------------------*/

jQuery.fn.rollover = function(suffix) {
	suffix = suffix || '_on';
	return this.not('[src*="'+ suffix +'."]').each(function() {
		var img = jQuery(this);
		var src = img.attr('src');
		var _on = [
			src.substr(0, src.lastIndexOf('.')),
			src.substring(src.lastIndexOf('.'))
		].join(suffix);
		jQuery('<img>').attr('src', _on);
		img.hover(
			function() { img.attr('src', _on); },
			function() { img.attr('src', src); }
		);
	});
};

jQuery(function($) {
	$('a.on img').rollover();
	$('form input:image').rollover();
//	$('button img').rollover();
});





