jQuery.noConflict()(function($){

	var preLoadImg = new Object();


	
// メインメニュー
	$('body.home #mainhomeb').attr('src','/common_2010/pic/home-b_f2.gif');
	$('body.product #mainproductb').attr('src','/common_2010/pic/product-b_f2.gif');
	$('body.history #mainhistoryb').attr('src','/common_2010/pic/history-b_f2.gif');
	$('body.news #mainnewsb').attr('src','/common_2010/pic/news-b_f2.gif');
	$('body.showroom #mainshowroomb').attr('src','/common_2010/pic/showroom-b_f2.gif');
	$('body.inquiry #maininquiryb').attr('src','/common_2010/pic/inquiry-b_f2.gif');
	$('body.testride #maintestrideb').attr('src','/common_2010/pic/testride-b_f2.gif');
	$('body.catalog #maincatalogb').attr('src','/common_2010/pic/catalog-b_f2.gif');
	$('body.loan #mainloanb').attr('src','/common_2010/pic/loan-b_f2.gif');
	$('#mainmenu > ul > li > ul').css('visibility','hidden').hide();
	$("#mainmenu > ul > li").each(function(){
		var swapimg = $(this).children('a').find('img');
		var imgSrc = swapimg.attr('src');
		var separater = imgSrc.lastIndexOf('.');
		var separaterprev = separater;
		var chkstr = imgSrc.substr(separater - 3, 3);
		if(chkstr == '_f2') {separaterprev = separaterprev - 3}
		var onSrc = imgSrc.substr(0, separaterprev) + '_f2' + imgSrc.substr(separater, 4);
		preLoadImg[imgSrc] = new Image();
		preLoadImg[imgSrc].src = onSrc;
		$(this).hover(
			function() {
				$(this).children('ul').css('visibility','visible').slideDown('250');
				swapimg.css({opacity: "0"}).attr('src',onSrc).animate({ 
    				opacity: 1}, 250 );
			},
			function() {
				$(this).children('ul').css('visibility','hidden').hide();
				swapimg.attr('src',imgSrc);
			}
		);
	});
	
	
	
	
	
	
	
	
	
	
// サイドバナー
	$("#sideshowroombanner li a").each(function(){
		$(this).hover(
			function() {
				$(this).find('img').animate({ 
				opacity: 0.5}, 250 );
			},
			function() {
				$(this).find('img').animate({ 
				opacity: 1}, 250 );
			}
		);
	});

// メインイメージ
	$("body.group #mainimage").append('<div class="shadow">&nbsp;</div>');

// 地図
	$('#globalmap ul li img').css('opacity','0.6');
	$('#globalmap ul li a').each(function(){
		var self = $(this);
		var alttext = self.find('img').attr('alt')
		var showroominfo = self.parent().find('span.info').html();
		self.hover(function(e){
			$(this).find('img').animate({ 
    				opacity: 1}, 500 ).attr('alt','');
			$("body").append('<div id="tooltip"><div class="tooltiptop">&nbsp;</div><div class="tooltipbody">'+showroominfo+'</div><div class="tooltipbottom">&nbsp;</div></div>');
        	$("#tooltip").css({
				top: e.pageY+16,
				left: e.pageX-110
				}).fadeIn(250);
			},function(){
				$(this).find('img').animate({ 
    				opacity: 0.6}, 500 ).attr('alt',alttext);
				$("#tooltip").hide().remove();
		});
    	self.mousemove(function(e){
			$("#tooltip").css({
				top: e.pageY+16,
				left: e.pageX-110
			});
		});
	});

// マトリックスメニュー
	$('.matrixmenu a').hover(
		function() {
			$(this).children("img").animate({ 
				opacity: 0.5}, 250 );
		},
		function() {
			$(this).children("img").animate({ 
				opacity: 1}, 250 );
		}
	);

// ロールオーバー
	$("a.rollover img").each(function(){
		var imgSrc = this.src;
		var sep = imgSrc.lastIndexOf('.');
		var onSrc = imgSrc.substr(0, sep) + '_f2' + imgSrc.substr(sep, 4);
		preLoadImg[imgSrc] = new Image();
		preLoadImg[imgSrc].src = onSrc;
		$(this).parent("a.rollover").hover(
			function() {
				$(this).children("img").css({opacity: "0"}).attr('src',onSrc).animate({ 
    				opacity: 1}, 250 );
			},
			function() {
				$(this).children("img").attr('src',imgSrc);
			}
		);
	});

// トップページ リンク
	$('body.group.toppage .showroominfo').css('cursor','pointer').each(function(){
		var position = $(this).attr('id').indexOf("box",0)
		var showroom_name = $(this).attr('id').substr(0,position);
		$(this).hover(function(){
			$(this).css('opacity','0.5');
			$('#'+showroom_name+'image').css('z-index','20').animate({ 
    				height: 400}, 250 );
		},function(){
			$(this).css('opacity','1');
			$('#'+showroom_name+'image').css('z-index','10').animate({ 
    				height: 0}, 250 );
		})
	}).click(function(){
		var showroomsitelink=$(this).find('a').attr('href');
		location.href=showroomsitelink;
	});


// トップページ ニュース高さ合わせ
	var showroombox_ul_max_height = 0;
	var showroombox_ul_height;
	$('body.group.toppage .showroombox ul').each(function(){
		var showroombox_ul_height = $(this).height();
		if(showroombox_ul_height > showroombox_ul_max_height){
			showroombox_ul_max_height = showroombox_ul_height;
		}
	}).height(showroombox_ul_max_height);


	
});


window.addEvent('domready', function(){
	//call multiBox
	var initMultiBox = new multiBox({
		mbClass: '.mb',//class you need to add links that you want to trigger multiBox with (remember and update CSS files)
		container: $(document.body),//where to inject multiBox
		descClassName: 'mbDesc',//the class name of the description divs
		path: './Files/',//path to mp3 and flv players
		useOverlay: true,//use a semi-transparent background. default: false;
		maxSize: {w:900, h:1000},//max dimensions (width,height) - set to null to disable resizing
		addDownload: false,//do you want the files to be downloadable?
		pathToDownloadScript: './Scripts/ForceDownload.asp',//if above is true, specify path to download script (classicASP and ASP.NET versions included)
		addRollover: true,//add rollover fade to each multibox link
		addOverlayIcon: true,//adds overlay icons to images within multibox links
		addChain: false,//cycle through all images fading them out then in
		recalcTop: true,//subtract the height of controls panel from top position
		addTips: true//adds MooTools built in 'Tips' class to each element (see: http://mootools.net/docs/Plugins/Tips)
	});
});

