// JavaScript Document
//主导航菜单显示
function site_nav()
{
	$.ajax({
		type: "GET",
		url: "include/site_public_config.php",
		data: "action=get_site_nav",
		success:function(response){
			//alert(response);
			$('#Site_Nav').html(response);
		}
	}); 	
}

//下拉菜单调用
function sub_nav( Pid, Status )
{
	if(Status=="hide"){
		$("#Sub_Nav_"+Pid).hide();	
		document.getElementById("Nav_"+Pid).className='';	
	}else{
		$("#Sub_Nav_"+Pid).show();	
		document.getElementById("Nav_"+Pid).className='on';	
	}
}

//产品介绍显示
function Intro( Sorts, ProID )
{
	document.getElementById("Intro_1").className = '';	
	document.getElementById("Intro_2").className = '';	
	document.getElementById("Intro_3").className = '';	
	document.getElementById("Intro_"+Sorts).className = 'on';	
	$.ajax({
		type: "GET",
		url: "include/site_public_config.php",
		data: "action=get_Pro_Intro&ID="+ProID+"&obj="+Sorts,
		success:function(response){
			$('#Pro_Intro').html(response);
		}
	}); 	
}

function chkchkcode(n){
	if(!n){
		$("#floatmain").find(".msg").html("<strong>请输入正确的验证码！</strong>");
	}else{
		$.ajax({
			type: "POST",
			url: "ajax.php",
			data: "act=fwchkcode&code="+n,
			success:function(o){
				if(o=='false'){
					$("#floatmain").find(".msg").html("<strong>请输入正确的验证码！</strong>");
				}else{
					$("#floatmain").find(".msg").html("欢迎使用雅格丽白产品！<br />为了您的合法权益, 请使用雅格丽白正品！");
					$('#chkcodetrue').val(1);
				}
			}
		}); 	
	}
}

$(function(){
	$("#fwcxlink").bind('click',function(){
		$("#floatmain").show();	
	});
	$("#closefwcx").hover(function(){
		$(this).attr("title","关闭窗口");
	},function(){});
	$("#closefwcx").bind('click',function(){
		$("#floatmain").hide();	
		$("#fwCode").val('');
		$("#chkcodetrue").val(0);
		$("#fchkcode").val('');
		$("#floatmain").find(".msg").html("欢迎使用雅格丽白产品！<br />为了您的合法权益, 请使用雅格丽白正品！");
	});
	$("#fwreset").bind('click',function(){
		$("#fwCode").val('');
		$("#chkcodetrue").val(0);
		$("#fchkcode").val('');
		$("#floatmain").find(".msg").html("欢迎使用雅格丽白产品！<br />为了您的合法权益, 请使用雅格丽白正品！");
	});
	$("#fwsubmit").bind('click',function(){
		var fwcode = $("#fwCode").val();
		var chkcodetrue = $("#chkcodetrue").val();
		if(fwcode==""){
			$("#floatmain").find(".msg").html("<strong>请输入您的防伪码！</strong>");
			return false;	
		}
		if(chkcodetrue==0){
			$("#floatmain").find(".msg").html("<strong>请输入正确的验证码！</strong>");
			return false;	
		}
		$.ajax({
			type: "POST",
			url: "ajax.php",
			data: "act=fwchecked&fwcode="+fwcode,
			beforeSend:function(){$("#floatmain").find(".msg").html("<img src='/images/loading.gif' align='absmiddle'>&nbsp;查询中......");},
			success:function(o){
				$("#fwCode").val('');
				$("#chkcodetrue").val(0);
				$("#fchkcode").val('');
				$("#floatmain").find(".msg").html(o);
			}
		}); 	
	});
	//验证码验证
	$("#fchkcode").blur(
		function(){
			chkchkcode(this.value);
		}
	);
	$("#fchkcode").keyup(
		function(){
			var code = this.value;
			if(code.length>4){
				chkchkcode(this.value);
			}
		}
	);
	$("#fchkcode").keydown(
		function(){
			var code = this.value;
			if(code.length>4){
				chkchkcode(this.value);
			}
		}
	);
})
