//by owensoft.net
//when 5/27/2004 11:48 PM
//how  editplus.com



function check_form(form){
	return getFormState(form);
}

function getFormState(thisForm) {

	if (!thisForm) return false;

    for (x = 0; thisForm[x]; x++) {
			
			if ( getValue(thisForm, thisForm[x].name) =='' & thisForm[x].title != '' ) {
					thisForm[x].focus();
					alert( thisForm[x].title );
	//				myFunction( thisForm[x].title );
					thisForm[x].focus();
					return false;
			}
		}

	return true;
}
/*
function check_rule(rule, value) {
	alert( countInstances( thisForm[x].title, '[date]')
}
*/
function countInstances(string1, word) {
  var substrings = string1.split(word);
  alert(string1);
  return substrings.length - 1;
}

function myFunction(somestring) {
  var splitArray = somestring.split('|');

//message

  for (var v=0; v<splitArray.length; v++) {
    alert('str' + (v+1) + '="' + splitArray[v] + '"');
  }

}


function getFormObj(thisForm, thisName) {
    var found = 0;
	
    for (i = 0; thisForm[i]; i++) {
        if (thisForm[i].name == thisName) {
            return thisForm[i];
            found = 1;
        }
    }
    if (found == 0) alert("Error: Could not locate " + thisName + " in " + thisForm + ".  function getFormObj() ");

}

function setSelectToValue(thisSelect, thisValue) {
    var found = 0;
	
	if(thisSelect.length==0) return '';

    for (i = 0; thisSelect[i]; i++) {
        if (thisSelect[i].value == thisValue) {
            thisSelect[i].selected = true;
            found = 1;
        }
    }
    if (found == 0) {
        alert("Error: Could not locate " + thisValue + " in " + thisSelect + ".  function setSelectToValue() ");
    }
}

function getSelectOptionOfThisValue(thisSelect, thisValue) {
    var found = 0;
	
	if(thisSelect.length==0) return '';

    for (i = 0; thisSelect[i]; i++) {
        if (thisSelect[i].value == thisValue) {
            found = 1;
            return i;
        }
    }
    if (found == 0) {
        alert("Error: Could not locate " + 
                thisValue + " in " + thisSelect + ". function getSelectOptionOfThisValue() ");
    }
}


function getSelectValue(thisSelect) {
    var found = 0;

	if(thisSelect.length==0) return '';

    for (y = 0; thisSelect[y]; y++) {
        if (thisSelect[y].selected == true) {
            found = 1;
            return thisSelect[y].value;
        }
    }

	return '';
/*    if (found == 0) {
        alert("Error: Could not locate " + 
                 " in " + thisSelect + ". function getSelectValue() ");
    }*/
}


function getValue(thisForm, thisName) {
    var found = 0;
	var thisValue='';

	if(thisForm.length==0) return '';

    for (i = 0; thisForm[i]; i++) {
        if (thisForm[i].name == thisName) {//alert(thisForm[i].tagName);

			switch(thisForm[i].tagName.toUpperCase()){
				case 'INPUT' : {
						switch(thisForm[i].type.toUpperCase()){					
							case 'CHECKBOX':{
								if ( thisForm[i].checked==true ) thisValue=thisForm[i].value;
								break;
							}
							case 'RADIO':{
								if ( thisForm[i].checked==true ) thisValue=thisForm[i].value;

								break;
							}
							default:	 thisValue=thisForm[i].value;
						}
					break;
				}
				case 'SELECT':{
					thisValue=getSelectValue(thisForm[i]);
					break;
				}
				case 'TEXTAREA':{
					thisValue=thisForm[i].value;
					break;
				}

				default:	 thisValue=thisForm[i].value;
			}
		  //alert("Object: " + thisForm[i].name + " with value " + thisForm[i].value + ".");
			found=1;
		}
    }

    if (found == 0) {
        alert("Error: Could not locate " + thisName + " in " + thisForm + ". function getValue() ");
    }

	return thisValue;
}
