///******************************************************    
///	FileName: CompanyShow.js
///	Action: 后台公司页面JS处理文件
///	Copyright(c)  2004-2008 网胜科技公司技术开发部
///	Writer: XFY
///	Create Date: 2008-12-17
///	Rewriter:
///	Rewrite Date:
///****************************************************** 
var rightIcon="../../../images/websen.gif"
var txtjbo=new  Array("txtCompanyName","txtCapital","txtRegisterAddress","txtDealinAdd","txtPostalcode","txtProduct","txtIndustry","txtStreet","txtURL","txtCorporate")

function ChkInfo(num)
{
obj = "txt"+num;
value = getobj(txtjbo[num]).value;	// 获取文本框的值
switch (num)
{
case "0"://公司名称
if (value=="")
{
document.getElementById(obj).innerHTML =GsBc[num];
return false;
} 
else
document.getElementById(obj).innerHTML =""
break;

case "1"://注册资本
if(value=="")
{ 
document.getElementById(obj).innerHTML = GsBc[num];
return false;
}
else if(! isNumber(this.value))
{
document.getElementById(obj).innerHTML = GsBc[11];
return false;
}
else
document.getElementById(obj).innerHTML=""
break;

case "2"://注册地址
if (value=="")
{
document.getElementById(obj).innerHTML = GsBc[num];
return false;
}
else
document.getElementById(obj).innerHTML = "";
break;

case "3"://主要经营地址
if(value=="")
{
document.getElementById(obj).innerHTML = GsBc[num];
return false;
}
else
document.getElementById(obj).innerHTML = "";
break;

case "4":  //邮政编码
if (value=="")
{ 
document.getElementById(obj).innerHTML = GsBc[num];
return false;
}
else if(! isNumber(this.value))
{
document.getElementById(obj).innerHTML = GsBc[11];
return false;
}
else if(!isPostalCode (value))
{
document.getElementById(obj).innerHTML =GsBc[12];
return false; 
}
else
document.getElementById(obj).innerHTML = "";
break;

case "5"://主营产品
if (value=="")
{
document.getElementById(obj).innerHTML = GsBc[num];
return false; 
}
else
document.getElementById(obj).innerHTML = "";
break;  

case "6":// 主营行业
if (value=="")
{
document.getElementById(obj).innerHTML = GsBc[num];
return false;
} 
else
document.getElementById(obj).innerHTML="";
break;

case "7":// 街道地址
if (value=="")
{
document.getElementById(obj).innerHTML = GsBc[num];
return false;
}
else
document.getElementById(obj).innerHTML = "";
break;

case "8"://公司网址
var re="[a-zA-z]+://[^\s]*";  
if(value=="")
{
document.getElementById(obj).innerHTML = GsBc[num];
return false;
}
else
document.getElementById(obj).innerHTML = "";
break;

case "9": 
if(value=="")//法人代表
{
document.getElementById(obj).innerHTML = GsBc[num];
return false;
}else
document.getElementById(obj).innerHTML = "";
break;
}

}



function $(id)
{  
return document.getElementById(id)
}
function getobj(objName)
{
if($) 
return eval('$("'+ objName +'")');
else 
return eval('document.all["'+ objName +'"]');
}



$(txtjbo[0]).onchange =function  a(){
ChkInfo("0");
}
$(txtjbo[1]).onchange =function  b(){
ChkInfo("1");
}
$(txtjbo[2]).onchange=function   c(){
ChkInfo("2");
}
$(txtjbo[3]).onchange=function   d(){
ChkInfo("3");
}
$(txtjbo[4]).onchange=function   e(){
ChkInfo("4");
}
$(txtjbo[5]).onchange=function   f(){
ChkInfo("5");
}
$(txtjbo[6]).onchange=function   g(){
ChkInfo("6");
}
$(txtjbo[7]).onchange=function   k(){
ChkInfo("7");
}
$(txtjbo[8]).onchange=function   l(){
ChkInfo("8");
}
$(txtjbo[9]).onchange=function   i(){
ChkInfo("9");
}





$("btnServer").onclick=function Server(){
var  k = new Array();
var arr = new Array();
for(var i=0;i<10;i++)
{
obj="txt"+i
k[i]= getobj(txtjbo[i]).value;
if (k[i]=="")
{
document.getElementById(obj).innerHTML=GsBc[i];
arr=1
}
}
if(arr==1)
return false;
else if(! isNumber(getobj(txtjbo[1]).value))
{
document.getElementById("txt1").innerHTML =GsBc[11];
return false;
}
else if (! isNumber(getobj(txtjbo[4]).value))
{
document.getElementById("txt4").innerHTML =GsBc[11];
return false;
}
else if(!isPostalCode (getobj(txtjbo[4]).value))
{
document.getElementById("txt4").innerHTML =GsBc[12];
}
else
{
return true;
}
}

//地区
$("country").onchange=function country()
{diqu(this);}
function diqu(list) //地区样式 
{
if (list.options[list.selectedIndex].value != "中国") {
$("province").selectedIndex = 0;
$("city").selectedIndex = 0;
$("county").selectedIndex = 0;
$("province").style.display = 'none';
$("city").style.display = 'none';
$("county").style.display = 'none';
} 
else 
{
$("province").style.display = '';
$("city").style.display = '';
$("county").style.display = '';
}
}
//公司信息 保存显示文字
var  GsBc=new Array(12);
GsBc[0]="<img src="+rightIcon+" align=\"absmiddle\"> <font color=#FF0000>公司名不能为空</font>";
GsBc[1]="<img src="+rightIcon+" align=\"absmiddle\"> <font color=#FF0000>注册资本不能为空</font>";
GsBc[2]="<img src="+rightIcon+" align=\"absmiddle\"> <font color=#FF0000>注册地址不能为空</font>";
GsBc[3]="<img src="+rightIcon+" align=\"absmiddle\"> <font color=#FF0000>主要经营地址不能为空</font>";
GsBc[4]="<img src="+rightIcon+" align=\"absmiddle\"> <font color=#FF0000>邮政编码不能为空</font>";
GsBc[5]="<img src="+rightIcon+" align=\"absmiddle\"> <font color=#FF0000>主营产品不能为空</font>";
GsBc[6]="<img src="+rightIcon+" align=\"absmiddle\"> <font color=#FF0000> 主营行业不能为空</font>";
GsBc[7]="<img src="+rightIcon+" align=\"absmiddle\"> <font color=#FF0000> 街道地址不能为空</font>";
GsBc[8]="<img src="+rightIcon+" align=\"absmiddle\"> <font color=#FF0000> 公司网址不能为空</font>";
GsBc[9]="<img src="+rightIcon+" align=\"absmiddle\"> <font color=#FF0000> 法人代表不能为空</font>";
GsBc[10]="<img src="+rightIcon+" align=\"absmiddle\"> <font color=#FF0000> 公司简介不能为空</font>";
GsBc[11]="<img src="+rightIcon+" align=\"absmiddle\"> <font color=#FF0000>请输入数字</font>";
GsBc[12]="<img src="+rightIcon+" align=\"absmiddle\"> <font color=#FF0000>输入不符和规范</font>";
