$(function() {
		$('.tab-box').hover(function(){
			if(!$(this).is(".tab-box-selected")){
				$(this).addClass('tab-box-1');
			}
		}, function(){
			$(this).removeClass('tab-box-1');
		});
		
		$('.twoclass-button').click(function(){
			$(this).parent().find('.twoclass-selected').removeClass('twoclass-selected');
			$(this).addClass('twoclass-selected');
		})
		$('.business-normal-2').click(function(){
			$(this).removeClass('business-normal-2');
			$(this).addClass('business-selected-2');
			$(this).parent().find('.business-selected-1').addClass('business-normal-1');
			$(this).parent().find('.business-selected-3').addClass('business-normal-3');	
			$(this).parent().find('.business-selected-4').addClass('business-normal-4');
			$(this).parent().find('.business-selected-5').addClass('business-normal-5');
			$('.business-table-1').show();
			$('.business-table-2').hide();
			$('.business-table-3').hide();
			$('.business-table-0').hide();
		})
		$('.business-normal-3').click(function(){
			$(this).removeClass('business-normal-3');
			$(this).addClass('business-selected-3');
			$(this).parent().find('.business-selected-1').addClass('business-normal-1');
			$(this).parent().find('.business-selected-2').addClass('business-normal-2');	
			$(this).parent().find('.business-selected-4').addClass('business-normal-4');
			$(this).parent().find('.business-selected-5').addClass('business-normal-5');	
			$('.business-table-2').show();
			$('.business-table-1').hide();
			$('.business-table-3').hide();
			$('.business-table-0').hide();
		})
		$('.business-normal-4').click(function(){
			$(this).removeClass('business-normal-4');
			$(this).addClass('business-selected-4');
			$(this).parent().find('.business-selected-1').addClass('business-normal-1');
			$(this).parent().find('.business-selected-3').addClass('business-normal-3');	
			$(this).parent().find('.business-selected-2').addClass('business-normal-2');
			$(this).parent().find('.business-selected-5').addClass('business-normal-5');	
			$('.business-table-3').show();
			$('.business-table-1').hide();
			$('.business-table-2').hide();
			$('.business-table-0').hide();
		})
		$('.business-selected-1').click(function(){
			$(this).removeClass('business-normal-1');
			$(this).addClass('business-selected-1');
			$(this).parent().find('.business-selected-3').addClass('business-normal-3');
			$(this).parent().find('.business-selected-2').addClass('business-normal-2');	
			$(this).parent().find('.business-selected-4').addClass('business-normal-4');
			$(this).parent().find('.business-selected-5').addClass('business-normal-5');
			$('.business-table-0').show();
			$('.business-table-1').hide();
			$('.business-table-2').hide();
			$('.business-table-3').hide();
		})
		
		$('.information-tab-1').click(function(){
			$('.twohand-sale-twoclass-car').show();
			$('.twohand-sale-twoclass-moto').hide();
			$('.twohand-sale-twoclass-spaces').hide();
			$('.twohand-sale-twoclass-product').hide();
			$('.twohand-sale-twoclass-other').hide();
			$('.twohand-sale-table').hide();
			$('#twohand-sale-table-car-sell').show();
			$('twohand-button-car-sell').attr('class','twoclass-selected twoclass-button');
		})
		$('.information-tab-2').click(function(){
			$('.twohand-sale-twoclass-car').hide();
			$('.twohand-sale-twoclass-moto').show();
			$('.twohand-sale-twoclass-spaces').hide();
			$('.twohand-sale-twoclass-product').hide();
			$('.twohand-sale-twoclass-other').hide();
			$('.twohand-sale-table').hide();
			$('#twohand-sale-table-moto-all-sell').show();
			motoAllSell();
			$('#twohand-button-moto-all-sell').attr('class','twoclass-selected twoclass-button');
		})
		$('.information-tab-3').click(function(){
			$('.twohand-sale-twoclass-car').hide();
			$('.twohand-sale-twoclass-moto').hide();
			$('.twohand-sale-twoclass-spaces').hide();
			$('.twohand-sale-twoclass-product').show();
			$('.twohand-sale-twoclass-other').hide();
			$('.twohand-sale-table').hide();
			$('#twohand-sale-table-product').show();
			productSell();
			$('#twohand-button-product').attr('class','twoclass-selected twoclass-button');
		})
		$('.information-tab-4').click(function(){
			$('.twohand-sale-twoclass-car').hide();
			$('.twohand-sale-twoclass-moto').hide();
			$('.twohand-sale-twoclass-spaces').show();
			$('.twohand-sale-twoclass-product').hide();
			$('.twohand-sale-twoclass-other').hide();
			$('.twohand-sale-table').hide();
			$('#twohand-sale-table-spaces-rent').show();
			spacesRent();
			$('#twohand-button-spaces-rent').attr('class','twoclass-selected twoclass-button');
		})
		$('.information-tab-5').click(function(){
			$('.twohand-sale-twoclass-car').hide();
			$('.twohand-sale-twoclass-moto').hide();
			$('.twohand-sale-twoclass-spaces').hide();
			$('.twohand-sale-twoclass-product').hide();
			$('.twohand-sale-twoclass-other').show();
			$('.twohand-sale-table').hide();
			$('#twohand-sale-table-other').show();
		})
		$('#twohand-button-car-sell').click(function(){
		    $('.twohand-sale-table').hide();
			$('#twohand-sale-table-car-sell').show();
			
		})
		$('#twohand-button-car-company-sell').click(function(){
		    $('.twohand-sale-table').hide();
			$('#twohand-sale-table-car-company-sell').show();
			carCompanySell();
		})
		$('#twohand-button-car-personal-sell').click(function(){
		    $('.twohand-sale-table').hide();
			$('#twohand-sale-table-car-personal-sell').show();
			carPersonalSell();
		})
		$('#twohand-button-car-personal-buy').click(function(){
		    $('.twohand-sale-table').hide();
			$('#twohand-sale-table-car-personal-buy').show();
			carPersonalBuy();
		})
		$('#twohand-button-moto-all-sell').click(function(){
		    $('.twohand-sale-table').hide();
			$('#twohand-sale-table-moto-all-sell').show();
			motoAllSell();
		})
		$('#twohand-button-moto-company-sell').click(function(){
		    $('.twohand-sale-table').hide();
			$('#twohand-sale-table-moto-company-sell').show();
			motoCompanySell();
		})
		$('#twohand-button-moto-personal-sell').click(function(){
		    $('.twohand-sale-table').hide();
			$('#twohand-sale-table-moto-personal-sell').show();
			motoPersonalSell();
		})
		$('#twohand-button-product').click(function(){
		    $('.twohand-sale-table').hide();
			$('#twohand-sale-table-product').show();
			productSell();
		})
		$('#twohand-button-spaces-all').click(function(){
		    $('.spaces-sale-table').hide();
			$('#twohand-sale-table-spaces-all').show();
			
		})
		$('#twohand-button-spaces-rent').click(function(){
		    $('.spaces-sale-table').hide();
			$('#twohand-sale-table-spaces-rent').show();
			spacesRent();
		})
		$('#twohand-button-spaces-sell').click(function(){
		    $('.spaces-sale-table').hide();
			$('#twohand-sale-table-spaces-sell').show();
			spacesSell();
		})
		$('#twohand-button-spaces-rent-sell').click(function(){
		    $('.spaces-sale-table').hide();
			$('#twohand-sale-table-spaces-rent-sell').show();
			spacesRentSell();
		})
		$('#twohand-button-spaces-request-rent').click(function(){
		    $('.spaces-sale-table').hide();
			$('#twohand-sale-table-spaces-request-rent').show();
			spacesRequestRent();
		})
		$('#twohand-button-spaces-reqeust-sell').click(function(){
		    $('.spaces-sale-table').hide();
			$('#twohand-sale-table-spaces-request-sell').show();
			spacesRequestSell();
		})
		$('#twohand-button-spaces-requset-rent-sell').click(function(){
		    $('.spaces-sale-table').hide();
			$('#twohand-sale-table-spaces-request-rent-sell').show();
			spacesRequestRentSell();
		})
		$('.tab-box').click(function(){
			$(this).parent().parent().find('.tab-box-selected').removeClass('tab-box-selected');
		 	$(this).addClass('tab-box-selected').removeClass('tab-box-1');
		})
		
		$('.magazine-right-left-1').hover(function(){
			$(this).parent().find('.open-magazine').slideDown('fast')
			}, function(){
			$('.open-magazine').slideUp('fast');
		})
		$('.magazine-left').hover(function(){
			$(this).parent().find('.open-magazine-1').slideDown('fast')
			}, function(){
			$('.open-magazine-1').slideUp('fast');
		})
		
		$('.parts-box').hover(function(){
			$(this).find('.parts-pic').css('border','#FFBA00 solid 1px');
			}, function(){
			$('.parts-pic').css('border','#C9C9C9 solid 1px');
		})
		
		$('.myinput').focus(function(){
		  	$(this).css('color','#000');
		})
		
		$('.parking-li').hover(function(){
			$(this).find('.parking-pic').css('border','#FFBA00 solid 1px');
			}, function(){
			$('.parking-pic').css('border','#C9C9C9 solid 1px');
		})
		changePic();
	});
	
	function changePic()
	{
		//small-pic-selected
	
		var $iB=$(".information-left>.big-pic");
		var $iS=$(".information-left>.small-pic");
		
		//初期化
		$iB.find(">img:gt(0)").hide();
		$iS.find(">div:eq(0)").addClass("small-pic-selected");
		
		var length=$iB.find(">img").length;
		var t=false;
		var time=5000;
		var i=0;
		
		var change=function(j){
			$iB.find(">img:eq("+i+")").hide();
			$iS.find(">div:eq("+i+")").removeClass("small-pic-selected");
			
			i+=j;
			if(i==length) i=0;
			$iB.find(">img:eq("+i+")").show();
			$iS.find(">div:eq("+i+")").addClass("small-pic-selected");
		}
		var clearT=function(){
			if(t) clearInterval(t);
		}
		
		t=setInterval(function(){change(1)},time);
		 
		$iS.find(">div").click(function(){
			var index=$iS.find(">div").index($(this));
			
			clearT();
			if(i!=index)
			{	
				$iB.find(">img").hide();
				$iS.find(">div").removeClass("small-pic-selected");

				$(this).addClass("small-pic-selected");
				$iB.find(">img:eq("+index+")").show();
				
				i=index;
			}
			
			t=setInterval(function(){change(1)},time);
		});	
	}

function carCompanySell(){
	if($("#twohand-sale-table-car-company-sell").find("tr").size()<=0){
   		
   		$.ajax({
		   type: "POST",
		   url: "index/carCompanySell",
		   dataType: 'json',
		   success: function(msg){
		     $("#twohand-sale-table-car-company-sell").html(msg);
		     
		   }  
        });
     }
}	
function carPersonalSell(){
	if($("#twohand-sale-table-car-personal-sell").find("tr").size()<=0){
   		
   		$.ajax({
		   type: "POST",
		   url: "index/carPersonalSell",
		   dataType: 'json',
		   success: function(msg){
		     $("#twohand-sale-table-car-personal-sell").html(msg);
		     
		   }  
        });
     }
}

function carPersonalBuy(){
	if($("#twohand-sale-table-car-personal-buy").find("tr").size()<=0){
   		$.ajax({
		   type: "POST",
		   url: "index/carPersonalBuy",
		   dataType: 'json',
		   success: function(msg){
		     $("#twohand-sale-table-car-personal-buy").html(msg);
		     
		   }  
        });
     }
}

function motoAllSell(){
	if($("#twohand-sale-table-moto-all-sell").find("tr").size()<=0){
   		$.ajax({
		   type: "POST",
		   url: "index/motoAllSell",
		   dataType: 'json',
		   success: function(msg){
		     $("#twohand-sale-table-moto-all-sell").html(msg);
		     
		   }  
        });
     }
}

function motoCompanySell(){
	if($("#twohand-sale-table-moto-company-sell").find("tr").size()<=0){
   		$.ajax({
		   type: "POST",
		   url: "index/motoCompanySell",
		   dataType: 'json',
		   success: function(msg){
		     $("#twohand-sale-table-moto-company-sell").html(msg);
		     
		   }  
        });
     }
}

function motoPersonalSell(){
	if($("#twohand-sale-table-moto-personal-sell").find("tr").size()<=0){
   		$.ajax({
		   type: "POST",
		   url: "index/motoPersonalSell",
		   dataType: 'json',
		   success: function(msg){
		     $("#twohand-sale-table-moto-personal-sell").html(msg);
		     
		   }  
        });
     }
}

function productSell(){
	if($("#twohand-sale-table-product").find("tr").size()<=0){
   		$.ajax({
		   type: "POST",
		   url: "index/productSell",
		   dataType: 'json',
		   success: function(msg){
		     $("#twohand-sale-table-product").html(msg);
		     
		   }  
        });
     }
}

function otherSell(){

}

function spacesRent(){
	if($("#twohand-sale-table-spaces-rent").find("tr").size()<=0){
   		$.ajax({
		   type: "POST",
		   url: "index/spacesRent",
		   dataType: 'json',
		   success: function(msg){
		     $("#twohand-sale-table-spaces-rent").html(msg);
		     
		   }  
        });
     }
}
function spacesSell(){
	if($("#twohand-sale-table-spaces-sell").find("tr").size()<=0){
   		$.ajax({
		   type: "POST",
		   url: "index/spacesSell",
		   dataType: 'json',
		   success: function(msg){
		     $("#twohand-sale-table-spaces-sell").html(msg);
		     
		   }  
        });
     }
}

function spacesRentSell(){
	if($("#twohand-sale-table-spaces-rent-sell").find("tr").size()<=0){
   		$.ajax({
		   type: "POST",
		   url: "index/spacesRentSell",
		   dataType: 'json',
		   success: function(msg){
		     $("#twohand-sale-table-spaces-rent-sell").html(msg);
		     
		   }  
        });
     }
}

function spacesRequestRent(){
	if($("#twohand-sale-table-spaces-request-rent").find("tr").size()<=0){
   		$.ajax({
		   type: "POST",
		   url: "index/spacesRequestRent",
		   dataType: 'json',
		   success: function(msg){
		     $("#twohand-sale-table-spaces-request-rent").html(msg);
		     
		   }  
        });
     }
}

function spacesRequestSell(){
	if($("#twohand-sale-table-spaces-request-sell").find("tr").size()<=0){
   		$.ajax({
		   type: "POST",
		   url: "index/spacesRequestSell",
		   dataType: 'json',
		   success: function(msg){
		     $("#twohand-sale-table-spaces-request-sell").html(msg);
		     
		   }  
        });
     }
}

function spacesRequestRentSell(){
	if($("#twohand-sale-table-spaces-request-rent-sell").find("tr").size()<=0){
   		$.ajax({
		   type: "POST",
		   url: "index/spacesRequestRentSell",
		   dataType: 'json',
		   success: function(msg){
		     $("#twohand-sale-table-spaces-request-rent-sell").html(msg);
		     
		   }  
        });
     }
}
function doBoxMessage(url){
    
	viewAdvertising('1');
	window.location.href = url;
}

	