// JavaScript Document

function disp(url){

	window.open(url, "sp_contents", "width=940,height=634,status=0,resizable=0,scrollbars=0,toolbar=0,menubar=0,location=0");

}


/*
// Rollover Script on [ jQuery ]
// Rollover class = hover
// Rollover FileName = ***_on.jpg/gif/png
*/
function initRollovers() {
	var conf = { className : 'hover', postfix : '_on' };
	$('img.' + conf.className).each(function(){
		
		this.originalSrc = new Image;
		this.preloadSrc = new Image;

		this.originalSrc = this.src;
		this.preloadSrc = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1" + conf.postfix + "$2");
		
		$(this).hover(function(){
			this.src = this.preloadSrc;
		},function(){
			this.src = this.originalSrc;
			//this.src = this.src.replace(/^(.+)_on(\.[a-z]+)$/, "$1$2");
		});
		
	});
};

/*
// Open New Window on [ jQuery ]
// Rollover class = popup
*/
function initNewWindow() {
	// External Link
	$('a[@href^="http"]').not('[@href^="http://www.carecom.jp"]').not("[href^=#]").addClass("external");
	
	var popupEvent = function(event) {
		if( this.rel ) {
			window.open(this.href, 'popup', this.rel).focus();
		} else {
			window.open(this.href, '_blank').focus();
		}
		event.preventDefault();
		event.stopPropagation();
	}
	$("a.popup, a.external").each(function(i) {
		$(this).click(popupEvent);
		$(this).keypress(popupEvent);
	});
};

function searchBox() {
	$("#search .btn").each(function(){
		this.originalSrc = new Image;
		this.preloadSrc = new Image;
		this.originalSrc = this.src;
		this.preloadSrc = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1_on$2");
		$(this).hover(function(){
			this.src = this.preloadSrc;
		},function(){
			this.src = this.originalSrc;
		});
		
	});
	$("#search input[@type='text']").focus(function(){$(this).addClass("focus");}).blur(function(){$(this).removeClass("focus")});
};

function interface() {
	$("#news div span").hover(function(){
		$(this).addClass("focus")},function(){$(this).removeClass("focus");
	});
	$("#pickup dl").hover(function(){
		$(this).addClass("focus")},function(){$(this).removeClass("focus");
	});
	$("#pickup dl:last").css("background-image","none");
	$("#footer li:last").css({"border-right":"none", "padding-right":"0"});
};


$(document).ready(function() {
	$(initRollovers);
	$(initNewWindow);
	$(searchBox);
	$(interface);
});

function changeMapImage(url) {
document.getElementById('map').src = url;
}
