jQuery.noConflict()(function($){

	var preLoadImg = new Object();


// トップページイメージ

	$('.home #mainimage img').each(function(idx){
		var imgSrc = this.src;
		$('.home #thumbimage').append('<img src="'+imgSrc+'" alt="" width="90" height="40" class="thumbnail" id="thumbnail'+idx+'" />');
	});
	$('.home #mainimage img:gt(0)').hide();
	$('.home #thumbimage img:eq(0)').css({opacity: 0.5});
	$('.home #thumbimage img').css({'cursor':'pointer'}).each(function(){
		var opcity_num;
		$(this).hover(function() {
			opcity_num=$(this).css('opacity');
			$(this).css({opacity: 0.75} );
			var thumb_id = $(this).attr('id');
			var thumb_no = thumb_id.substr(9,1);
			$('.home #mainimage img').hide();
			$('.home #mainimage img:eq('+thumb_no+')').fadeIn(500);
			$('.home #thumbimage img').css({opacity: 1});
			$(this).css({opacity: 0.5});
			opcity_num=$(this).css('opacity');
		},function() {
			$(this).css({opacity: opcity_num});
		}).click(function(){
			var thumb_id = $(this).attr('id');
			var thumb_no = thumb_id.substr(9,1);
			var imagelink=$('.home #mainimage img:eq('+thumb_no+')').parent('a').attr('href');
			var target=$('.home #mainimage img:eq('+thumb_no+')').parent('a').attr('target');
			if(imagelink&&!target){
				location.href=imagelink;
			}else if(imagelink){
				window.open(imagelink, target);
			}
		});
	});
	




// 新車

	$('#newcarlist').after('<p id="message"></p>');
	$('.newcar #newcarselect select').find('option:first').attr('selected','selected').end()
	.find('option:gt(1)').attr('selected','');
	$('.newcar #newcarselect select').change(
		function(){
			var dispflug = 0;
			var selecttype = $('.newcar select[name^="type"] option:selected').attr('value');
			var selectengine = $('.newcar select[name^="engine"] option:selected').attr('value');
			var selecteco = $('.newcar select[name^="eco"] option:selected').attr('value');
			var selectprice = $('.newcar select[name^="price"] option:selected').attr('value');
			$('#newcarlist > li').each(
			function(){
				$(this).css('display','none');
				var delay;
				var hit = 1;
				var classstr = $(this).attr('class');
				if(classstr.lastIndexOf(selecttype) < 0 && selecttype!='all') {
					hit=0;
				}
				if(classstr.lastIndexOf(selectengine) < 0 && selectengine!='all') {
					hit=0;
				}
				if(classstr.lastIndexOf(selecteco) < 0 && selecteco!='all') {
					hit=0;
				}
				if(classstr.lastIndexOf(selectprice) < 0 && selectprice!='all') {
					hit=0;
				}
				if(hit) {
					$(this).fadeIn(750);
					dispflug = 1;
				}
			});
			if(!dispflug) {
				$('#message').text('当てはまる車種はありませんでした。');
			} else {
				$('#message').text('※グレード・装備によりエコカー減税対象車とならない場合があります');
			}
		});
	$('#newcarlist > li > a').each(function(){
		var self = $(this);
		var alttext = self.parent().find('img').attr('alt')
		var carspec = self.parent().find('span.spec').html();
		self.hover(function(e){
			$(this).parent().find('img').animate({ 
			opacity: 0.5}, 250 ).attr('alt','');
			$("body").append('<div id="tooltip"><div class="tooltiptop">&nbsp;</div><div class="tooltipbody"><strong>'+alttext+'</strong><br />'+carspec+'</div><div class="tooltipbottom">&nbsp;</div></div>');
        	$("#tooltip").css({
				top: e.pageY+16,
				left: e.pageX+4
				}).fadeIn(250);
			},function(){
				$(this).parent().find('img').animate({ 
			opacity: 1}, 250 ).attr('alt',alttext);
				$("#tooltip").hide().remove();
		});
    	self.mousemove(function(e){
			$("#tooltip").css({
				top: e.pageY+16,
				left: e.pageX+4
			});
		});
	});
	$('#lineuplist > li > a').each(function(){
		var self = $(this);
		self.hover(function(){
			$(this).parent().find('img').animate({ 
			opacity: 0.5}, 250 );
			},function(){
				$(this).parent().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);
		});
	});



});


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

