﻿
function showDropDown(value) {
	if (value) {
		// looping through all forms on the page
		for (f = 0; f < document.forms.length; f++) {
			var elements = document.forms[f].elements;
			// looping through all elements on certain form
			for (e = 0; e < elements.length; e++) {
				if (elements[e].type == "select-one")
				{
					elements[e].style.visibility = 'visible';
				}
			}
		}			
	} else {
		// looping through all forms on the page
		for (f = 0; f < document.forms.length; f++) {
			var elements = document.forms[f].elements;
			// looping through all elements on certain form
			for (e = 0; e < elements.length; e++) {
				if (elements[e].type == "select-one") {
					// alert(elements[e].id); 
					elements[e].style.visibility = 'hidden';
				}
			}
		}
	}
}

//注册会员
function checkReg(form) {

	if (trim(form.user_name.value) == "") {
		alert("请输入会员名称");
		form.user_name.focus();
		return(false);
	}

  if (form.user_name.value.search(/^[0-9a-zA-Z\-_]+$/) == -1)
  {
		alert("会员名称由4至20个大小写英文字母和数字组成");
		form.user_name.focus();
		return(false);
	}

	if (form.user_name.value.length > 20 ||	form.user_name.value.length < 4) {
		alert("会员名称由4至20个大小写英文字母和数字组成");
		form.user_name.focus();
		return(false);
	}

	if (trim(form.password.value) == "") {
		alert("请输入登陆密码");
		form.password.focus();
		return(false);
	}

  if (form.password.value.search(/^[0-9a-zA-Z]+$/) == -1)
  {
		alert("登陆密码由6至20个大小写英文字母和数字组成");
		form.password.focus();
		return(false);
	}

	if (trim(form.confirm_password.value) == "") {
		alert("请输入重复输入密码");
		form.confirm_password.focus();
		return(false);
	}

	if (form.password.value != form.confirm_password.value) {
		alert("登陆密码与重复输入密码不相同");
		form.confirm_password.focus();
		return(false);
	}

	if (form.password.value.length > 20 || form.password.value.length < 6) {
		alert("登陆密码由6至20个大小写英文字母和数字组成");
		form.password.focus();
		return(false);
	}
	
  if (form.email.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1)
  {
		alert("请输入正确的Email");
		form.email.focus();
		return(false);
  }
	
	return(true);
}
//修改个人信息
function checkMdfInfo(form) {

  if (trim(form.password.value) != "") {

	   if (form.password.value.search(/^[0-9a-zA-Z]+$/) == -1)
	   {
		   alert("登陆密码由6至20个大小写英文字母和数字组成");
		   form.password.focus();
		   return(false);
	   }

	   if (trim(form.confirm_password.value) == "") {
		   alert("请输入重复输入密码");
		   form.confirm_password.focus();
		   return(false);
	   }

	   if (form.password.value != form.confirm_password.value) {
		   alert("登陆密码与重复输入密码不相同");
		   form.confirm_password.focus();
		   return(false);
	   }

	   if (form.password.value.length > 20 || form.password.value.length < 6) {
		   alert("登陆密码由6至20个大小写英文字母和数字组成");
		   form.password.focus();
		   return(false);
	   }
  }
	
		if (form.email.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1)
		{
				alert("请输入正确的Email");
				form.email.focus();
				return(false);
		}

	
  return(true);
}



function trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
		return"";
	}

	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
		return "";
	}else{
		return TRIM_VALUE;
	}
} //End Function


function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;

	} //End While
	return strTemp;

} //End Function


function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function


function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

// set the radio button with the given value as being checked

// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

var startYear = 2000;

function genYear(tag) {
  var date = new Date();
  var year = date.getFullYear();
  if (tag == "temp_year")
	document.write("<select name='" + tag + "' onclick=\"radioperiod[1].click()\">");
  else
	document.write("<select name='" + tag + "' onclick=\"radioperiod[2].click()\">");
  for(i=startYear;i<=year;i++) 
	document.write("<option value=\"" + i + "\">" + i + "</option>");
  document.write("</select>");
}

function genMonth(tag) {
  if (tag == "temp_month")
	document.write("<select name='" + tag + "' onclick=\"radioperiod[1].click()\">");
  else
	document.write("<select name='" + tag + "' onclick=\"radioperiod[2].click()\">");
  for(i=1;i<=12;i++)
	document.write("<option value=\"" + i + "\">" + i + "</option>");
  document.write("</select>");
}

function genDay(tag) {
  if (tag == "temp_day")
	document.write("<select name='" + tag + "' onclick=\"radioperiod[1].click()\">");
  else
	document.write("<select name='" + tag + "' onclick=\"radioperiod[2].click()\">");
  for(i=1;i<=31;i++)
	document.write("<option value=\"" + i + "\">" + i + "</option>");
  document.write("</select>");
}

function isInteger(s)
{   var i;
	for (i = 0; i < s.length; i++)
	{   
		// Check that current character is number.
		var c = s.charAt(i);
		if (((c < "0") || (c > "9"))) return false;
	}
	// All characters are numbers.
	return true;
}



var city1Array =  new Array("('','0',true,true)",
"('安庆','1')",
"('蚌埠','2')",
"('亳州','3')",
"('巢湖','4')",
"('阜阳','5')",
"('淮南','6')",
"('黄山','7')",
"('九华山','8')",  
"('马鞍山','9')",
"('宿州','10')",
"('天柱山','11')",  
"('芜湖','12')",
"('其他','13')");

var city2Array =  new Array("('','0',true,true)",
"('北京','1')",
"('其他','2')");

var city3Array =  new Array("('','0',true,true)",
"('重庆','1')",
"('其他','2')");

var city4Array =  new Array("('','0',true,true)",
"('福州','1')",
"('福鼎','2')",
"('晋江','3')",
"('连城','4')",
"('龙岩','5')",
"('宁德','6')",
"('莆田','7')",
"('泉州','8')",
"('三明','9')",
"('石狮','10')",
"('武夷山','11')",
"('厦门','12')",
"('漳州','13')",
"('其他','14')");

var city5Array =  new Array("('','0',true,true)",
"('兰州','1')",
"('敦煌','2')",
"('张掖','3')",
"('其他','4')");

var city6Array =  new Array("('','0',true,true)",
"('广州','1')",
"('潮州','2')",
"('从化','3')",
"('东莞','4')",
"('恩平','5')",
"('佛山','6')",
"('河源','7')",
"('惠州','8')",
"('江门','9')",
"('开平','10')",
"('茂名','11')",
"('梅州(县)','12')",
"('清远','13')",
"('汕头','14')",
"('汕尾','15')",
"('韶关','16')",
"('深圳','17')",
"('台山','18')",
"('阳江','19')",
"('增城','20')",
"('湛江','21')",
"('肇庆','22')",
"('中山','23')",
"('珠海','24')",
"('其他','25')");

var city7Array =  new Array("('','0',true,true)",
"('南宁','1')",
"('北海','2')",
"('桂林','3')",
"('柳州','4')",
"('其他','5')");

var city8Array =  new Array("('','0',true,true)",
"('安顺','1')",
"('贵阳','2')",
"('凯里','3')",
"('遵义','4')",
"('其他','5')");

var city9Array =  new Array("('','0',true,true)",
"('海口','1')",
"('陵水','2')",
"('琼海','3')",
"('三亚','4')",
"('通什','5')",
"('万宁','6')",
"('其他','7')");

var city10Array =  new Array("('','0',true,true)",
"('石家庄','1')",
"('保定','2')",
"('北戴河','3')",
"('沧州','4')",
"('昌黎','5')",
"('承德','6')",
"('丰宁','7')",
"('邯郸','8')",
"('衡水','9')",
"('廊坊','10')",
"('滦平','11')",
"('南戴河','12')",
"('秦皇岛','13')",
"('三河市','14')",
"('唐山','15')",
"('邢台','16')",
"('其他','17')");

var city11Array =  new Array("('','0',true,true)",
"('郑州','1')",
"('鹤壁','2')",
"('济源','3')",
"('开封','4')",
"('洛阳','5')",
"('南阳','6')",
"('濮阳','7')",
"('三门峡','8')",
"('新乡','9')",
"('其他','10')");

var city12Array =  new Array("('','0',true,true)",
"('哈尔滨','1')",
"('大庆','2')",
"('佳木斯','3')",
"('牡丹江','4')",
"('齐齐哈尔','5')",
"('绥芬河','6')",
"('其他','7')");

var city13Array =  new Array("('','0',true,true)",
"('武汉','1')",
"('恩施','2')",
"('荆门','3')",
"('荆州','4')",
"('十堰','5')",
"('武穴','6')",
"('襄樊','7')",
"('宜昌','8')",
"('其他','9')");

var city14Array =  new Array("('','0',true,true)",
"('长沙','1')",
"('凤凰县','2')",
"('韶山','3')",
"('湘潭','4')",
"('岳阳','5')",
"('张家界','6')",
"('株洲','7')",
"('其他','8')");

var city15Array =  new Array("('','0',true,true)",
"('安图','1')",
"('长春','2')",
"('吉林','3')",
"('延吉','4')",
"('其他','5')");

var city16Array =  new Array("('','0',true,true)",
"('南京','1')",
"('常熟','2')",
"('常州','3')",
"('淮安','4')",
"('江都','5')",
"('江阴','6')",
"('金坛','7')",
"('昆山','8')",
"('连云港','9')",
"('溧阳','10')",
"('南通','11')",
"('启东','12')",
"('宿迁','13')",
"('苏州','14')",
"('太仓','15')",
"('泰州','16')",
"('同里','17')",
"('吴江','18')",
"('无锡','19')",
"('徐州','20')",
"('盐城','21')",
"('扬州','22')",
"('宜兴','23')",
"('仪征','24')",
"('张家港','25')",
"('镇江','26')",
"('周庄','27')",
"('其他','28')");

var city17Array =  new Array("('','0',true,true)",
"('南昌','1')",
"('萍乡','2')",
"('景德镇','3')",
"('井冈山','4')",
"('九江','5')",
"('庐山','6')",
"('上饶','7')",
"('婺源','8')",
"('宜春','9')",
"('其他','10')");

var city18Array =  new Array("('','0',true,true)",
"('沈阳','1')",
"('鞍山','2')",
"('大连','3')",
"('丹东','4')",
"('海城','5')",
"('锦州','6')",
"('盘锦','7')",
"('铁岭','8')",
"('其他','9')");

var city19Array =  new Array("('','0',true,true)",
"('呼和浩特','1')",
"('包头','2')",
"('鄂尔多斯','3')",
"('乌海','4')",
"('其他','5')");

var city20Array =  new Array("('','0',true,true)",
"('银川','1')",
"('其他','2')");

var city21Array =  new Array("('','0',true,true)",
"('西宁','1')",
"('其他','2')");

var city22Array =  new Array("('','0',true,true)",
"('滨州','1')",
"('济南','2')",
"('德州','3')",
"('东营','4')",
"('菏泽','5')",
"('胶州','6')",
"('济宁','7')",
"('莱西','8')",
"('聊城','9')",
"('临沂','10')",
"('蓬莱','11')",
"('青岛','12')",
"('曲阜','13')",
"('日照','14')",
"('泰安','15')",
"('潍坊','16')",
"('威海','17')",
"('烟台','18')",
"('淄博','19')",
"('其他','20')");

var city23Array =  new Array("('','0',true,true)",
"('太原','1')",
"('大同','2')",
"('晋中','3')",
"('平遥','4')",
"('运城','5')",
"('其他','6')");

var city24Array =  new Array("('','0',true,true)",
"('西安','1')",
"('宝鸡','2')",
"('咸阳','3')",
"('其他','4')");

var city25Array =  new Array("('','0',true,true)",
"('上海','1')",
"('其他','2')");

var city26Array =  new Array("('','0',true,true)",
"('成都','1')",
"('阿坝州','2')",
"('德阳','3')",
"('都江堰','4')",
"('峨眉山','5')",
"('广安','6')",
"('广元','7')",
"('九寨沟','8')",
"('乐山','9')",
"('泸州','10')",
"('绵阳','11')",
"('松潘','12')",
"('遂宁','13')",
"('宜宾','14')",
"('自贡','15')",
"('其他','16')");

var city27Array =  new Array("('','0',true,true)",
"('天津', '1')",
"('其他', '2')");

var city28Array =  new Array("('','0',true,true)",
"('拉萨','1')",
"('阿里','2')",
"('其他','3')");

var city29Array =  new Array("('','0',true,true)",
"('乌鲁木齐','1')",
"('库尔勒','2')",
"('克拉玛依','3')",
"('吐鲁番','4')",
"('伊宁','5')",
"('其他','6')");

var city30Array =  new Array("('','0',true,true)",
"('昆明','1')",
"('大理','2')",
"('丽江','3')",
"('香格里拉','4')",
"('西双版纳','5')",
"('其他','6')");

var city31Array =  new Array("('','0',true,true)",
"('杭州','1')",
"('安吉','2')",
"('慈溪','3')",
"('德清','4')",
"('东阳','5')",
"('奉化','6')",
"('富阳','7')",
"('海宁','8')",
"('海盐','9')",
"('黄岩','10')",
"('湖州','11')",
"('建德','12')",
"('嘉善','13')",
"('嘉兴','14')",
"('金华','15')",
"('缙云','16')",
"('兰溪','17')",
"('临安','18')",
"('临海','19')",
"('丽水','20')",
"('龙游','21')",
"('宁波','22')",
"('宁海','23')",
"('平湖','24')",
"('千岛湖','25')",
"('衢州','26')",
"('瑞安','27')",
"('上虞','28')",
"('绍兴','29')",
"('嵊泗','30')",
"('嵊州','31')",
"('台州','32')",
"('天台','33')",
"('桐庐','34')",
"('桐乡','35')",
"('温岭','36')",
"('温州','37')",
"('武义','38')",
"('象山','39')",
"('新昌','40')",
"('雁荡山','41')",
"('义乌','42')",
"('永康','43')",
"('余姚','44')",
"('舟山','45')",
"('诸暨','46')",
"('其他','47')");


function populateCountry(inForm, selected)
{
	if (selected == 1)
	{
		inForm.state.disabled = false;
		inForm.city.disabled = false;
	}
	else
	{
		inForm.state.disabled = true;
		inForm.city.disabled = true;
	}
}


function populateCity(inForm, selected)
{	
	if (selected != "0")
	{
		//alert ("selectedArrayName=city" + selected + "Array");
					
		var selectedArray = eval("city" + selected + "Array");
		
		//alert ("selectedArray=" + selectedArray);
		//alert ("selectedArray.length=" + selectedArray.length);
		//alert ("inForm.city.options.length=" + inForm.city.options.length);
		
		while (selectedArray.length < inForm.city.options.length) 
		{
			//alert ("selectedArray.length < inForm.city.options.length");
			//alert ("removed option="+(inForm.city.options.length - 1));
	
			inForm.city.options[(inForm.city.options.length - 1)] = null;
		}
		
		for (var i=0; i < selectedArray.length; i++) 
		{
			//alert ("inForm.city.options[i]=" + "new Option" + selectedArray[i]);
			
			eval("inForm.city.options[i]=" + "new Option" + selectedArray[i]);
		}
		
		if (inForm.state.options[0].value == '') 
		{
			inForm.state.options[0]= null;
			if ( navigator.appName == 'Netscape') 
			{
				if (parseInt(navigator.appVersion) < 4) 
				{
					window.history.go(0);
				}
				else 
				{      
					if (navigator.platform == 'Win32' || navigator.platform == 'Win16') 
					{
						window.history.go(0);
			}
		  }
		}
	  }
  }
}


function populateCityWithSelection(inForm, selected, citySelected)
{
	if (selected != "0")
	{
		//alert ("selectedArrayName=city" + selected + "Array");
					
		var selectedArray = eval("city" + selected + "Array");
		
		//alert ("selectedArray=" + selectedArray);
		//alert ("selectedArray.length=" + selectedArray.length);
		//alert ("inForm.city.options.length=" + inForm.city.options.length);
		
		while (selectedArray.length < inForm.city.options.length) 
		{
			//alert ("selectedArray.length < inForm.city.options.length");
			//alert ("removed option="+(inForm.city.options.length - 1));
	
			inForm.city.options[(inForm.city.options.length - 1)] = null;
		}
		
		for (var i=0; i < selectedArray.length; i++) 
		{
			//alert ("inForm.city.options[i]=" + "new Option" + selectedArray[i]);
			
			eval("inForm.city.options[i]=" + "new Option" + selectedArray[i]);
		}
		
		inForm.city.options[citySelected].selected = true;
		
		if (inForm.state.options[0].value == '') 
		{
			inForm.state.options[0]= null;
			if ( navigator.appName == 'Netscape') 
			{
				if (parseInt(navigator.appVersion) < 4) 
				{
					window.history.go(0);
				}
				else 
				{      
					if (navigator.platform == 'Win32' || navigator.platform == 'Win16') 
					{
						window.history.go(0);
			}
		  }
		}
	  }
  }
}


function populateCityWithSelectedCityName(inForm, selected, cityNameSelected)
{			
	if (selected != "0")
	{
		//alert ("selectedArrayName=city" + selected + "Array");
					
		var selectedArray = eval("city" + selected + "Array");
		
		//alert ("selectedArray=" + selectedArray);
		//alert ("selectedArray.length=" + selectedArray.length);
		//alert ("inForm.city.options.length=" + inForm.city.options.length);
		
		while (selectedArray.length < inForm.city.options.length) 
		{
			//alert ("selectedArray.length < inForm.city.options.length");
			//alert ("removed option="+(inForm.city.options.length - 1));
	
			inForm.city.options[(inForm.city.options.length - 1)] = null;
		}
		
		for (var i=0; i < selectedArray.length; i++) 
		{
			//alert ("inForm.city.options[i]=" + "new Option" + selectedArray[i]);
			
			eval("inForm.city.options[i]=" + "new Option" + selectedArray[i]);
			var temp = selectedArray[i].toString().split("'");			
			
			if (temp[1] == cityNameSelected) {				
				inForm.city.options[i].selected = true;
			}
		}
		
		// inForm.city.options[citySelected].selected = true;
		
		if (inForm.state.options[0].value == '') 
		{
			inForm.state.options[0]= null;
			if ( navigator.appName == 'Netscape') 
			{
				if (parseInt(navigator.appVersion) < 4) 
				{
					window.history.go(0);
				}
				else 
				{      
					if (navigator.platform == 'Win32' || navigator.platform == 'Win16') 
					{
						window.history.go(0);
			}
		  }
		}
	  }
  }
}

function resize_iframe(id) {
  var _y = document.getElementById("div_"+id);
  var _x = "";
  if (window.frames[id] != null) {
	_x = window.frames[id].document.body.innerHTML;
	_y.innerHTML = _x;
  } else if (document.getElementById(id) != null) {
	_x = document.getElementById(id).contentWindow.document.body.innerHTML;
	_y.innerHTML = _x;
  }
}

/************
	frame_resizer.js
*************/

var iframeids=["index_inner", "regmsg"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
	var dyniframe=new Array();
	for (i=0; i<iframeids.length; i++){
		if (document.getElementById) {
			resizeIframe(iframeids[i])
		}
		//reveal iframe for lower end browsers? (see var above):
		if ((document.all || document.getElementById) && iframehide=="no"){
			var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
				empobj.style.display="block"
		}
	}
}

function resizeIframe(frameid){
	// alert('resizeIframe() '+frameid)
	var currentfr=document.getElementById(frameid);
	if (currentfr && !window.opera){
		currentfr.style.display="block";
		if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
			currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
		else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
			currentfr.height = currentfr.Document.body.scrollHeight;

		if (currentfr.addEventListener)
			currentfr.addEventListener("load", readjustIframe, false)
		else if (currentfr.attachEvent){
			currentfr.detachEvent("onload", readjustIframe) // Bug fix line
			currentfr.attachEvent("onload", readjustIframe)
		}
	}
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

