// Check browser so we can find the applet in the local object model.
// Browser detection derived from scripts (C) Netscape Communications 1998.
function Is () {
// convert all characters to lowercase to simplify testing
var agt=navigator.userAgent.toLowerCase()
this.major = parseInt(navigator.appVersion)
this.minor = parseFloat(navigator.appVersion)

this.nav  = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1)))
this.nav2 = (this.nav && (this.major == 2))
this.nav3 = (this.nav && (this.major == 3))
this.nav4 = (this.nav && (this.major == 4))
this.nav4up = this.nav && (this.major >= 4)

this.ie   = (agt.indexOf("msie") != -1)
this.ie3  = (this.ie && (this.major == 2))
this.ie4  = (this.ie && (this.major == 4))
this.ie4up  = this.ie  && (this.major >= 4)

this.ie5  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.")!=-1) );
this.ie5up  = this.ie5;
this.opera = (agt.indexOf("opera") != -1)
}

var is = new Is()
// setimgsrc('img_name', 'new_src');
function setimgsrc(imageName, imageLocation) {
  if (document.images) document.images[imageName].src = imageLocation;
  return true;
}

var firsttime = 0;
function sendform( commandname, value, bNoCheckboxCleanup ){
   if ( firsttime == 0 ){
     firsttime = 1;
     var k = -1;
     var sixsix = eval("/" + String.fromCharCode(8220) + "/g" );
     var ninenine = eval("/" + String.fromCharCode(8221) + "/g" );
     var smOpenApos = eval("/" + String.fromCharCode(8216) + "/g" );
     var smClosedApos = eval("/" + String.fromCharCode(8217) + "/g" );
     var smDash = eval("/" + String.fromCharCode(8211) + "/g" );
     var smEllipse = eval("/" + String.fromCharCode(8230) + "/g" );

	 for ( i = 0; i < document.forms[0].elements.length; i++ ) {
		 var ss;
		 var name = document.forms[0].elements[i].name;
		 name = name + "";
		 if ( name == commandname && document.forms[0].elements[i].type == "hidden" ) {
			 k = i;
		 }
		 else if ( is.ie5up && (document.forms[0].elements[i].type == "text" ||
				   document.forms[0].elements[i].type == "textarea" ||
				   document.forms[0].elements[i].type == "hidden" ) ){
			 if ( document.forms[0].elements[i].value != null ) {
				 ss = document.forms[0].elements[i].value.replace( sixsix,  String.fromCharCode(34) );
				 ss = ss.replace( ninenine, String.fromCharCode(34) );
				 ss = ss.replace( smOpenApos, String.fromCharCode(39) );
				 ss = ss.replace( smClosedApos, String.fromCharCode(39) );
				 ss = ss.replace( smDash, String.fromCharCode(45) );
				 ss = ss.replace( smEllipse, String.fromCharCode(46,46,46) );
				 document.forms[0].elements[i].value = ss;
			  }
		 }

		 /* Fix up the check box to do true and false */
		 if(!bNoCheckboxCleanup && document.forms[0].elements[i].type == "checkbox" ) {
			var ele_full_name	= document.forms[0].elements[i].name;
			var ele_short_name	= ele_full_name.slice(1);
			if (document.forms[0].elements[ele_full_name])
			{
				if(document.forms[0].elements[ele_full_name].checked) {
					if (document.forms[0].elements[ele_short_name] && document.forms[0].elements[ele_short_name].type == 'hidden') {
						document.forms[0].elements[ele_short_name].value = "True";
					}
				} else {
					if (document.forms[0].elements[ele_short_name] && document.forms[0].elements[ele_short_name].type == 'hidden') {
						document.forms[0].elements[ele_short_name].value = "False";
					}
				}
			}
		 }
	 }

     if ( k == -1 ){
        alert(g_DB_COMMANDFIELDNOTFOUND);
     }
     else {
        document.forms[0].elements[k].value = value;
        // 04/20/2006 jswafford NOTE: If you get an "Invalid Syntax" IE javascript error during submit, you are posting too much
        // form information using the GET method. Change form method to POST.
        document.forms[0].submit();
     }
  }
}

function check_for_search_keywords(formName){
   var sf = document.forms[formName];

   if(formName == 'listForm')
   {
       if (sf.SubSearch.value == '') 
       {
           alert(g_DB_SPECIFYSEARCHTERM);
           return false;
       }
   }
   else
   {
       if (sf.SubSearch.value == '') 
       {
           alert(g_DB_SPECIFYSEARCHTERM);
           return false;
       }
   }
   

   return true;
}
