// JavaScript Document  2008.4.22 by 郭娟
window.onload = loads;
var ParName = null;//家长姓名
//var ParSex = "";//家长性别
var Name = null; //学生姓名
var Sex = ""; //学生性别
var Phone = null;  //手机
var areacode = null; //区号
var Tel = null;//电话
var Grade = null;//年级
var SchName = null;  //学校
//var SchType = null; //学校类型
var StuType = null;//学习类型
//var Study = null;//学习状况
//var StuQue = null;//学习问题
var no2 = null;//学科
var nation = null;//省
var prov = null;//市
var areas = null;//区

function loads()
{	
	ParName = document.getElementById('ParName');
	Name = document.getElementById('Name');
	areacode = document.getElementById('areacode');
	Phone = document.getElementById('Phone');
	Tel = document.getElementById('Tel');
	Grade = document.getElementById('Grade');
	SchName = document.getElementById('SchName');
	//SchType = document.getElementById('SchType');
	StuType = document.getElementById('StuType');
	//Study = document.getElementById('Study');
	//StuQue = document.getElementById('StuQue');
	no2 = document.getElementById('no2val');	
	nation = document.getElementById('nation');
	prov = document.getElementById('prov');
	areas = document.getElementById('areas');
}

//开始提交并检测输入的有效性
function btn_ok()
{
	//alert(no2.value);
	//if(ParName.value=="")
	//{
	//   alert('请输入家长姓名');
	//   ParName.focus();
	 //  return false;
	//}
	/*var radio_num1 =  document.form1.ParSex;
	for(k=0;k<radio_num1.length;k++)
	{
		if(radio_num1[k].checked)
		{
		 ParSex=radio_num1[k].value;
		}
	}*/
	var tecmode =  document.form1.Sex;
	for(k=0;k<tecmode.length;k++)
	{
		if(tecmode[k].checked)
		{
		  Sex=tecmode[k].value;
		}
	}
	
	if(Name.value=="")
	{
	   alert('请输入学生姓名');
	   Name.focus();
	   return false;
	}
	
	if(!/^[0-9]{11,12}$/.exec(Phone.value))		
	{
	   alert('手机号码为11位，且必须是数字，请输入正确的手机号码！');
	   Phone.focus();
       return false;
	}
	
	if(!/^[0-9]{3,4}$/.exec(areacode.value))	
	{
	   alert('区号为3位或4位，且必须是数字，请输入正确的区码！');
	   areacode.focus();
       return false;
	}
	
	if(!/^[0-9]{7,8}$/.exec(Tel.value))		
	{
	   alert('电话号码为7位或8位，且必须是数字，请输入正确的电话号码！');
	   Tel.focus();
       return false;
	}
    
   // if(Grade.value=="")
	//{
	//   alert('年级必须填写！');
	//   Grade.focus();
	 //  return false;
	//}

  //if(SchName.value=="")
	//{
	//   alert('学校必须填写！');
	//   SchName.focus();
	//   return false;
	//}
	
	//if(SchType.value == 0)
	//{
	//   alert('请选择学校类型！');
	//   SchType.focus();
	//   return false;
	//}
	
	//if(StuType.value == 0)
	//{
	//   alert('请选择学习类型！');
	//   StuType.focus();
	 //  return false;
	//}
	
	//if(Study.value == "")
	//{
	//   alert('请填写学习情况！');
	//   Study.focus();
	//   return false;
	//}
	
	//if(StuQue.value == "")
	//{
	//   alert('请填写学习问题！');
	//   StuQue.focus();
	//   return false;
	//}
	
	if(prov.value=="")
	{
	   alert('请选择城市！');
	   prov.focus();
       return false;
	}
	
xajax_stu(ParName.value,Name.value,Sex,Phone.value,areacode.value,Tel.value,Grade.value,nation.value,prov.value,areas.value,SchName.value,StuType.value,no2.value);	
}



function Add1(ObjSource,ObjTarget)
{
	var t=0;
	for(var i=0;i<ObjSource.length;i++)
	{

		if(ObjSource.options[i].selected && ObjTarget.length<3  )
		{
			for(var k=0;k<ObjTarget.length;k++)
			{
				if(NolVal7()+"-"+ObjSource.options[i].value==ObjTarget.options[k].value)
				{
					t=1;
				}
			}
			if(t==0)
			{
				var opt=document.createElement('OPTION');
				ObjTarget.add(opt);
				opt.value=NolVal7()+"-"+ObjSource.options[i].value;
				if(ObjSource == document.all.no21)
				opt.text=No1Val()+ObjSource.options[i].text;
			}
		}
	}
}


function delNo4()
{
	var no41 = document.getElementById('No41');
	for(var i=0;i<no41.length;i++)
	{
		if(no41[i].selected)
		{
			no41.options.removeChild(no41.options[i--]);
		}
	}
}

//算No1的选择

function No1Val()
{
	var no11 = document.getElementById('no11');
	for(var i=0;i<no11.length;i++)
	{
		if(no11[i].selected)
		return no11[i].text;
	}
}

function NolVal7()
{
	var no11 = document.getElementById('no11');
	for(var i=0;i<no11.length;i++)
	{
		if(no11[i].selected)
		{
			if(no11[i].value!=0)
			return no11[i].value;
		}
	}
}
function addOption(SelectName,val,text)
{
	var opt = document.createElement('OPTION');
	SelectName.add(opt);
	opt.value = val;
	opt.text = text;
}


function arr(SelectName,num)
{
	for(var i=0;i<SelectName.length;i++)
	{
		SelectName.options.removeChild(SelectName.options[i--]);
	}
	var no2 = document.getElementById('no21');
	var data = new Array();
	data[0]= new Array("语文","数学","英语","奥数","华数","作文","剑桥英语","新概念英语","朗文英语","信息科学","社会","语文","数学","英语","科学","俄语","地理","生物","历史","政治","语文","数学","英语","物理","化学","俄语","历史","地理","政治","生物","文综","理综","雕塑","摄影","书法","美术","吉它","手风琴","电子琴","小(大)提琴","古筝","钢琴","其它西洋乐器","其它民族乐器","象棋","围棋","体育","心理咨询","基本操作","网页设计制作","应用能力中级","图象处理软件","动画制作","程序设计","数据库");
	data[1]=new Array("13","14","15","37","38","39","41","42","43","57","58","13","14","15","40","56","19","21","18","20","13","14","15","16","17","56","18","19","20","21","22","23","24","25","26","44","27","28","29","30","31","32","33","34","35","45","59","47","49","50","51","52","53","54","55");

	if(num == '1')   //小学
	{
		for(var i=0;i<11;i++)
		{
			addOption(SelectName,data[1][i],data[0][i]);

		}
	}
	else if(num =='2')   //初一
	{
		for(var i=11;i<=19;i++)
		{
			addOption(SelectName,data[1][i],data[0][i]);
		}
	}
	else if(num == '3')  //初二
	{
		for(var i=20;i<=29;i++)
		{
			addOption(SelectName,data[1][i],data[0][i]);
		}
	}
	else if(num == '4') //初三
	{
		for(var i=20;i<=29;i++)
		{
			addOption(SelectName,data[1][i],data[0][i]);
		}
	}
	else if(num == '5')  //高中
	{
		for(var i=20;i<=31;i++)
		{
			addOption(SelectName,data[1][i],data[0][i]);
		}
	}
	else if (num == '6')  //艺术
	{
		for(var i=32;i<47;i++)
		{
			addOption(SelectName,data[1][i],data[0][i]);
		}
	}
	else if (num == '7')  //心理咨询
	{
		for(var i=47;i<48;i++)
		{
			addOption(SelectName,data[1][i],data[0][i]);
		}
	}
	else if (num == '8')  //计算机
	{
		for(var i=48;i<55;i++)
		{
			addOption(SelectName,data[1][i],data[0][i]);
		}
	}
}


function lotArr(id)
{
	var no21= document.getElementById('no21');
	switch(id)
	{
		case "1":
		case "2":
		case "3":
		case "4":
		case "5":
		case "36":
		{
			arr(no21,1);
			break;
		}
		case "6":
		{
		   arr(no21,2);
		   break;
		}
		case "7":
		{

		   arr(no21,3);
		   break;
		}
		case "8":
		{
			arr(no21,4);
			break;
		}
		case "9":
		case "10":
		case "11":
		{
			arr(no21,5);
			break;
		}
		case "12":
		{
			arr(no21,6);
			break;
		}
		case "46":
		{
			arr(no21,7);
			break;
		}
		case "48":
		{
			arr(no21,8);
			break;
		}
		
	}
}

function getval()
{   
    var no2 = document.getElementById('no41');
	document.getElementById('no2val').value="";
	if(no2.length != 0)
	{
		for(var i=0;i<no2.length;i++)
			document.getElementById('no2val').value += no2[i].value+',';
	}

}

