// JavaScript Document
<!--
function strip_space(form){
	for(var i=0;i<form.elements.length;i++){
		e = form.elements[i];
		if ((e.type == 'text') || (e.type == 'textarea'))
			e.value = replaceCharacters(e.value,' ','');
	}
}

function get_checkbox_value(form,name){
	var e = form.elements[name];
	var value = 0;
	for(var i=0;i<e.length;i++){
		if (e[i].checked)
			value += parseInt(e[i].value);
	}
	return value;
}

function get_checkbox_count(form,name){
	var e = form.elements[name];
/*	for (key in e){
		document.writeln(key + ' = ' + e[key] + '<br>');
	}*/
	var count = 0;
	if (e){
		if (e.length){
			for(var i=0;i<e.length;i++){
				if (e[i].checked)
					count ++;
			}
		}
		else
			count = e.checked ? 1 : 0;
	}
	return count;
}

function get_radio_value(form,name){
	var e = form.elements[name];
	var value = '';
	if (e.length){
		for(var i=0;i<e.length;i++){
			if (e[i].checked){
				value = e[i].value;
				break;
			}
		}
	}
	else{
		if (e.checked) value = e.value;
	}
	return value;
}

function CheckAll(form,obj,name){
  for (var i=0;i < form.elements.length;i++){
    var e = form.elements[i];
    if ((e.name == name) && (!e.disabled))
       e.checked = obj.checked;
  }
}

/***********************************
函数名:textCounter(field, countfield, maxlimit)
作用:限制textArea输入字数
编写时间:2005-05-11
编写人:高骏
************************************/
function textCounter(field, countfield, maxlimit) { 
// 定义函数，传入3个参数，分别为表单区的名字，表单域元素名，字符限制； 
if (field.value.length > maxlimit) 
//如果元素区字符数大于最大字符数，按照最大字符数截断； 
field.value = field.value.substring(0, maxlimit); 
else 
//在记数区文本框内显示剩余的字符数； 
countfield.value = maxlimit - field.value.length; 
} 

function  trim(strInput){ 
	var iLoop=0;
	var iLoop2=-1;
	var strChr;
	if((strInput == null)||(strInput == "<NULL>"))
		return "";
	if(strInput){
		for(iLoop=0;iLoop<strInput.length-1;iLoop++){
			strChr=strInput.charAt(iLoop);
			if(strChr!=' ')
				break;
		}
		for(iLoop2=strInput.length-1;iLoop2>=0;iLoop2--){
			strChr=strInput.charAt(iLoop2);
			if(strChr!=' ')
				break;
		}
	}
	
	if(iLoop<=iLoop2){
		return strInput.substring(iLoop,iLoop2+1);
	}
	else{
		return "";
	}
}

function fnCheckForm(f){  
 //=======================================================================================
	var dataReady = true;;
	var strNumSource ="0123456789."
	var aDataType = f.elements['DataType'].value.split('|');
	var aNeed = f.elements['Need[]'].value.split('|');
	var aErrmsg = f.elements['Errmsg[]'].value.split('|');
	for(var i=0;i<f.elements.length;i++){
		var obj = f.elements[i];
		if (aNeed[i] != 0){
			switch(obj.type){
				case 'text':
				case 'password':
					var value = trim(obj.value);
//					alert(value);
					unvalid = (aNeed[i] > 1) ? (value.length < aNeed[i]) : value =="";
					break;
				case 'textarea':
					unvalid = trim(obj.innerText) == "";
				case 'select-one':
					unvalid = (obj.value == '' || obj.value == '0');
			}
			if(unvalid){
				alert(aErrmsg[i])
				f.elements[i].focus()
				dataReady = false
				return false;
			}
		}
		if((obj.value!="")&&(aDataType[i]=="number")){
			str = f.elements[i].value
			var ch;
			var temp;
			for (var j=0;j<str.length;j++){
				ch = str.charAt(j);
				temp = strNumSource.indexOf(ch);
				if (temp==-1){
					alert("光标所处栏位只能填数字！") 
					f.elements[i].focus()
					dataReady = false
					return false;
			    }
			}
		}
		if((f.elements[i].value!="")&&(aDataType[i]=="Email")){
			p=f.elements[i].value.indexOf('@');
			if(p<1 || p==(f.elements[i].value.length-1)){
				   alert("您填写了Email，但它的格式不正确!\n正确例子：webmaster@57show.com")
				   f.elements[i].focus()
			  dataReady = false
			  return false;
			}
		}

	}
	
	if(f.pwd){
		if(f.pwd.value!=f.pwd2.value){
			alert("两次密码输入不正确，请重新输入！")
			dataReady = false
			f.pwd.focus();
			return false;
		}
	}
  	return dataReady;
}


/*****************************************   
auth: polarbear   
data: 2009.04.17   
  
******************************************/   
  
//ucstar select   
//id: select id   
//name: select attribute name   
//rootSelectname: select first option value   
//sign: iterator options's prefix sign   
//selectid: about the selected option id   
function UcstarSelectObj(id,name,rootSelectname,sign,selectedid) {   
    this.id = id;   
    this.name = name;   
    this.rootSelectname = rootSelectname;   
    this.sign = sign;   
    this.selectedid = selectedid;   
    this.selectStr = "";   
    this.ucstaroptions = [];   
    this.ucstaroptionobjs = [];   
}   
  
//ucstar option   
//value: option value   
//name: option name   
//pid: the node's parent id   
//desc: the option's description   
function UcstarOption(id,name,pid,desc) {   
    this.value = id;   
    this.name = name;   
    this.pid = pid;   
    this.desc = desc;   
}   
  
//get the options by parentid   
UcstarSelectObj.prototype.getChildOptions = function(vPid) {   
    var childOptions = new Array();   
    //this.debug(this.ucstaroptions.length);   
    for(var i = 0; i < this.ucstaroptions.length; i++) {   
        if(this.ucstaroptions[i].pid == vPid) {   
            //this.debug(this.ucstaroptions[i].pid + "-" + this.ucstaroptions[i].id);   
            childOptions[childOptions.length] = this.ucstaroptions[i];   
        }   
    }   
    return childOptions;   
}   
  
//debug message   
UcstarSelectObj.prototype.debug = function(message) {   
    alert(">>Debug:"+message);   
}   
  
//add the select's option   
UcstarSelectObj.prototype.addOption = function(id,name,pid,desc) {   
    //this.debug(this.ucstaroptions.length);   
    this.ucstaroptions[this.ucstaroptions.length] = new UcstarOption(id,name,pid,desc);   
    this.ucstaroptionobjs[id] = new UcstarOption(id,name,pid,desc);   
}   
  
//generate select string   
UcstarSelectObj.prototype.genSelect = function(vPid) {   
    var sPid = "0";   
    if(vPid != undefined) {   
        sPid = vPid;   
    }   
    this.selectStr = '<select id=\'' + this.id + '\' name=\'' + this.name + '\'>';   
    this.selectStr += '<option value=\'' + vPid + '\'>' + this.rootSelectname + '</option>';   
    this._genSelect(sPid,'');   
    this.selectStr += '</select>';   
    return this.selectStr;   
       
}   
  
//private generate select string   
UcstarSelectObj.prototype._genSelect = function(vPid,vSign) {   
    var oldtsign = vSign;   
    var newtsign = oldtsign + this.sign;   
    var childOptions = this.getChildOptions(vPid);   
       
    if(childOptions != null && childOptions.length > 0) {   
        for(var i = 0; i < childOptions.length; i++) {   
            this.selectStr += '<option value=\'' + childOptions[i].value + '\'';   
            if(childOptions[i].value == this.selectedid) {   
                this.selectStr += ' selected';   
            }   
            this.selectStr += '>' + oldtsign + childOptions[i].name + '</option>';   
            this._genSelect(childOptions[i].value,newtsign);   
        }   
    }   
}   
  
UcstarSelectObj.prototype.setSelected = function(optionid) {   
    this.selectedid = optionid;   
}   
//--> 
//-->
