﻿jQuery.ajaxSetup ({cache:false})
email_ok=function(email){return ((email.length>=5) && (email.indexOf('@',0)!=-1) && (email.indexOf('@',0) < email.length-4) && (email.indexOf('.',0)!=-1));}
jQuery(function($){
	$('a').bind('focus',function(){if(this.blur){this.blur();};});
	$('#contactform').click(function(){				  
		checkguest();
	});
	
	$('li.mm').mousemove(function(){
		$(this).find('ul.sec').show();//you can give it a speed
	});
	$('li.mm').mouseleave(function(){
		$(this).find('ul.sec').hide();
	});
	

	
});

show_sub_menu=function(id){
	$('.sub_menu_ul ul').hide();
	$('#submenu_'+id).show();
}

toggle_frame=function(i,j){
		//$(this).parent().find('a:not('+ct+')').removeClass('profile'+ct).addClass('currnt'+ct);
		
		
		$('.toggle_btn a:eq('+i+')').removeClass('profile'+i).addClass('currnt'+i);
		$('.toggle_btn a:eq('+j+')').removeClass('currnt'+j).addClass('profile'+j);
		
		$('.toggle_content .tc:eq('+j+')').hide();
		$('.toggle_content .tc:eq('+i+')').fadeIn(500);
	}



checkguest=function(){
	if ($("#yourname").val()==''){
		$('.error_tips_1').html("请填写完您的姓名后再提交！");
		$("#yourname").focus();
		return false;
		}
	if ($("#yourPhone").val()==''){
		$('.error_tips_2').html("请填写完您的电话后再提交！");
		$("#yourPhone").focus();
		return false;
		}
	if ($("#youremail").val()==''){
		$('.error_tips_3').html("请填写完您的邮箱后再提交！");
		$("#youremail").focus();
		return false;
		}else
		{
		if (!email_ok($("#youremail").val()))
		{
			$('.error_tips_3').html("对不起哦，您的邮箱格式写错啦！");
			$("#youremail").select();
			return false; 
		}
	}
	if ($("#youraddress").val()==''){
		$('.error_tips_4').html("请填写完地址后再提交！");
		$("#youraddress").focus();
		return false;
		}
	if ($("#guestcontent").val()==''){
		$('.error_tips_5').html("请填写完咨询内容后再提交！");
		$("#guestcontent").focus();
		return false;
		}
	if ($("#VerifyCode").val()==''){
		$('.error_tips_6').html("请填写验证码！");
		$("#VerifyCode").focus();
		return false;
		}
		
		$.ajax({
			type:"POST",
			url:"../../cp.asp",
			data:"act=add_guest&name="+escape($("#yourname").val())+"&phone="+escape($("#yourPhone").val())+"&email="+escape($("#youremail").val())+"&address="+escape($("#youraddress").val())+"&message="+escape($("#guestcontent").val())+"&VerifyCode="+escape($("#VerifyCode").val()),
			success:function (html) {
				$("#guestForm")[0].reset();
				document.images['validatecodeimg'].src='../../themes/asp/sys.safecode.asp?t='+Math.random();			
				if (html=='success'){
					//重置表单
					alert('感谢你的留言！我们尽快与您联系！');
				}else{
					alert(html);
					}
			}
		});

	}
	Pageback=function(step) {window.history.back(step);}
focusLoginName=function() {
	var Login_UserId=$('#Login_UserId');
	if (Login_UserId.val()=='输入email'){
		Login_UserId.val('');
		}
}
	
checkLogin=function() {
	var Login_UserId=$('#Login_UserId');
	var Login_pass=$('#Login_pass');
	if (Login_UserId.val()==''||Login_UserId.val()=='输入email'){
		$('.error_tips').html("登录账号不能为空！");
		Login_UserId.focus();
		return false;
		}else
		{
			if (!email_ok(Login_UserId.val()))
			{
				$('.error_tips').html("对不起哦，您的邮箱格式写错啦！");
				Login_UserId.select();
				return false; 
			}
		}
	if (Login_pass.val()==''){
		$('.error_tips').html("登录密码不能为空！");
		Login_pass.focus();
		return false;
		}
}

checkreg=function() {
	var reg_UserId=$('#reg_UserId');
	var reg_pass=$('#reg_pass');
	var reg_pass_1=$('#reg_pass_1');
	if (reg_UserId.val()==''){
		$('.error_tips').html("输入注册邮箱！");
		reg_UserId.focus();
		return false;
		}else
		{
			if (!email_ok(reg_UserId.val()))
			{
				$('.error_tips').html("对不起哦，您的邮箱格式写错啦！");
				reg_UserId.select();
				return false; 
			}
		}
	if (reg_pass.val()==''){
		$('.error_tips').html("登录密码不能为空！");
		reg_pass.focus();
		return false;
		}
	if (reg_pass_1.val()==''){
		$('.error_tips').html("请再输入一次密码！");
		reg_pass_1.focus();
		return false;
		}		
	if (reg_pass_1.val()!=reg_pass.val()){
		$('.error_tips').html("2次输入的密码不一致，请重新输入密码！");
		reg_pass.val('');reg_pass_1.val('');
		reg_pass.focus();
		return false;
		}		
}
checkfindpass=function() {
	var Login_UserId=$('#Login_UserId');
	if (Login_UserId.val()==''){
		$('.error_tips').html("输入注册邮箱！");
		Login_UserId.focus();
		return false;
		}else
		{
			if (!email_ok(Login_UserId.val()))
			{
				$('.error_tips').html("对不起哦，您的邮箱格式写错啦！");
				Login_UserId.select();
				return false; 
			}
		}
}
function i(ur,w,h){
        document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+w+'" height="'+h+'"> ');
        document.write('<param name="movie" value="' + ur + '">');
        document.write('<param name="quality" value="high"> ');
        document.write('<param name="wmode" value="transparent"> ');
        document.write('<param name="menu" value="false"> ');
        document.write('<embed src="' + ur + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'" wmode="transparent"></embed> ');
        document.write('</object> ');
}

