////////////////////////////////////////////////////////  AJAX Functions//  http://www.phpbuilder.com/columns/kassemi20050613.php3 and http://developer.apple.com/internet/webcontent/xmlhttpreq.html////  These ajax functions are only used in problemDatabase searching to show a preview of the problem/////////////////////////////////////////////////////////* The following function creates an XMLHttpRequest object... */function createRequestObject(){        var request_o; //declare the variable to hold the object.        var browser = navigator.appName; //find the browser name        if(browser == "Microsoft Internet Explorer"){                /* Create the object using MSIE's method */                request_o = new ActiveXObject("Microsoft.XMLHTTP");        }else{                /* Create the object using other browser's method */                request_o = new XMLHttpRequest();        }        return request_o; //return the object}/* The variable http will hold our new XMLHttpRequest object. */var http = createRequestObject(); /* Function called to get the product categories list */function getProblemDetail(id){        /* Create the request. The first argument to the open function is the method (POST/GET),                and the second argument is the url...                 document contains references to all items on the page                We can reference document.form_category_select.select_category_select and we will                               be referencing the dropdown list. The selectedIndex property will give us the                 index of the selected item.         */        http.open('get', 'ajaxResponse.php?problemActionType=getProblemDetail&id=' + id);        /* Define a function to call once a response has been received. This will be our                handleProductCategories function that we define below. */        http.onreadystatechange = displayProblemDetail;         /* Send the data. We use something other than null when we are sending using the POST                method. */        http.send(null);}/* Function called to handle the list that was returned from the internal_request.php file.. */function displayProblemDetail(){        /* Make sure that the transaction has finished. The XMLHttpRequest object                 has a property called readyState with several states:                0: Uninitialized                1: Loading                2: Loaded                3: Interactive                4: Finished */        if(http.readyState == 4){ //Finished loading the response                /* We have got the response from the server-side script,                        let's see just what it was. using the responseText property of                         the XMLHttpRequest object. */                var response = http.responseText;                /* And now we want to change the product_categories <div> content.                        we do this using an ability to get/change the content of a page element                         that we can find: innerHTML. */                document.getElementById('problemDetail').innerHTML = response;        }}////////////////////////////////////////////////////////  This function is called in the body tag.//  http://www.alistapart.com/articles/zebratables///////////////////////////////////////////////////////  // this function is need to work around   // a bug in IE related to element attributes  function hasClass(obj) {     var result = false;     if (obj.getAttributeNode("class") != null) {         result = obj.getAttributeNode("class").value;     }     return result;  }    function stripe(id) {    // the flag we'll use to keep track of     // whether the current row is odd or even    var even = false;      // if arguments are provided to specify the colours    // of the even & odd rows, then use the them;    // otherwise use the following defaults:    var evenColor = arguments[1] ? arguments[1] : "#fff";    var oddColor = arguments[2] ? arguments[2] : "#eee";      // obtain a reference to the desired table    // if no such table exists, abort    var table = document.getElementById(id);    if (! table) { return; }        // by definition, tables can have more than one tbody    // element, so we'll have to get the list of child    // &lt;tbody&gt;s     var tbodies = table.getElementsByTagName("tbody");    // and iterate through them...    for (var h = 0; h < tbodies.length; h++) {         // find all the &lt;tr&gt; elements...       var trs = tbodies[h].getElementsByTagName("tr");            // ... and iterate through them      for (var i = 0; i < trs.length; i++) {	    // avoid rows that have a class attribute        // or backgroundColor style	    if (!hasClass(trs[i]) && ! trs[i].style.backgroundColor) {          // get all the cells in this row...          var tds = trs[i].getElementsByTagName("td");                  // and iterate through them...          for (var j = 0; j < tds.length; j++) {                    var mytd = tds[j];            // avoid cells that have a class attribute            // or backgroundColor style	        if (! hasClass(mytd) && ! mytd.style.backgroundColor) {        		      mytd.style.backgroundColor = even ? evenColor : oddColor;                          }          }        }        // flip from odd to even, or vice-versa        even =  ! even;      }    }  }                    ////////////////////////////////////////////////////////  These functions are used to validate webforms//  http://developer.apple.com/internet/webcontent/validation.html///////////////////////////////////////////////////////*A master function, called checkWholeForm() is placed at the top of the page that contains a form.function checkWholeForm(theForm) {    var why = "";    why += checkEmail(theForm.email.value);    why += checkPhone(theForm.phone.value);    why += checkPassword(theForm.password.value);    why += checkUsername(theForm.username.value);    why += isEmpty(theForm.notempty.value);    why += isDifferent(theForm.different.value);    for (i=0, n=theForm.radios.length; i<n; i++) {        if (theForm.radios[i].checked) {            var checkvalue = theForm.radios[i].value;            break;        }     }    why += checkRadio(checkvalue);    why += checkDropdown(theForm.choose.selectedIndex);    if (why != "") {       alert(why);       return false;    }return true;}*/// emailfunction checkEmail (strng) {var error="";if (strng == "") {   error = "You didn't enter an email address.\n";}    var emailFilter=/^.+@.+\..{2,3}$/;    if (!(emailFilter.test(strng))) {        error = "Please enter a valid email address.\n";    }    else {//test email for illegal characters       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/         if (strng.match(illegalChars)) {          error = "The email address contains illegal characters.\n";       }    }return error;    }// phone number - strip out delimiters and check for 10 digitsfunction checkPhone (strng) {var error = "";if (strng == "") {   error = "You didn't enter a phone number.\n";}var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters    if (isNaN(parseInt(stripped))) {       error = "The phone number contains illegal characters.";      }    if (!(stripped.length == 10)) {	error = "The phone number is the wrong length. Make sure you included an area code.\n";    } return error;}// password - between 6-8 chars, uppercase, lowercase, and numeralfunction checkPassword (strng) {var error = "";if (strng == "") {   error = "You didn't enter a password.\n";}    var illegalChars = /[\W_]/; // allow only letters and numbers        if ((strng.length < 6) || (strng.length > 8)) {       error = "The password is the wrong length.\n";    }    else if (illegalChars.test(strng)) {      error = "The password contains illegal characters.\n";    }     else if (!((strng.search(/(a-z)+/)) && (strng.search(/(A-Z)+/)) && (strng.search(/(0-9)+/)))) {       error = "The password must contain at least one uppercase letter, one lowercase letter, and one numeral.\n";    }  return error;    }    // username - 4-10 chars, uc, lc, and underscore only.function checkUsername (strng) {var error = "";if (strng == "") {   error = "You didn't enter a username.\n";}    var illegalChars = /\W/; // allow letters, numbers, and underscores    if ((strng.length < 4) || (strng.length > 10)) {       error = "The username is the wrong length.\n";    }    else if (illegalChars.test(strng)) {    error = "The username contains illegal characters.\n";    } return error;}       // non-empty textboxfunction isEmpty(strng,fieldName) {var error = "";  if (strng.length == 0) {     error = "Please fill in required field:\n " + fieldName + "\n\n\n";  }return error;	  }// was textbox alteredfunction isDifferent(strng) {var error = "";   if (strng != "Can\'t touch this!") {     error = "You altered the inviolate text area.\n";  }return error;}// exactly one radio button is chosenfunction checkRadio(checkvalue,fieldName) {var error = "";   if (!(checkvalue)) {     error = "Please select a " + fieldName + "\n\n\n";    }return error;}// valid selector from dropdown listfunction checkDropdown(choice,fieldName) {var error = "";    if (choice == 0) {    error = "Please select a "+fieldName+".\n\n\n";    }    return error;}    