$(document).ready(function(){
	 /* all=============all */
	 
		//outline
	$(".thumbnail a,.productInfo .btn_addnew,#logo a,.footer-nav a ").bind("focus",function(){
		if(this.blur){
			this.blur();
		};
	});	
	
		//validate
	$("#form_validate").validate({
        errorClass: 'error'
    });	
	
	$("a.lightbox").lightBox();
	
		//form input foucs
	$(".forms input,.forms .input_text,.forms .text,.forms textarea").focusin(function() {
  	$(this).addClass("input_focus");
	});
	$(".forms input,.forms .input_text,.forms .text,.forms  textarea").focusout(function() {
  	$(this).removeClass("input_focus");
	});
	
		//btn hover
	$(".btn-submit").hover(function(){
		$(this).addClass("btn-submit-hover");	
	},function(){
		$(this).removeClass("btn-submit-hover");
	});
	
	$("#JS_btnSend").hover(function(){
		$(this).addClass("btn-send-hover");	
	},function(){
		$(this).removeClass("btn-send-hover");
	});
	
	$("#JS_btnAdd").hover(function(){
		$(this).addClass("btn-add-hover");	
	},function(){
		$(this).removeClass("btn-add-hover");
	});
	
	$("#JS_btnEnter").hover(function(){
		$(this).addClass("btn-enter-hover");	
	},function(){
		$(this).removeClass("btn-enter-hover");
	});
	
	$(".JS_btnMakeInquiry").hover(function(){
		$(this).addClass("btn-make-inquiry-hover");	
	},function(){
		$(this).removeClass("btn-make-inquiry-hover");
	});
	
	$(".JS_btnMakeInquiryAll").hover(function(){
		$(this).addClass("btn-make-inquiry-all-hover");	
	},function(){
		$(this).removeClass("btn-make-inquiry-all-hover");
	});
	
	
		//remind_close
	$(".remind_close").click(function(){
		$(this).parent(".remind").hide();
	});
	
		//popoUp close
	$(".popoUp .btn_close").click(function(){
		$(this).parent(".popoUp").hide();
	});
	$(".popoUp .btn_close").hover(function(){
		 $(this).addClass("btn_close_hover");
	},function(){
		$(this).removeClass("btn_close_hover");		
	});
	
	/*header====header*/
	$(".JS_navItem").hover(function(){
		_li=this;
		time_sub_hover = setTimeout(function(){
			$(_li).addClass("hover");
			$(_li).find(".JS_navSub").show();
		},120);
	},function(){
		_li=this;
		clearTimeout(time_sub_hover);
		$(_li).removeClass("hover");
		$(_li).children(".JS_navSub").hide();	
	}); 
	
		//language hover

 	var timeLanguageHover,timeLanguageOut;
	$(".header-language-inner").hover(function(){	
		clearTimeout(timeLanguageOut);
		timeLanguageHover = setTimeout(function(){
			$("ul.language-down").slideDown(100);
/*			$(".currency_main").addClass('currency_main_on')*/
		},300)	
	},function(){
		clearTimeout(timeLanguageHover);
		timeLanguageOut = setTimeout(function(){
			$("ul.language-down").slideUp(100);
/*			$(".currency_main").removeClass('currency_main_on')*/
		},300)
	}); 
	
	/*index page===========index page*/
	//homenews carousel 
	$("#JS_homeNewsList").carousel({
			btnNext: "#JS_homeNewsNext",
			btnPrev: "#JS_homeNewsPrev",
			scrolls: 1,
			mouseWheel: false,
			circular: true,
			auto: true,
			vertical: true,
			onMouse: true,
			auto: 3000,
			speed: 1000,
			visible: 1
 	});
	
		//homepro switch
	$('#JS_homeSwitch').switchboxaction({Time:5000,SwitchTime:3000,switchindex:'#JS_homeSwitchTriggers',onclass:'current',SwitchMode:'Click',SwitchBox:'div',AutoStart:true,SwitchEffect:'fadeOut'});
	
		//promo
	$("#JS_promo a").addClass("bigimg");
	$("#JS_promo .bigimg img").banner_thaw({
		thumbObj:"#JS_promo ul li",
		thumbNowClass:"current",
		changeTime:5000
	});
	
	$("#JS_promoTriggers li:first").addClass("first")
	$("#JS_promoTriggers li:last").addClass("last")
	

	/*list page=========list page*/
	
		//side-category
	$(".JS_sideCategoryItem").hover(function(){
		$(this).addClass("side-category-item-hover");
	},function(){
		$(this).removeClass("side-category-item-hover");
	})
	.click(function(){
		_this = $(this);
		if(_this.next(".side-category-sub").find(".side-category-sub-list").length > 0){		
			_this.toggleClass("side-category-item-selected").next(".side-category-sub").slideToggle("slow").siblings(".side-category-sub").slideUp("slow");
			_this.siblings(".JS_sideCategoryItem").removeClass("side-category-item-selected");
			return false;
		}else{};
	});
	
	$(".side-service-item").hover(function(){
		$(this).addClass("side-service-item-hover");								   
	},function(){
		$(this).removeClass("side-service-item-hover");	
	});
	
		//filter	
	var timeFilterHover;
	$(".filter-select").hover(function(){
		_this = $(this);
		timeFilterHover = setTimeout(function(){
			_this.find(".select-list").show().parents(".filter-item").siblings().find(".select-list").hide()
		},100);
	},function(){
		_this = $(this);
		clearTimeout(timeFilterHover);
		_this.find(".select-list").hide();
	});
	

	
	
	/*product page==========product page*/
		//gallery
	$(".zoom").zoom({
		xzoom: 300,
		yzoom: 300,
		offsetTop: 0,
		offset: 10,
		lens:1
	});
	var small_img = 40;
	var mid_img = 300;
	$(".thumbnail ul li:first").addClass("hover");
	var thumbTimeHover,thumbTimeOut;
	$(".thumbnail ul li").hover(function(){
		var _this=$(this);
		clearTimeout(thumbTimeOut);
		thumbTimeHover = setTimeout(function(){
			_this.addClass("hover").siblings().removeClass("hover");
			$("#picture").attr("src",_this.find('img').attr("src").replace(small_img + "x" + small_img,mid_img + "x" + mid_img));
			$("#picture").parent(".picbox").attr("href",_this.find('img').attr("src").replace("_" + small_img + "x" + small_img,""));
		},150);
    },function(){
		var _this=$(this);
		clearTimeout(thumbTimeHover);
    });
	$(".thumbnail ul li").click(function(){
		return false;
	})

		//send inquiry
	$("#JS_btnSend").click(function(){
		offsetTop=$("#detail").offset().top;
		$("html,body").animate({scrollTop:offsetTop},300);
		$("#JS_sendInquiryTab").click();
		return false;
	})
	
	$("#JS_btnAdd").click(function(){
		$(this).hide();
		$("#JS_btnEnter").css({"display":"block"});
	});
	
		//comments
	$("a[name='do_show_review_form']").unbind().bind('click keyup',function(e){
		$("#detail").find('.tab-content > div:first').css({display: "none"}); 
		$("#detail .tab-holder li").attr("className","");
		$("div.sendInquiry").show();
		$("div.sendInquiry").css({display: "block"}); 
		$("#detail #sendInquiry_tab").attr("className","current");		
		var targetOffset = $("div.sendInquiry").offset().top;
        $('html,body').animate({scrollTop: targetOffset}, 1000);
		return false;
	});
	
		//tips_inquiry close
	$(".tips_inquiryadd .btn_close").click(function(){
		$(this).parent(".tips_inquiryadd").hide();
	});
	
		//detail tab
	$(".JS_tabHolder > li").each(function(index){
		$(".JS_tabHolder > li:first").addClass("current");
		$(".JS_tabContent .JS_tabPanel:first").show();
		$(this).click(function(){
			var _this=this;
			$(_this).addClass("current").siblings().removeClass("current");
			$(_this).parent(".JS_tabHolder").siblings(".JS_tabContent").find(".JS_tabPanel").eq(index).show().siblings().hide();
		})
	});
	 if(location.hash=="#specifications"){
        $(".JS_tabContent .JS_tabPanel:eq(1)").show();
	    $(".JS_tabContent .JS_tabPanel:eq(0)").hide();
        $(".JS_tabHolder > li:eq(0)").removeClass("current");
		$(".JS_tabHolder > li:eq(1)").addClass("current");
	}
	
	//about slide
	var aboutThumbItem = $("#JS_thumbnailSlide .list-item");
	if(aboutThumbItem.length > 0){
		$("#JS_thumbnailSlide").carousel({
			btnNext:"#JS_thumbnailNext",
			btnPrev:"#JS_thumbnailPrev",
			scrolls:1,
			mouseWheel: true,
			circular: false,
			visible:4
		}).mousewheel(function(){
			return false;
		});
	};
	
	//change picture
/* 	var about_small_img = 50;
	var about_mid_img = 300; */
	aboutThumbItem.first().addClass("hover");
	var about_thumbTimeHover;
	aboutThumbItem.hover(function(){
		var _this=$(this);
		about_thumbTimeHover = setTimeout(function(){
			_this.addClass("hover").siblings().removeClass("hover");
			$("#about-picture").attr("src",_this.find('img').attr("src"));
			$("#about-picture").attr("big",_this.find('img').attr("src"));
		},150)
    },function(){
		var _this=$(this);
		clearTimeout(about_thumbTimeHover);
    })
	.click(function(){
		return false;
	});

		//inquiry_fill
	$("#JS_inquiryInfoTitle").click(function(){
		$(this).toggleClass("inquiry_info_hide");
		$(this).parent(".hd").siblings(".bd").slideToggle(100);
		return false;
	});
	$(".inquiry_fill .btnMoreoption").click(function(){
		$(this).toggleClass("btnMoreoptionHide");
		if($(this).text()=="More options"){
			$(this).text("Hide options");
		}else{
			$(this).text("More options");
		}
		$(".inquiry_fill .moreoptions").slideToggle(100);
		return false;
	})

	
	/* -----------------------------------------------------------------
	 * certification slide
	 * certification small-big 
	*/
	//cert slide1
	$("#JS_certSlide").carousel({
			btnNext: "#JS_certNext",
			btnPrev: "#JS_certPrev",
			scrolls: 1,
			mouseWheel: false,
			circular: false,
			vertical: true,
			visible: 4
 	});
	
/*	var cert_small_img = 50;
	var cert_mid_img = 300;	*/
	var certThumbItem = $("#JS_certSlide .list-item");
	certThumbItem.first().addClass("hover");
	var cert_thumbTimeHover;
	certThumbItem.hover(function(){
		var _this=$(this);
		cert_thumbTimeHover = setTimeout(function(){
			_this.addClass("hover").siblings().removeClass("hover");
			$("#cert-picture").attr("src",_this.find('img').attr("src"));
			$("#cert-picture").attr("big",_this.find('img').attr("src"));
		},150)
    },function(){
		var _this=$(this);
		clearTimeout(cert_thumbTimeHover);
    })
	.click(function(){
		return false;
	});
		
	/* end -------------------------------------- end */

})


