// JavaScript Document
var a1 = parseInt(Math.random()*10);
var b1 = parseInt(Math.random()*10);
$(function(){   
	 /**
		* Customer Enter His Requirements Funtion 
		* @ author zhaiyu
		* @ date 2009.11.21
		* click the button id is ReqBill to show a form to fill customers requirements 
		* after user submit it this form hidden
		*/  
		$(".jqidefaultbutton").click(function(){
					 
					var t1 = $.trim($('#top_username').val()); 
					var t2 = $.trim($('#top_tel').val()); 
					var t4 = $.trim($('#top_company').val());
					var t5 = $.trim($('#top_intention').val()); 
					var t6 = $.trim($('#top_content').val()); 
					var t7 = $("input:checked").val();  
					var otherway = $.trim($('.otherway').val()); 
					var t8 = $.trim($('#top_checkcode').val()); 
					     
					if(t1 == "" || t1.length==0){
								$('#top_username').css("border","solid red 1px");
								return false;
					}else{
								$('#top_username').css("border","solid #bebebe 1px");
					}
					
					if(t2 == ""|| t2.length<8 || isNaN(t2)){
								$('#top_tel').css("border","solid red 1px");
								return false;
					}else{
								$('#top_tel').css("border","solid #bebebe 1px");
					}
					  
					if(t4 == ""|| t4.length==0){
								$('#top_company').css("border","solid red 1px");
								return false;
					}else{
								$('#top_company').css("border","solid #bebebe 1px");
					}
					
					if(t5 == ""|| t5.length==0 ||t5=="+ 请您选择您目前遇到的情况"){
								$('#top_intentionwrap').css("border","solid red 1px");
								return false;
					}else{
								$('#top_intentionwrap').css("border","solid #bebebe 1px");
					}
					
					if(t6 == ""|| t6.length==0){
								$('#top_content').css("border","solid red 1px");
								return false;
					}else{
								$('#top_content').css("border","solid #bebebe 1px");
					} 
					
					if(t7 =="" || t7==undefined){   
							if(otherway=="" || otherway.length==0){  
								$('#top_findme').css({"border":"1px solid red","border-bottom":"none"}); 
								$('#top_findme2').css({"border":"1px solid red","border-top":"none"}); 
								
								return false;
							}else{ 
								$('#top_findme').css("border","none");
								$('#top_findme2').css("border","none"); 
							}
					}else{  
								$('#top_findme').css("border","none");
								$('#top_findme2').css("border","none");
					} 
					 
					if(t8 ==""|| t8.length==0 || isNaN(t8)){ 
								$('#top_checkcode').css("border","1px solid red"); 
								return false;
					}else{  
								if(t8==(a1+b1)){
								$('#checkcode').css("border","solid #bebebe 1px");
								}else{
								$('#checkcode').css("border","solid red 1px");	
								return false;
								}
					}
					  
					$(".jqidefaultbutton").submit(); 
					$(".jqidefaultbutton").addClass("hidden");
		});
		
		$(".jqiclose > a").click(function(){ 
			$("#jqibox").addClass("hidden");
		});
		
		$(".ReqBill").click(function(){  
				$("#jqibox").removeClass("hidden");
		});
		
}); 