$(document).ready(function(){
	$("a,input[type='button'],input[type='submit']").bind("focus",function(){
		if(this.blur){
			this.blur();
		};
	});	
	//main mav
	
    $(".mainNav").children("li").hover(function(){
        $(this).addClass("hover").find(".smenu").show();				        
    },function(){
        $(this).removeClass("hover").find(".smenu").hide();		
    })
	 $(".mainNav").children("li").hover(function(){
        $(this).addClass("hover").find(".smenu0").show();		       
    },function(){
        $(this).removeClass("hover").find(".smenu0").hide();
    })
	$(".smenu1,.smenu2,.smenu3").hover(function(){
		$(this).children("h3").addClass("hover");
		$(this).parent("li").addClass("hover");
	},function(){
		$(this).children("h3").removeClass("hover");
	});
	
	
		

	//search	
	var inputval=$(".inputBox input").val();
	$(".inputBox input").focus(function(){
		if($(this).val()==inputval){
			$(this).val("").removeClass("search_input_blur");
		}
	})
	.blur(function(){
		if($(this).val()==""){
			$(this).val(inputval).addClass("search_input_blur");
		}
	})
	
	//index_slide	
	$('.index_category').Scroll({
		visible:3,
		speed:500,
		next:".pic_next",
		prev:".pic_prev"
	});	
	
	
	/*side*/ 	
/*	$(".sider .title").click(function(){
			$(this).next(".side_child").slideToggle()
			.siblings(".side_child:visible").slideUp("slow");
			$(this).toggleClass("activeTitle");
			$(this).siblings(".sider .title").removeClass("activeTitle");
		});*/
		
	 $(".list .sider .title").click(function(){
		$(this).toggleClass("activeTitle").next(".side_child").slideToggle().siblings(".side_child").slideUp("slow");
        $(this).siblings(".sider .title").removeClass("activeTitle");
	});
    

	  
	$(".side_child li").hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	});
	
	/*sort*/
	$(".selectBox ul li").hover(function(){
		$(this).addClass("hover").siblings().removeClass("hover");
	});
	$(".selectBox ul").css({ visibility:"visible"});
	$(".selectBox").hover(function(){
		$(this).find('ul:first').stop().animate({height:'toggle',opacity:'toggle'},{queue:false,duration:0});
	},function(){
		$(this).find('ul:first').stop().animate({height:'toggle',opacity:'toggle'},{queue:false,duration:0});
	});


		
	/*certification_slide*/
	$(".certification .slide_main").Scroll({
		visible:4,
		next:".btn_down",
		prev:".btn_up",
		vertical:true		
	});
	$(".certification .slide_main").find("li:first").addClass("selected");
	$(".certification .slide_main li").click(function(){
		$(this).addClass("selected").siblings().removeClass("selected");													 
		$(".bigimg").find("img").attr("src",$(this).find("img").attr("src").replace("110x110","373x540"));
        return false;
    });

	
/*certification_slide*/
	$(".plant .slide_main").Scroll({
		visible:5,
		next:".pbtn_down",
		prev:".pbtn_up",
		vertical:false		
	});
	$(".plant .slide_main").find("li:first").addClass("selected");
	$(".plant .slide_main li").click(function(){
		$(this).addClass("selected").siblings().removeClass("selected");													 
		$(".bigimg").find("img").attr("src",$(this).find("img").attr("src").replace("110x110","373x540"));
        return false;
    });
	
	/*form*/
	 $("#form_validate").validate({errorClass:"error"});
    $("#send_enquiry_form").validate({errorClass:"error"});
	/*inquiry_02*/
	 $("#more_contact_type").unbind().bind('click',function(e){
            if ($("#more_contact_type_input").html()==''){
            $("#more_contact_type").attr('class','minus');
            $("#more_contact_type_input").show();
            $("#more_contact_type_input").html('<label>More options:</label><input name="more_contact_type" type="text" maxlength="100"/>');
			$("#more_contact_type").html('Hide options');
            }else{
            $("#more_contact_type").attr('class','add');
            $("#more_contact_type_input").hide();
            $("#more_contact_type_input").html('');
			$("#more_contact_type").html('More options');
            }

            return false;

            });
	/*lightbox*/
	$(".lightbox").lightbox();
	
	/*company*/
	$(".company .slide_main").Scroll({
		visible:4,
		next:".img_next",
		prev:".img_pre"		
	});
	
	
	/*news*/
	$(".news ul li").hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	})
	
	
	/*product*/
	/*product_slide*/
	$(".product .slide_main").Scroll({
		visible:4,
		next:".pbtn_next",
		prev:".pbtn_pre"
	});
	
	//inquiry_message*/
	$("#message").keyup(function(){
            	var s=$(this).val();
        		var len=s.length;
        		var last=parseInt(1000-len)>'0'?parseInt(1000-len):'0';
        		var output='<b style="color:Red">' + 1000 + '</b> characters max;<b style="color:Red">' + last + '</b> characters left.';
        		$("#textarea_spring").html('' + output + '');
        	
        	});

	
	//picture show zoom
	$("#picture").unbind().bind("mousemove", showZoom);	
	$('#picture').mouseout(function(){
		$("#zoom_image_box").hide();								
	})
	
	$(".product .slide_main").find("li:first").addClass("selected");
	$(".product .slide_main li").click(function(){
		$(this).addClass("selected").siblings().removeClass("selected");
		$(".bigimg").find("img").attr("src",$(this).find("img").attr("src").replace("60x60","300x300"));
		$(".bigimg").attr("href",$(this).find("img").attr("src").replace("_60x60",""));
		$(".imgbox").attr("href",$(this).find("img").attr("src").replace("_60x60",""));
        $("#zoom_image").css("background-image","url("+$(this).find('img').attr("src").replace("_60x60","")+")");
        return false;
    });

	//pro_tab
	/*product_pro_tab*/
	$(".pro_tab_title li").each(function(index){
		$(".pro_tab_title li:first").addClass("current")
		$(".pro_tab_box .pro_tab_content").not(":first").hide();
		$(this).click(function(){
			$(this).addClass("current").siblings().removeClass("current");
			$(".pro_tab_box div").eq(index).show().siblings().hide();
		});
	});
	$("a[name='do_show_inquiry_form']").unbind().bind('click keyup',function(e){
		//comments
		$(".pro_tab_box").find('div:first').css({display: "none"}); 
		$(".pro_tab_title li").attr("className","");
		$("div#send_inquiry").show();
		$("div#send_inquiry").css({display: "block"}); 
		$("#product_inquiry_tab").attr("className","current");		
		var targetOffset = $("div#send_inquiry").offset().top;
        $('html,body').animate({scrollTop: targetOffset}, 1000);
		return false;
	});
	//product_btn_clost
	$(".btn_close").click(function(){
		$(this).parent().hide();							   
	})
	
		
		$(".close_msg").click(function(){
			$(this).parent().hide()
		});
		
			
});
	

