// JavaScript Document
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 excessively is 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 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 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 _delete(thisform)
{
if (confirm("The dangerous operation, you believe firmly the deletion!"))
return true;
else
return false;
}
function selectOther(obj)  
{
for(var i = 0;i<obj.elements.length;i++)  
if(obj.elements[i].type == "checkbox"  )  
{
if(!obj.elements[i].checked)
obj.elements[i].checked=true;
else
obj.elements[i].checked=false;
}
}
function findObj(theObj, theDoc)
{
var p, i, foundObj;
if(!theDoc) theDoc = document;
if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
{
theDoc = parent.frames[theObj.substring(p+1)].document;
theObj = theObj.substring(0,p);
}
if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
for (i=0; !foundObj && i < theDoc.forms.length; i++) 
foundObj = theDoc.forms[i][theObj];
for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
foundObj = findObj(theObj,theDoc.layers[i].document);
if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
return foundObj;
}
function left_menu(meval)
{
var left_n=eval(meval);
if (left_n.style.display=="none")
{ eval(meval+".style.display='';"); }
else
{ eval(meval+".style.display='none';"); }
}
var tt='start';
var ii='start';
function turnit(ss,bb) {
if (ss.style.display=="none") {
if(tt!='start') tt.style.display="none";
if(ii!='start') ii.src="";
ss.style.display="";
tt=ss;
ii=bb;
bb.src="";
}
else {
ss.style.display="none"; 
bb.src="";
}
}