jQuery.noConflict();
jQuery(document).ready(function($){
	/****nav **/
	$(".leftbar .nav .hassub").hover(
			function(){
				 if(!$(this).hasClass("hover")){
   				    $(this).addClass("hover");
				 }
				    $(this).children(".sub").show(0);

					$(this).children(".sub").children("dl").children("dd.hassub").hover(

						function(){

							$(this).css("z-index","3");														

							$(this).children(".sub").show(0);

					     },

						function(){

							$(this).css("z-index","2");

							$(this).children(".sub").hide(0);

						}

					);



				},



			function(){



				 if($(this).hasClass("hover")){



   				    $(this).removeClass("hover");



				 }



				  $(this).children(".sub").hide(0);



				}



			);



	  $(".leftbar .nav li.com-hover").hover(



			function(){



				$(this).css("background-color","#9a9ccc");



				if(!$(this).hasClass("n-w-bg")){



				 $(this).addClass("n-w-bg");



                }







				$(this).children("a").css("color","#fff");



				},



			function(){



				$(this).css("background-color","#d8d8f2");



				if($(this).hasClass("n-w-bg")){				



				  $(this).removeClass("n-w-bg");



				}



				$(this).children("a").css("color","#65669F");				



		    }



										 );	

	 /*  CMS Page Image**/

	 //$(".content-1 img").css("float","right");



	/********apple bottom banner*****/	   



	    var sUserAgent = navigator.userAgent; 

		if(sUserAgent.indexOf("AppleWebKit") > -1 &&(sUserAgent.indexOf("KHTML") > -1 || sUserAgent.indexOf("Konqueror") > -1 || sUserAgent.indexOf("AppleWebKit") > -1)){



			 $(".footer .bannerlinks a").css("margin-right","3px");	 



		}



	/*******banner*********/    

	

	$(".main .homeright .bar h1").toggle(

			function(event){				

			/********20110706 jonathan modify *****/			

				   var countdd = $(this).parent().children(".bsub").children("dl").children("dd").size(); 			

        		   var realheight = (countdd-1)*22+14;					 

				   $(this).parent().children(".bsub").animate({ height: realheight, opacity: 'show' }, {duration: 1000});

			 },

		     function(){
                    

				   $(this).parent().children(".bsub").animate({ height:0, opacity: 'hide' }, { duration: 500 }); 	
			 }		



			);



	$(".main .homeright .bar .bsub dd.first a").click(function(){

          $(this).parent().parent().parent().animate({ height:0, opacity: 'hide' }, { duration: 500 });	

		  return false;



	 });



	



	/**** every input form, just add a  parameter "tishitext" and set the note text**/
    $("input").each(function(){
				if( $(this).attr("tishitext") && $(this).attr("tishitext").length >0 ){
					$(this).val($(this).attr("tishitext"));	
				}
				$(this).bind('focus', function() {
				    if( $(this).val() == $(this).attr("tishitext")){$(this).val('')}	
				});
				$(this).bind('blur', function() {
				    if($(this).val()=='') $(this).val($(this).attr("tishitext")) ;	
				});			 
		 });
	/********crump**********/
	$(".breadcrump a:last-child").addClass("current");
	/***************/
	 /****用法**/
	  $("#emailaddress").submit(function(){							 
				bool1 = false					 
				bool1 = $(this).check();		
				if(!bool1){
				  return bool1;
				}
				data = $(this).serializeArray();
				var post_url = $(this).attr('action');
				$("#emailaddress .f_submit input").attr('disabled','disabled');			
				$.post(post_url, data, function(result){
						$('#message-pop  #msg-content').html(result);
						$('#message-pop').show();
						$("#emailaddress").hide();
						$("#product_newsletter_form #emailaddress .f_submit input").removeAttr('disabled');
						$('#message-pop').get(0).reset();
				});
				return false;								
	  });	
	/**扩展************/
        (function($){
        $.fn.extend({
        	check:function(){
        		var bool1_t = true;  
        		var bool11_t = true;  
        		var bool2_t = true;  
        		var bool3_t = true;       		
        		$(this).find('.required-entry').each(function(){
        			v = $(this).val();
        			if(v == 'Please select message type...' || v == 'Please select...' || v == 'Enter your email address'){
							$(this).addClass('input-failed');
							bool11_t = false;
						} else {
							if(v == '' || (v == null) || (v.length == 0) || /^\s+$/.test(v)){
								$(this).addClass('input-failed');
								bool1_t = false;
							   }else{
								$(this).removeClass('input-failed');
								bool1_t = true;
							   }
							   
					   }
        		});
        		$(this).find('.required-email').each(function(){
        			v = $(this).val();
						$(this).addClass('input-failed');
						check_email = /^([a-zA-Z\.0-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('input-failed');
							bool2_t = false;
						}else{
							$(this).removeClass('input-failed');
							bool2_t = true;
						}
					
        		});
        		$(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 || v == 'What is your Driving Licenece Number?' || v == 'What is your Telephone Number?'){
        				$(this).addClass('input-failed');
        				bool3_t = false;
        			}else{
        				$(this).removeClass('input-failed');
						bool3_t = true;
        			}
        		});
        		
        		return bool1_t&&bool11_t&&bool2_t&&bool3_t;
        	},
			//中间定位
        	fixPop:function(w,h){
        		WLeft_f2   =   Math.ceil((winWidth   -   w)   /   2  );
    		    WTop_f2   =   Math.ceil((winHeight   -   h)   /   2   ); 
    			if(WTop_f2<0) WTop_f2=10;
    			$(this).css('left',WLeft_f2 + "px");
    			$(this).css('top',WTop_f2 + "px");
        	}
        })
    })(jQuery);
	
	
	
	
})




