jQuery.noConflict()(function($){

	var preLoadImg = new Object();

// メインメニュー
	$('body.news #mainmenunewsimg').css({opacity:"0"}).attr('src','/common_2010/pic/news-b_f2.gif').animate({opacity:"1"}, 1000 );
	$('body.newcar #mainmenunewcarimg').css({opacity:"0"}).attr('src','/common_2010/pic/newcar-b_f2.gif').animate({opacity:"1"}, 1000 );
	$('body.usedcar #mainmenuusedcarimg').css({opacity:"0"}).attr('src','/common_2010/pic/usedcar-b_f2.gif').animate({opacity:"1"}, 1000 );
	$('body.showroom #mainmenushowroomimg').css({opacity:"0"}).attr('src','/common_2010/pic/showroom-b_f2.gif').animate({opacity:"1"}, 1000 );
	$('body.inquiry #mainmenuinquiryimg').css({opacity:"0"}).attr('src','/common_2010/pic/inquiry-b_f2.gif').animate({opacity:"1"}, 1000 );

	$("#mainmenu li a").each(function(){
		$(this).hover(
			function() {
				$(this).find('img').animate({ 
				opacity: 0.75}, 250 );
			},
			function() {
				$(this).find('img').animate({ 
				opacity: 1}, 250 );
			}
		);
	});
	
// グローバルメニュー
	$("#groupmenu a img").each(function(){
		var imgSrc = this.src;
		var sep = imgSrc.lastIndexOf('.');
		var sepprev = sep;
		var chkstr = imgSrc.substr(sep - 3, 3);
		if(chkstr == '_f2') {sepprev = sepprev - 3}
		var onSrc = imgSrc.substr(0, sepprev) + '_f2' + imgSrc.substr(sep, 4);
		$(this).hover(
			function() {
				$(this).attr('src',onSrc);
			},
			function() {
				$(this).attr('src',imgSrc);
			}
		);
	});

// サイドコンテンツメニュー
	var current_pass='';
	var current_pass_arr=location.href.split("/");
	for(i=3;i<current_pass_arr.length;i++){
		current_pass=current_pass+'/'+current_pass_arr[i];
	}
	$("#sidecontents li a").each(function(){
		var href_pass=$(this).attr('href');
		if(current_pass == href_pass){
			$(this).css({'background-color':'#f1f1f1','color':'#999'});
		}
	});

// サイドバナー
	$(".sidebanner li a").each(function(){
		$(this).hover(
			function() {
				$(this).find('img').animate({ 
				opacity: 0.5}, 250 );
			},
			function() {
				$(this).find('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);
			}
		);
	});
	
// トップページタブ
	var listheight = 0;
	var maxlistheight = 0;
	$('body.toppage #tabnewcar li').each(function(){
		listheight = $(this).height();
		if(listheight > maxlistheight) {
			maxlistheight = listheight;
		}
	});
	$('body.toppage #tabnewcar li').height(maxlistheight);
	$('body.toppage #tabnewcar').hide();
	$('body.toppage #tabcampaignh').css({'cursor':'pointer','position':'absolute','top':'0','left':'380px'}).attr('src','pic/campaign-h_f2.png').click(function() {
			$(this).attr('src','pic/campaign-h_f2.png');
			$('body.toppage #tabcampaign').fadeIn(500);
			$('body.toppage #tabnewcarh').attr('src','pic/newcar-h.png');
			$('body.toppage #tabnewcar').hide();
		});
	$('body.toppage #tabnewcarh').css({'cursor':'pointer','position':'absolute','top':'0','left':'510px'}).click(function() {
			$(this).attr('src','pic/newcar-h_f2.png');
			$('body.toppage #tabnewcar').fadeIn(500);
			$('body.toppage #tabcampaignh').attr('src','pic/campaign-h.png')
			$('body.toppage #tabcampaign').hide();
		});
	var tabheight=$('body.toppage #calendarbox').height();
	$('body.toppage .tabbox').css({'position':'absolute','top':'50px','left':'20px','overflow':'auto','width':'620px'}).height(tabheight-50);

// トップページコンテンツバナー
	$('body.toppage #contentsbannerbox img').hover(
			function() {
				$(this).animate({ 
    				opacity: 0.5}, 250 );
			},
			function() {
				$(this).animate({ 
    				opacity: 1}, 250 );
			})

// 地図
	$('#showroomlist li .showroomicon').css({'opacity':'0.25'});
	$('#showroomlist li').css({'cursor':'pointer'}).hover(
			function() {
				$(this).css({'background-color':'#fff'}).find('.showroomicon').animate({ 
    				opacity: 1}, 250 );
			},
			function() {
				$(this).css({'background-color':'transparent'}).find('.showroomicon').animate({ 
    				opacity: 0.25}, 250 );
			}).click(function() {
			var showroomlink=$(this).find('a').attr('href');
			location.href=showroomlink;
		});
	
	$('#showroomlist li .showroomicon').mouseover(
			function() {
				var topOffset=$('#showroomlist').height()/2-30;
				var divOffset = $('#showroomlist').offset().top;
				var pOffset = $(this).parent().parent('li').offset().top;
				var pScroll = pOffset - divOffset - topOffset;
				$('#showroomlist').animate({ 
    				scrollTop: '+=' + pScroll + 'px'}, 250 );
			});
});



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)
	});
});
