////////////////////////////////订阅
function subscribe(){
	if($("#subscribe").length>0){
		$("#subscribe input.text").focus(function(){
			if($(this).attr("value")=="请输入email订阅电子通讯"){
				$(this).attr("value","");
			}
		});
		$("#subscribe input.text").blur(function(){
			if($(this).attr("value")==""){
				$(this).attr("value","请输入email订阅电子通讯");
			}
		});
	}
}
////////////////////////////////主导航
function mainNav(){
	if($("#mainNav").length>0){
		$("#mainNav>li").each(function(){
			$(this).hover(function(){
				if($(this).find("div").length>0){
					$(this).find("div").fadeIn("fast");
				}
			},
			function(){
				$(this).find("div").hide();
			}
			);
		});
	}
}
function techSpes(){
	if($("table.techSpes").length>0){
		$("table.techSpes tbody:gt(0)").each(function(){
			$(this).find("tr:odd").css("background","#f0f0f5");
			$(this).data("stat","off");
			$(this).find("tr").hide();
			$(this).find("tr").eq(0).show();
			$(this).find("tr").eq(0).find("th").eq(0).css("background","#ccccd1 url(/templates/default/images/arr8.gif) right center no-repeat");
			$(this).find("tr").eq(0).find("th").css("border-bottom","1px solid #fff");
			$(this).find("tr").eq(0).click(function(){
				$(this).nextAll().toggle();
				if($(this).parent().data("stat") == "on"){
					$(this).parent().data("stat","off");
					$(this).find("th").eq(0).css("background","#ccccd1 url(/templates/default/images/arr8.gif) right center no-repeat");
				}else if($(this).parent().data("stat") == "off"){
					$(this).parent().data("stat","on");
					$(this).find("th").eq(0).css("background","#ccccd1 url(/templates/default/images/arr7.gif) right center no-repeat");
				}
			});
		});
		$("table.techSpes tbody").eq(1).data("stat","on");
		$("table.techSpes tbody").eq(1).find("tr").eq(0).find("th").eq(0).css("background","#ccccd1 url(images/arr7.gif) right center no-repeat");
		if($("table.techSpes").length == 1){
			$("table.techSpes tbody").eq(1).find("tr").show();
		}
		$("table.techSpes tbody:first").find("tr").eq(0).css("background","#ffffff");
		//$("table.techSpes tbody:first").find("tr").eq(0).css("height","35px");
	
	////多款车
	$("h4.carType").each(function(){
		//$("h4.carType:first").find("span").addClass("on");
		if($("table.techSpes").length == 1){
			$("table.techSpes").eq(0).show();
			$("h4.carType").eq(0).find("span").addClass("on");
		}
		$(this).click(function(){
			if($(this).find("span").hasClass("on")){
				$(this).find("span").removeClass("on");
			}else{
				$(this).find("span").addClass("on");
			}
			$(this).next().toggle();
		});
	});
	}
}

/////////////////车展列表页鼠标经过
function carList(){
	if($("ul.carList").length>0){
		$("ul.carList li").hover(function(){$(this).addClass("on")},function(){$(this).removeClass("on")});
	}
}

/////////////////车展详细页标签
function detailTab(){
	if($(".detailTab").length>0){
		$(".detailTabCon").eq(0).show();
		$(".detailTab a").each(function(i){
			$(this).click(function(){
				$(".detailTab a").removeClass("on");
				$(this).addClass("on");
				$(".detailTabCon").hide();
				$(".detailTabCon").eq(i).show();
			});
			$(this).hover(function(){$(this).addClass("hover")},function(){$(this).removeClass("hover")});
		});
	}
}
/////////////////外观内饰
function extInt(){
	if($("#thumbsWra").length>0){
		$("#thumbsWra ul.thumbs li:first").addClass("on");
		$("#thumbsWra ul.thumbs li").each(function(){
			$(this).click(function(){
				$("#thumbsWra ul.thumbs li").removeClass("on");
				$(this).addClass("on");
				$("#large img").attr("src",$(this).attr("title"));
			});
		});
		$("#thumbsWra ul.thumbs").hide();
		$("#thumbsWra ul.thumbs").eq(0).show();
		$("#thumbsWra ul.tab li").each(function(i){
			$(this).click(function(){
				$("#thumbsWra ul.tab li").removeClass("on");
				$("#thumbsWra ul.tab li").eq(i).addClass("on");
				$("#thumbsWra ul.thumbs").hide();
				$("#thumbsWra ul.thumbs").eq(i).show();
			});
		});
		$("#large img").attr("src",$("#thumbsWra ul.thumbs li:first").attr("title"));
		//alert($("#thumbsWra ul.thumbs li:first").attr("title"));
	}
}

function extInt2(){
	if($("#thumbsWra2").length>0){
		$("#thumbsWra2 ul.thumbs li:first").addClass("on");
		$("#thumbsWra2 ul.thumbs li").each(function(){
			$(this).click(function(){
				$("#thumbsWra2 ul.thumbs li").removeClass("on");
				$(this).addClass("on");
				$("#large2 img").attr("src",$(this).attr("title"));
			});
		});
		$("#thumbsWra2 ul.thumbs").hide();
		$("#thumbsWra2 ul.thumbs").eq(0).show();
		$("#thumbsWra2 ul.tab li").each(function(i){
			$(this).click(function(){
				$("#thumbsWra2 ul.tab li").removeClass("on");
				$("#thumbsWra2 ul.tab li").eq(i).addClass("on");
				$("#thumbsWra2 ul.thumbs").hide();
				$("#thumbsWra2 ul.thumbs").eq(i).show();
			});
		});
		$("#large2 img").attr("src",$("#thumbsWra2 ul.thumbs li:first").attr("title"));
		//alert($("#thumbsWra ul.thumbs li:first").attr("title"));
	}
}



/////////////////订阅提交成功
function showSubscribeSuccess(){
	$("p#subscribeSuccess").html("您好，您的email已经提交成功。");
	$("p#subscribeSuccess").show();
}
/////////////////右键格式不正确
function showSubscribeError(){
	$("p#subscribeSuccess").html("<span style='color:red;'>对不起，您的邮箱格式不正确。</span>");
	$("p#subscribeSuccess").show();
}
/////////////////常见问题标签
function questionTab(){
	if($("#quetionTab").length>0){
		$(".quetionWra").eq(0).show();
		$("#quetionTab li").each(function(i){
			$(this).click(function(){
				$("#quetionTab li").removeClass("on");
				$(this).addClass("on");
				$(".quetionWra").hide();
				$(".quetionWra").eq(i).show();
			});
		});
	}
}
/////////////////常见问题下拉
function questionList(){
	if($("#quetionList").length>0){
		$("h3.quetionTitle").each(function(){
			$(this).click(function(){
				if(!$(this).hasClass("on")){
					$(this).addClass("on");
					$(this).next().slideDown("normal");
				}else{
					$(this).removeClass("on");
					$(this).next().slideUp("normal",function(){$(this).data("stat","off")});
				}
			});
		});
	}
}
/////////////////首页鼠标经过小图效果
function carSeries(){
	if($("#carSeries").length>0){
		var str = '<div class="thumbWra"><div class="bg"></div><img class="thumb2" /></div>';
		$("#carSeries li").each(function(){
			$(this).append(str);
			var _src = $(this).find("img.thumb").attr("src");
			$(this).find("img.thumb2").attr("src",_src);
			var _left = ($(this).width()-105)/2;
			$(this).find(".thumbWra").css("left",_left);
			if(_src!=""){
				$(this).mouseover(function(){$(this).addClass("on")});
				$(this).mouseout(function(){$(this).removeClass("on")});			
			}			
		});
	}
}

/////////////////招贤纳士效果

function zhaopin(){
	if($("table.zhaopin").length>0){
		$("table.zhaopin").each(function(){
			$(this).find("tr:first").each(function(){
				$(this).nextAll().hide();
				$(this).click(function(){
					$(this).nextAll().toggle();
				});
				$(this).css("cursor","pointer");
			});
		});
		//$("table.zhaopin:first").find("tr").show();
	}
}
/////////////////首页banner切换

function indBanner(){
	if($("#indBanner").length>0){
		$('#indBanner').innerfade({
				speed: 1500,
				timeout: 3500,
				type: 'sequence',
				containerheight: '285px'
			});
	}
}
/////////////////兑奖专区tab
function duijiangTab(){
	if($("#duijiangTab").length>0){
		$(".duijiangWra").eq(0).show();
		$("#duijiangTab li").each(function(i){
			$(this).click(function(){
				$("#duijiangTab li").removeClass("on");
				$(this).addClass("on");
				$(".duijiangWra").hide();
				$(".duijiangWra").eq(i).show();
			});
		});
	}
}
/////////////////精品附件放大镜效果
function jZoom(){
	if($(".jqzoom").length>0){
		$(".jqzoom").jqueryzoom({
				xzoom: 300, //zooming div default width(default width value is 200)
				yzoom: 150, //zooming div default width(default height value is 200)
				offset: 10, //zooming div default offset(default offset value is 10)
				position: "right", //zooming div position(default position value is "right")
 				preload:1,
				lens:1
			});
	}
}
//按比例缩小
function DrawImage(ImgD,W,H){ 
  var flag=false; 
  var image=new Image(); 
  image.src=ImgD.src; 
  if(image.width>0 && image.height>0){ 
    flag=true; 
    if(image.width/image.height>= W/H){ 
      if(image.width>W){
        ImgD.width=W; 
        ImgD.height=(image.height*H)/image.width; 
      }
	  else{ 
        ImgD.width=image.width;
        ImgD.height=image.height; 
      } 
      ImgD.alt= ""; 
    } 
    else{ 
      if(image.height>H){
        ImgD.height=H; 
        ImgD.width=(image.width*W)/image.height; 
      }
	  else{ 
        ImgD.width=image.width;
        ImgD.height=image.height; 
      } 
      ImgD.alt=""; 
    } 
  }
}
function subBanner(){
	if($("#subBanner2 img").length>1){
		$('#subBanner2').innerfade({
				speed: 1500,
				timeout: 3500,
				type: 'sequence',
				containerheight: '285px'
			});
	}
}
$(document).ready(subscribe);
$(document).ready(mainNav);
$(document).ready(techSpes);
$(document).ready(carList);
$(document).ready(detailTab);
$(document).ready(questionTab);
$(document).ready(questionList);
$(document).ready(extInt);
$(document).ready(extInt2);
$(document).ready(carSeries);
$(document).ready(zhaopin);
$(document).ready(indBanner);
$(document).ready(duijiangTab);
$(document).ready(jZoom);
$(document).ready(subBanner);