﻿/**
 * JavaScript banner
 */
jQuery(function($){
	$("#priNav li.navi").hover(
	function(){
		$(this).find(".subNav").show();  
	},
	function(event){
		//$(this).find(".subNav").slideUp("fast");
		if(event.pageY < $(this).find(".subNav").offset().top){
				$(this).find(".subNav").slideUp("fast");
		}
	});
	$(".subNav").hover(
		function(){			
		}, 
		function(){
			$(this).slideUp("fast"); 
		}
	);

	
	$("#priNav li.navi li.subNav01").hover(
	function(){
		$(this).children("a").addClass("green");
		$(this).find(".subNav02").slideDown("fast");
	},
	function(){
		$(this).children("a").removeClass("green");
		$(this).find(".subNav02").slideUp("fast");
	});
	
	$("#languageWrap .current").click(function(){
		$(this).parent().find(".languageList").stop().slideDown();
		$("#searchSuggestPanel").hide();
	})
	/*$("#languageWrap .languageList li").click(function(){ 
		self = $(this);
		that =self.html(); 
		thaturl =$(this).children("a").attr("href"); 
		$("#languageWrap").find("span").html(that);				 
		$(this).parent().hide();
		window.location = thaturl;
	})*/
	/*$(document).click(function(){
		$("#languageWrap").find(".languageList").hide();
	})*/
	$(".mainWrap").click(function(){
		$("#searchSuggestPanel").hide();
	});
	
	//product menu
	$("#leftMenuBarProduct .title").click(function(){
			$(this).next(".content:first").toggle().siblings(".content").toggle();
	});
	//set height 100%;
	$(window).load(function(){
		var xHeight = 400;
		var cHeight = $(".BS-content").height();
		if(cHeight<xHeight){
			$(".BS-content").css({
				"height" : xHeight
			});
		}
	});
	
	//login textbox
		$(".regForm .wrapInput02>:input")
		.focus(function(){
			$(this).parent().addClass("wrapInput02_Cur");
			var msgWrap = $(this).closest(".field").children(".msg");
			var obj_msgok = msgWrap.children(".ok");
			if(obj_msgok.length > 0 && obj_msgok.is(":hidden")){
				//msgWrap.children(".attention").show();
			}
		})
		.blur(function(){
			$(this).parent().removeClass("wrapInput02_Cur");
			$(this).closest(".field").children(".msg").children(".attention").hide();
		});
	//flash VerifyCode
	$(".picCheckcode").click(function(){
		$(this).attr("src",'checknumber.php?' + Math.random());
	});
	$(".picCheckcode00").click(function(){
		$(this).prev().attr("src",'checknumber.php?' + Math.random());
	})
});
//check Verify code
function checkVerifyCode(A){
	if(0==A.length){
		return 1
	}else{
		if(4==A.length){
			return 0
		}
	}
	return 2
}

//image preload
function preLoadImg(url) {
	var img = new Image();
	img.src = url;
}	
// preload images
$.fn.getImage = function(url, fn){
	var img = new Image();
	img.src = url;
	if (img.complete){
		fn.call(img); 
	}
	else{
		img.onload = function(){
			fn.call(img);
			this.onload = null;
		}
	}
	return this;
}; 
