﻿function check(theform,func)
{
var e=theform.elements;
for (var i=0,lngLeng = e.length;i<lngLeng;i++)
{
if (e[i].disabled) continue;
if (e[i].leixing==null) continue;
if (e[i].chulibz=='R') continue
var strValue;
strValue=e[i].value.replace(/^\s+|\s+$/,"");
e[i].value=strValue;

if (strValue==""){
if (e[i].allowNull==null){
if (e[i].chulibz=='M'){
_goError(e[i],func,"This project cannot be spatial!")
return false
}
continue
}
if (e[i].allowNull=='Y'){
continue
}
if (e[i].chulibz=='M'){
_goError(e[i],func,"This project cannot be spatial!")
return false
}
switch(e[i].leixing){
case "NVC":
case "VC":
case "C":
continue
default:
_goError(e[i],func,"This project cannot be spatial!")
return false
}
}// end if strValue==""
if (e[i].value.length>e[i].maxlength&&(e[i].tagName=='TEXTAREA')){
alert (e[i].parentElement.previousSibling.innerText+" the length is excessively long should be smaller than "+e[i].maxlength);
e[i].focus();
return (false);
}
switch(e[i].leixing)
{
case 'NVC':
break
case 'VC':
break
case 'I':
if (!isintstr(strValue)){
_goError(e[i],func)
return false
}
break
case 'IP':
{
var filter=/[0-5]{1,3}.[0-5]{1,3}.[0-5]{1,3}.[0-5]{1,3}/;
if (!filter.test(strValue))
{
_goError(e[i],func)
return false
}
}
break
case 'DA':
if (!isdatestr(strValue)){
_goError(e[i],func)
return false
}
//alert(e[i].value)
if (!isValidSmallDate(strValue)){
_goError(e[i],func,"The date has surpassed the SmallDate scope (1900-1-1 to 2079-6-6)! ")
return false
}
break
case 'LDA':
//alert("HI");
if (!isdatestr_lda(strValue)){
_goError(e[i],func)
return false
}
//alert(e[i].value)
if (!isValidSmallDate(strValue)){
_goError(e[i],func,"The date has surpassed the SmallDate scope (1900-1-1 to 2079-6-6)! ")
return false
}
break
case 'DE': //decimal
if (!isDecimal(e[i].value)){
_goError(e[i],func)
return false
}
break
case 'R':
if (!isintstr(strValue)){
_goError(e[i],func)
return false
}
break
case 'M':
if (!isMoney(e[i].value)){
_goError(e[i],func)
return false
}
break
case 'SJ':
//if (!(/^(\d|[0-1]\d|2[0-3]):[0-5]\d$/.test(strValue))){
if (!(/^(([0-1][0-9])|([2][0-3])|[0-9]):(([0][0-9]|([1-5][0-9]|[0-9])))$/.test(strValue))){
_goError(e[i],func)
return false
}
case 'DASJ':
if (!isDASJ(e[i].value)){
_goError(e[i].value,func)
return false
}
case 'LLDA':
if (!isLLDA(e[i].value)){
_goError(e[i],func)
return false
}
break
case 'Y':
break
case 'YM':
break
}//end switch
}//end for
return true
}
function _goError(e,func,s){
if (s!=null) alert(e.parentElement.previousSibling.innerText+s)
else alert(e.parentElement.previousSibling.innerText+" type mistake!");
if (func!=null) {
func(e)
}
else{
//alert (e.type)
e.focus();
//e.select();
}
}
function _selItem(item1,item2)
{
var option1 = document.all(item1).options
var option2 = document.all(item2).options

var arrText = new Array();
var arrValue = new Array();
var j;
j = 0;
for(var i=option1.length-1;i>=0;i--)
{
if (option1(i).selected)
{
arrText[j]=option1(i).text;
arrValue[j]=option1(i).value;
option1.remove(i);
j = j + 1;
}
}
for(i=arrText.length-1;i>=0;i--)
{
var oOption = document.createElement("OPTION");
option2.add(oOption);
oOption.innerText = arrText[i];
oOption.value = arrValue[i];
}
}
function _rollup(sel_item)
{
var option = document.all(sel_item).options
var value
var text
if (document.all(sel_item).options.length == 0) return false
if (document.all(sel_item).selectedIndex == 0) return false
for (var i=0;i<option.length;i++)
{
if (option(i).selected)
{
value = option(i-1).value
text = option(i-1).innerText
option(i-1).value = option(i).value
option(i-1).innerText = option(i).innerText
option(i).value = value
option(i).innerText = text
option(i-1).selected=true
option(i).selected=false
}
}
}
function _rolldown(sel_item)
{
var option = document.all(sel_item).options
var value
var text
if (document.all(sel_item).selectedIndex == option.length-1) return false
for (var i=option.length-1;i>=0;i--)
{
if (option(i).selected)
{
if (i==(option.length-1)) return false
value = option(i+1).value
text = option(i+1).innerText
option(i+1).value = option(i).value
option(i+1).innerText = option(i).innerText
option(i).value = value
option(i).innerText = text
option(i+1).selected=true
option(i).selected=false
}
}
}
function getToday()
{
var d = new Date()
return d.getYear()+'/'+(d.getMonth()+1)+'/'+d.getDate()
}
function getTotime()
{
var d = new Date()
var s= d.getYear()+'/';
s += formatInt((d.getMonth()+1))+'/';
s += formatInt(d.getDate())+' ';
s += formatInt(d.getHours())+':'
s += formatInt(d.getMinutes())+':'
s += formatInt(d.getSeconds())
return s
}
function formatInt(value)
{
if (value<10)
{
return '0'+value
}
else
{
return ''+value
}
}
function getDateFormat10(d)
{
if (d=="") return ''
var arrDa
arrDa = d.split("-")
var s
s = formatInt(arrDa[0])+'-'+formatInt(arrDa[1])+'-'+formatInt(arrDa[2])
return s
}
function checkAllItemsISNull(thisform) {
var e=theform.elements;
var flag = 0;
for (var i=0,lngLeng = e.length;i<lngLeng;i++)
{
if (e[i].type=="text") {
alert(e[i].value);
if (e[i].value!="") 
flag = 1;
}
}
if (flag == 0) {
alert("error");
return false;
}
else
return true;
}
function changeHints(subject,spanid,strlen){
var l=strlength(subject.value)
if (l<=strlen) {
var templen = strlen-l
if (document.all!=null) document.all(spanid).innerHTML="<font color=blue>(May also input "+templen+" character)</font>"
}
else{
if (document.all!=null) {
document.all(spanid).innerHTML="<font color=red>(The input character surpasses"+strlen+" character)</font>"
}
}
return true
}
function strlength(str){
var l=str.length;
var n=l
for (var i=0;i<l;i++)
{
if (str.charCodeAt(i)<0||str.charCodeAt(i)>255) n++
}
return n
}
//**************************************************************************************
function $(id)
{
	if(document.getElementById)
	{
		return document.getElementById(id);
	}
	else if(document.all)
	{
		return document.all[id];
	}
	else if(document.layers)
	{
		return document.layers[id];
	}
}


//Default Form
function ChkFormTo(){
	if(document.getElementById('account').value==''){
		alert('Account Field is null!');
		document.getElementById('account').focus();
		return false;
	}else if(document.getElementById('password').value==''){
		alert('Password Field is null!');
		document.getElementById('password').focus();
		return false;
	}else{
		return true;
	}
}

//Member Form
function ChkFormTo1(){
	if(document.getElementById('account').value==''){
		alert('Account Field is null!');
		document.getElementById('account').focus();
		return false;
	}else if(document.getElementById('password').value==''){
		alert('Password Field is null!');
		document.getElementById('password').focus();
		return false;
	}else if(document.getElementById('newpassword').value==''){
		alert('New Password Field is null!');
		document.getElementById('newpassword').focus();
		return false;
	}else if(document.getElementById('newpassword1').value==''){
		alert('Confirms Password Field is null!');
		document.getElementById('newpassword1').focus();
		return false;
	}else{
		return true;
	}
}


//Show Clock
<!--
function tick() { 
	var hours, minutes, seconds, strTime; 
	var intHours, intMinutes, intSeconds; 
	var strnow; 
	strnow = new Date(); 
	intHours = strnow.getHours(); 
	intMinutes = strnow.getMinutes(); 
	intSeconds = strnow.getSeconds(); 
	if (intHours <= 12) { 
		hours = intHours+":"; 
		strTime = "AM"; 
	}else{ 
		intHours = intHours - 12 
		hours = intHours + ":"; 
		strTime = "PM"; 
	} 
	
	if (intMinutes < 10) { 
		minutes = "0"+intMinutes+":"; 
	} else { 
		minutes = intMinutes+":"; 
	} 
	
	if (intSeconds < 10) { 
		seconds = "0"+intSeconds+" "; 
	} else { 
		seconds = intSeconds+" "; 
	} 
	
	timeString = strTime+" "+hours+minutes+seconds+"&nbsp;"+(strnow.getMonth()+1)+"/"+strnow.getDate()+"/"+strnow.getYear(); 
	Clock.innerHTML = timeString; 
	window.setTimeout("tick();", 100); 
} 
window.onload = tick; 
-->