   
$(document).ready(function() { 

        $('input#username').focus( function(){
				
					this.value='';
				
			});
			$('input#email').focus( function(){
				
					this.value='';
				
			});
			
			$("#bookletcheck").toggle(function(){ $('#booklet').fadeIn('slow');},function(){$('#booklet').fadeOut('slow'); });
            $("#onlineorder").toggle(function(){ $('#order').fadeIn('slow');},function(){$('#order').fadeOut('slow'); });
			$("#tryout").toggle(function(){ $('#tryout2').fadeIn('slow');},function(){$('#tryout2').fadeOut('slow'); });
			$("#register").toggle(function(){ $('#register3').fadeIn('slow');},function(){$('#register3').fadeOut('slow'); });
			
			
			
    var options = { 
        target:        '#output1',   // target element(s) to be updated with server response 
        beforeSubmit:  validate,  // pre-submit callback 
        success:       showResponse  // post-submit callback 
 
        // other available options: 
        //url:       url         // override for form's 'action' attribute 
        //type:      type        // 'get' or 'post', override for form's 'method' attribute 
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
        //clearForm: true        // clear all form fields after successful submit 
        //resetForm: true        // reset the form after successful submit 
 
        // $.ajax options can be used here too, for example: 
        //timeout:   3000 
		

    }; 
	 
 
 
    // bind to the form's submit event 
    $('#myForm').submit(function() { 
        // inside event callbacks 'this' is the DOM element so we first 
        // wrap it in a jQuery object and then invoke ajaxSubmit 
        $(this).ajaxSubmit(options);  
        // !!! Important !!! 
        // always return false to prevent standard browser submit and page navigation 
        return false; 		
    }); 
	
}); 
 
// pre-submit callback 
  
// post-submit callback 
function showResponse()  { 
$('#output1').animate({opacity: 1.0}, 3000)
    .fadeOut('slow', function() {
      $(this).remove();
    }); 
  $('#myForm').resetForm();    
} 
function validate(formData, jqForm, options) { 
    // fieldValue is a Form Plugin method that can be invoked to find the 
    // current value of a field 
    // 
    // To validate, we can capture the values of both the username and password 
    // fields and return true only if both evaluate to true 
    var _isEmail=true;
    var usernameValue = $('input[@name=username]').fieldValue(); 
    var emailValue = $('input[@name=email]').fieldValue(); 
	var at_pos=emailValue[0].indexOf("@"); 
    var dot_pos=emailValue[0].lastIndexOf(".");
	if((at_pos>0&&at_pos<emailValue[0].length-4&&dot_pos>0&&dot_pos>at_pos+1&&emailValue[0].charAt(at_pos+1)!="."&&dot_pos<emailValue[0].length-2    )){
	_isEmail = true	
	}else{
	_isEmail = false	
	}  
 	 if(emailValue[0].length == 11){
	_isEmail = true	
	} ; 
    // usernameValue and passwordValue are arrays but we can do simple 
    // "not" tests to see if the arrays are empty 
   if (usernameValue[0] && _isEmail) { 	   
    } else{
       alert('请填写正确的姓名以及EMAIL地址');    
        return false; 
	}
	$('#output1').fadeIn('slow')
    $('#output1').html('提交....')
   
}



  function   check(obj) {  
  {   
  var   filter=/^\d*$/;   
  if(filter.test(obj.value))return   true;   
  else   
  {   
  alert("要求是输入数字");   
  obj.value='';   
  return   false;   
  }   
  }   
  }   






function checkForm() { 
var username=document.repairform.reusername.value;
var carno=document.repairform.reusername.value;
var tele=document.repairform.tele.value;
var type=document.repairform.type.value;
var miles=document.repairform.miles.value;
var repaircontent=document.repairform.repaircontent.value;
if(username==""){

alert("姓名不能为空");

a=false;

}else{

a=true

}


if(type==""){

alert("车牌号不能为空");

b=false;

}else{

b=true

}

if(tele==""){

alert("电话号码不能为空");

c=false;

}else{

c=true

}

if(type==""){

alert("汽车型号不能为空");

d=false;

}else{

d=true

}

if(miles==""){

alert("汽车型号不能为空");

e=false;

}else{

e=true

}

if(repaircontent==""){

alert("预约内容不能为空");

f=false;

}else{

f=true

}

if(a&&b&&c&&d&&e&&f){

document.repairform.submit();

}else{


}
}




function roll(img_name1, img_src1)
   {
   document[img_name1].src = img_src1;
  
   }




function checkcontact() { 
var username=document.contactForm.contact_username.value;
var tele=document.contactForm.mp.value;
var email=document.contactForm.email
_isEmpty = false;
at_pos=email.value.indexOf("@") 
dot_pos=email.value.lastIndexOf(".")
address=email.value

if(username==""){
alert("姓名不能为空");
a=false;
}else{
a=true
}

if((at_pos>0&&at_pos<address.length-4&&dot_pos>0&&dot_pos>at_pos+1&&address.charAt(at_pos+1)!="."&&dot_pos<address.length-2)){
	_isEmpty = true	
		}else{
		_isEmpty =false;
		alert("请填写正确的邮件地址");
		email.focus();
		}
	

if(tele=="" || tele.length !=11){
alert("请填写正确的手机号码");
b=false;
}else{
b=true
}

if(a&&b&&_isEmpty){

document.contactForm.submit();

}

}





function checkdemandForm() { 
var username=document.demandForm.seusername.value;
var gender=document.demandForm.gender.value;
var mp=document.demandForm.mp.value;
var age=document.demandForm.age.value;
var location=document.demandForm.location.value;
var city=document.demandForm.city.value;
var address=document.demandForm.address.value;
var postcode=document.demandForm.postcode.value;
var email=document.demandForm.email.value;
var nowcarbuy=document.demandForm.nowcarbuy.value;
var nowcarbu=document.demandForm.nowcarbu.value;


if(username==""){
alert("姓名不能为空");
a=false;
}else{
a=true;
}

if(gender==""){
alert("性别不能为空");
b=false;
}else{
b=true;
}


if(mp=="" || mp.length>11){
alert("请填写正确的手机");
d=false;
}else{
d=true;
}

if(age==""){
alert("请填写年龄");
e=false;
}else{
e=true;
}

if(location==""){
alert("请填写省市");
f=false;
}else{
f=true;
}



if(city==""){
alert("请填写城市");
h=false;
}else{
h=true;
}






if(address==""){
alert("请填写地址");
i=false;
}else{
i=true;
}





if(postcode==""){
alert("请填写邮编");
j=false;
}else{
j=true;
}


at_pos=email.indexOf("@") ;
dot_pos=email.lastIndexOf(".");
address=email;
if((at_pos>0&&at_pos<address.length-4&&dot_pos>0&&dot_pos>at_pos+1&&address.charAt(at_pos+1)!="."&&dot_pos<address.length-2)){
	_isEmpty = true;	
		}else
{
		_isEmpty = false;
		alert("请填写正确的邮件地址");
		email.focus();
		}
	


if(nowcarbuy==""){
alert("请填写新车购买时间");
k=false;
}else{
k=true;
}

if(nowcarbu==""){
alert("请填写新车购买预算");
l=false;
}else{
l=true;
}


if(a && b && d &&e && f && h && i && j && k && l && _isEmpty  ){

document.demandForm.submit();

}

}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}