

function oncancel(){
	$("#box2").addClass("boxhidden"); 
}

function showbox(top500_id,area_id){				
		$("#box2").removeClass("boxhidden");
		$("#top500_id").attr("value",top500_id);
		$("#area_id").attr("value",area_id);
		return true;
}

function showbox1(news_id){		
	$.get("ajax-show.php",
         { news_id:news_id },        
		 function(data){	
			var temp = data.split("*|*");			
		 	$("#newstitle").html("");
			$("#newstitle").html(temp[0]); 
			$("#showcontent").html("");
			var pic = temp[3].split(":");
			var pics="";
			for(var num = 0;num<pic.length;num++){
				pics += "<a href='pic/"+pic[num]+"' target='_blank'>"+pic[num]+"</a>";		
			}
			$("#showcontent").append(temp[1]+"<br>"+temp[2]+"<br>"+pics);
		 }
    ) 
	 $("#box2").removeClass("boxhidden");
}

		$(document).ready(function(){
			$("#button").click(function(){				
				if($("#com_name").val() == ""){
					$("#step").addClass("ferro");	
					$("#step").html("企业名称不能为空");
					return false;
				}
				
				$.post("/tpl/ajax_fw1.php",
  				{
					com_name: $("#com_name").val(),
					action: "step1"
				},
  				function(data){
					//alert(data);
					if(data == "null"){
						$("#step").addClass("ferro");	
						$("#step").html("该企业不再数据库内");
						return false;
					}else{
						//alert(data);
						$("#type1").val(data);
						$("#t_step1").hide();
						$("#t_step2").show();
					}
  				}
				);
				return true;
			});
			
			$("#step2_mobile").click(function(){
				$("#t_step2").hide();
				$("#t_step3").show();
				$("#title_step3").html("第3步、请输入注册时填写的总经理手机号码");				
				var c_way="手机号码：";
				$("#concact_step3").html(c_way);
				$(".notice1").html("手机号码");
				$("#con").val("mobile");
				return true;
			});
			
			$("#step2_email").click(function(){
				//alert($("#type1").val());
				//alert($("#con").val());
				$("#t_step2").hide();
				$("#t_step3").show();
				$("#title_step3").html("第3步、请输入注册时填写的总经理电子邮箱地址");
				var c_way="电子邮箱地址：";
				$("#concact_step3").html(c_way);
				$(".notice1").html("电子邮箱");
				$("#con").val("email");
				return true;
			});
			
			$("#step3").click(function(){
				//alert($("#contact").val());
				if($("#cor_attr").val() == ""){
					if($("#con").val() == "email"){
						var contact = "电子邮箱";
						var loadstr = "邮件正在发送中......";
					}
					else{
						var contact = "手机号码";
						var loadstr = "短信正在发送中......";
					}
					$("#title_step3").addClass("ferro");	
					$("#title_step3").html(contact+"不能为空");
					return false;
				}
				
				if($("#con").val() == "mobile" && !fucCheckNumLen($("#cor_attr").val(),11)){
					return false;
				}
				
				if($("#con").val() == "email" && !chkemail($("#cor_attr").val())){
					//alert("联系人电子邮件输入有误!");
					//document.getElementById("l_email").focus();
					$("#title_step3").addClass("ferro");	
					$("#title_step3").html("联系人电子邮件输入有误!");
					return false;
				}
				if($("#con").val() == "email"){
					var loadstr = "邮件正在发送中......";
				}else{
					var loadstr = "短信正在发送中......";
				}
				$("#loading").append(loadstr);
				$("#loading").show();				
				$.post("/tpl/ajax_fw1.php",
  				{
					cor_attr: $("#cor_attr").val(),
					con:$("#con").val(),
					com_name: $("#com_name").val(),
					action: "step3"
				},
  				function(data){
					//alert(data);
					if(data == "null"){
						$("#loading").hide();
						$("#title_step3").addClass("ferro");	
						$("#title_step3").html("输入内容与注册信息不符");
						return false;
					}else{
						//alert(data);
						$("#title_step3").addClass("mnote");	
						$("#title_step4").html(data);
						$("#t_step3").hide();
						$("#t_step4").show();
					}
  				}
				);
				return true;
				
			});
			
			$("#commendsend").click(function(){
				//alert($("#type1").val());
				//alert($("#con").val());
				if($("#receive").val() == ""){
					$("#title_receive").addClass("ferro");	
					$("#title_receive").html("接收人不能为空");
					return false;
				}
				if(!chkemail($("#receive").val())){
					//alert("联系人电子邮件输入有误!");
					//document.getElementById("l_email").focus();
					$("#title_receive").addClass("ferro");	
					$("#title_receive").html("联系人电子邮件输入有误!");
					return false;
				}
				$("#title_receive").hide();
				var loadstr = "邮件正在发送中......";
				
				$("#loading").append(loadstr);
				$("#loading").show();				
				//$.post("aa",
				$.post("/tpl/ajax_fw1.php",
  				{
					receive: $("#receive").val(),
					title:$("#title").val(),
					content: $("#content").val(),
					action: "commend"
				},
  				function(data){
					$("#loading").hide();
					alert(data);
					window.close();
					
  				}
				);
				return true;
			});
			
			
			$("#getpw").click(function(){				
				if($("#username").val() == ""){
					$("#step").addClass("ferro");	
					$("#step").html("用户名不能为空");
					return false;
				}	
				var loadstr = "系统正在检查用户名正确性......";
				
				$("#fontload").html(loadstr);
				$("#loading").show();
				$.post("/tpl/ajax_fw1.php",
  				{
					username: $("#username").val(),
					action: "getpw"
				},
  				function(data){
					//alert(data);
					if(data == "null"){
						$("#loading").hide();
						$("#step").addClass("ferro");	
						$("#step").html("该用户名不在数据库内");
						return false;
					}else{
						$("#loading").hide();
						alert(data);
						window.close();
					}
  				}
				);
				return true;
			});
						
						
		});
		

function fucCheckNumLen(ivalue,strlen){ 

	
	if(!fucCheckNUM(ivalue)){
		//alert(name+"请输入数字!");
		//document.getElementById(inputid).focus();
		$("#title_step3").addClass("erro");	
		$("#title_step3").html("手机号码请输入数字!");
		return 0;
	}
	if(ivalue.length!=strlen){
		//alert(name+"位数有误!");
		//document.getElementById(inputid).focus();
		$("#title_step3").addClass("erro");	
		$("#title_step3").html("手机号码位数有误!");
		return 0;
	}
	return 1;
	
}

function fucCheckNUM(NUM)
{
	 var i,j,strTemp;
	 strTemp="0123456789-";
	 if ( NUM.length== 0)
	  return 0;
	 for (i=0;i<NUM.length;i++)
	 {
	  j=strTemp.indexOf(NUM.charAt(i)); 
	  if (j==-1)
	  {
	  //说明有字符不是数字
	   return 0;
	  }
	 }
	 //说明是数字
	 return 1;
}

function chkemail(a)
{ 
	// a=document.getElementById(inputid).value;
	 var i=a.length;
	 var temp = a.indexOf('@');
	 var tempd = a.indexOf('.');
	 if (temp > 1) {
	  if ((i-temp) > 3){
	   
		if ((i-tempd)>0){
		 return 1;
		}
	   
	  }
	 }
	 return 0;
}
