jQuery.noConflict();         
    jQuery(document).ready(function($){ 
   									
   $("#nav7").click(function(){ // Compare Menu in Navigator

       $("#sub7").slideToggle("slow");
	});  

  $(".nav_s_li").mouseover(function(){  //  Nav sub7
                $(this).css({ background: "#D2FFC6" });
  });
   $(".nav_s_li").mouseout(function(){  //  Nav sub7
                $(this).css({ background: "#fff" });
  });
   
  $(".sub_sub_menu_a").mouseover(function(){  //  导航栏，sub_sub菜单hover效果
                $(this).css({ color: "#fff", padding:"0 0 0 30px", backgroundPosition: "0 -32px" });
  });
   $(".sub_sub_menu_a").mouseout(function(){  //  导航栏，sub_sub菜单hover效果
                $(this).css({ color: "#99BED1", padding:"0 0 0 20px", backgroundPosition: "0 0" });
  });
  $(".temp_img_open").click(function(){ // Compare Menu in Navigator   and Downloads Page      需要改成动态的
       $("#downloadsdetail" + $(this).attr("number")).show("slow");
	   $("#downloadsexpand" + $(this).attr("number")).removeClass("new-banner");
	   $("#downloadsexpand" + $(this).attr("number")).addClass("cars_closed");
	  
  });
  $(".temp_img_close").click(function(){ // Compare Menu in Navigator   and Downloads Page      需要改成动态的
       $("#downloadsdetail" + $(this).attr("number")).hide("slow");
	   $("#downloadsexpand" + $(this).attr("number")).addClass("new-banner");
	   $("#downloadsexpand" + $(this).attr("number")).removeClass("cars_closed");
  });
  $(".temp_img_open2").toggle(
		function(){ 				   
		   $("#downloadsdetailnew" + $(this).attr("number")).show("slow");
		   $("#downloadsexpandnew" + $(this).attr("number")).addClass("new-banner2");
		},
		function(){ 				   
		   $("#downloadsdetailnew" + $(this).attr("number")).hide("slow");
		   $("#downloadsexpandnew" + $(this).attr("number")).removeClass("new-banner2");
		}
  );
   /** Home Page Sliding banner **/
  var len2 = $("#idNum2 > li").length;
	$(".pre-img").attr("indexnum",parseInt(len2)-1);
	$(".slider2").css("width",eval(len2+1)*2*1024);
	$(".num").css("width",eval(len2+1)*14+10);
	var index2 = 0;
	$("#idNum2 li").mouseover(function(){
	index2 = $("#idNum2 li").index(this);
	showImg2(index2);
	});
	//next image
	$(".next-img").click(function(){
			showImg2($(this).attr("indexnum"));
			clearInterval(MyTime2);
	 })
	$(".pre-img").click(function(){
			showImg2($(this).attr("indexnum"));
			clearInterval(MyTime2);
	 })
	
	$('#idTransformView3').hover(function(){
	if(MyTime2){
	clearInterval(MyTime2);
	}
	},function(){
	MyTime2 = setInterval(function(){
	showImg2(index2);
	index2++;
	if(index2==len2){index2=0;}
	} , 4000);
	});
	
	var MyTime2 = setInterval(function(){
	showImg2(index2)
	index2++;
	if(index2==len2){index2=0;}
	} , 4000);
	function showImg2(i){
		changeindex(i,parseInt(i)+1);
		$("#idSlider2").stop(true,false).animate({left : -1024*i},800);
		$("#idNum2 li").eq(i).addClass("on").siblings().removeClass("on");
	}
	function changeindex(a,b){
		total = $("#idNum2 > li").length;
		if(b == total )b=0;
		if(a-1<0)a=total;
		$(".pre-img").attr("indexnum",a-1);
		$(".next-img").attr("indexnum",b);
	}
   //************* Bottom Small Slide Banner ************
  
var b_left2=15;//初始left
 begin_left2 = b_left2; //begin_left2 为开始移动时的left值
var img_num2 = imgages_number2;//总图片数
var img_width2 = 243; //每次移动宽度，即图片宽度
var total_long2 = -(img_width2*(img_num2-1)-begin_left2);//img_num2*img_width2;//总长度
var slide_img2 = null;  //setTimeout对象
var first_img2 = 0; //0 表示不是第一张图片，1表示第一张图片
var time_s2 = 5000; //没涨图片的间隔时间
//var no_slide = 0; //是否到达最后一张图片
var forword_click2 = 0;  // 是否点击下一张
var pre_click2 = 0;  // 是否点击前一张


function autoscroll_forward2(){

   if(begin_left2 <total_long2){ begin_left2 = b_left2; }
	 
		  $(".b_banner #small_slide").animate({ left:begin_left2+"px"},500,function(){ if(forword_click2 !=1 )begin_left2-=img_width2; forword_click2 = 0;});
	      //first_img2 =0;
		  slide_img2 = setTimeout(function(){autoscroll_forward2();},time_s2);
		   first_img2 =0;//不是第一张图片
}
function autoscroll_back2(){
	
	if(begin_left2 >b_left2){  first_img2=1;/*已到达第一张图片*/ begin_left2-=img_width2;/*因为多退了一步，所以这里要加上一步*/}
	   else { 
	           $(".b_banner #small_slide").animate({ left:begin_left2+"px"},500,function(){});
			    slide_img2 = setTimeout(function(){autoscroll_forward2();},time_s2);
			}
}
//slide_img2 = setTimeout(function(){autoscroll_forward2();},time_s2); //自动滑动
$('.b_banner #arrow_forward2').bind('click', function() {
    clearTimeout(slide_img2);
    forword_click2 = 1; //
	if(begin_left2 >=total_long2){
		begin_left2-=img_width2;
	}
	autoscroll_forward2();
    });
$('.b_banner #arrow_back2').bind('click', function() {
    clearTimeout(slide_img2);
	if(first_img2 !=1){begin_left2+=img_width2; autoscroll_back2();}

    });



/******************************/
$('#dealerlocatorform').submit(function(){
       
		bool = $(this).check();

		if(bool == false){

			return false;

		}
 });
$("#newsletter-validate-detail").submit(function(){
		
		bool = $(this).check();

		if(bool == false){

			return false;

		}
   });
$("#orderreport-form").submit(function(){
		
		bool = $(this).check();

		if(bool == false){

			return false;

		}
   });
	/**** every input form, just add classname called TISHI-INPUT**/


    var temp_text = '';
var text_a = new Array();
for(i=0;i<30;i++)text_a[i] ='';
var num_a = new Array();
for(i=0;i<30;i++)num_a[i] =1;
$('.tishi-input').focus(function(){
// if($(this).val() != '')$(this).attr("tishistr",$(this).val());//****
 if(num_a[$(this).attr("tishinum")]==1){
	 text_a[$(this).attr("tishinum")] = $(this).val();
     $(this).val('');
	num_a[$(this).attr("tishinum")] = num_a[$(this).attr("tishinum")]+1;
	
     if($(this).val()== text_a[$(this).attr("tishinum")])$(this).val(''); 
     }
if($(this).val()== text_a[$(this).attr("tishinum")])$(this).val('');
});



  $('.tishi-input').blur( function(){if($(this).val()=='')$(this).val( text_a[$(this).attr("tishinum")])});

});
	
	

    (function($){

        $.fn.extend({

        	check:function(){

        		var bool = true;

        		$(this).find('.required-entry').each(function(){

        			v = $(this).val();

        			if(v == 'Full postcode...' || v == 'Please Select The Message Type...' ||v == '' || (v == null) || (v.length == 0) || /^\s+$/.test(v)){

        				$(this).addClass('validation-failed');

        				bool = false;

        			}else{

        				$(this).removeClass('validation-failed');

        			}

        		});

        		$(this).find('.validate-email').each(function(){

        			v = $(this).val();

        			check_email = /^([a-z\.A-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/.test(v);

        			if(v == '' || (v == null) || (v.length == 0) || /^\s+$/.test(v) || !check_email){

        				$(this).addClass('validation-failed');

        				bool = false;

        			}else{

        				$(this).removeClass('validation-failed');

        			}

        		});

        		$(this).find('.validate-telephone').each(function(){

        			v = $(this).val();

        			check_telephone = /^[\d\s]+$/.test(v);

        			if(v == '' || (v == null) || (v.length == 0) || /^\s+$/.test(v) || !check_telephone){

        				$(this).addClass('validation-failed');

        				bool = false;

        			}else{

        				$(this).removeClass('validation-failed');

        			}

        		});

        		return bool;

        	}

        })

})(jQuery);
