

/* :first-child, :last-childをクラスとして追加
-----------------------------------------------------------*/
$(document).ready(function() {
	$('ul li:first-child,.news div:first-child').addClass('firstChild');
	$('ul li:last-child').addClass('lastChild');
	$("ul li:only-child").removeClass("first-child").removeClass("last-child").addClass("only-child");

});


/* access maps
-----------------------------------------------------------*/
function initAccessMap() {
	var key = 'ABQIAAAA3i_VtXXXNSNT21DTjLNtpBQ8RHekKEI1m63ZqZ1qwgCuJmkptBSKtKobHfXuu9CmByaC2tIVNrGzAQ';
	if(location.hostname.indexOf('192.168.') >= 0) key = 'ABQIAAAA3i_VtXXXNSNT21DTjLNtpBRB4nrBOd15Q9ov68K7sUHf5JKZLxSEMrrp8UdX8BPESjRsLIDEFD2P0Q';
	document.write('<script src="http://maps.google.com/maps?file=api&v=1&key=' + key + '" type="text/javascript" charset="utf-8"></script>');
	
	$(function() {
		$('a.stoOutlineLink').append('&nbsp;[+]');
		$('a.stoStoreLink').append('&nbsp;[+]');
	});
}

function setAccessMap(id, lat, lng) {
	if(GBrowserIsCompatible()){
		var point = new GLatLng(lat, lng);
		var map = new GMap2($('#' + id)[0]);
		map.setCenter(point, 17);
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		var marker = new GMarker(point);
		map.addOverlay(marker);
	}
}

function toggleAccessMap(mapID, linkObj, lat, lng) {
	$('#' + mapID).toggle(
		'slow',
		function() {
			var flg = $(linkObj).text().indexOf('[+]');
			if(flg < 0) {
				$(linkObj).text($(linkObj).text().replace(/\-/, '+'));
			} else {
				$(linkObj).text($(linkObj).text().replace(/\+/, '-'));
				setAccessMap(mapID, lat, lng);
			}
		}
	);
}

/* twitter
-----------------------------------------------------------*/
function setTwitter(id) {
	new TWTR.Widget({
		version: 2,
		type: 'profile',
		rpp: 2,
		interval: 6000,
		width: 'auto',
		height: 300,
		theme: {
			shell: {
				background: '#ebf9fd',
				color: '#333333'
			},
			tweets: {
				background: '#ebf9fd',
				color: '#333333',
				links: '#114488'
			}
		},
		features: {
			scrollbar: false,
			loop: false,
			live: false,
			hashtags: true,
			timestamp: false,
			avatars: false,
			behavior: 'all'
		}
	}).render().setUser(id).start();
}


/* ロールオーバー
-----------------------------------------------------------*/
(function($) {
	$.fn.rollover = function(postfix) {
		postfix = (postfix != null) ? postfix : '_on';
		
		return this.not('[src*="'+ postfix +'."]').each(
		function() {
			var img = $(this);
			var src = img.attr('src');
			var src_on = src.substr(0, src.lastIndexOf('.'))
			           + postfix
			           + src.substring(src.lastIndexOf('.'));
			$('<img>').attr('src', src_on);
			img.hover(
				function() {
					img.attr('src', src_on);
				},
				function() {
					img.attr('src', src);
				}
			);
		});
		
		
	};
})(jQuery);


jQuery(document).ready(function($) {
   // set postfix
   $('#globalNavi a img').rollover();
   $('.top .recruit a img,.blog a img,.school a img').rollover();
 });


