/***************************** check the contact form ***************************/
var whitespace = " \t\n\r";
var digits = "0123456789";

function isEmpty(s) {   
	return ((s == null) || (s.length == 0))
}
function isDigit(c) {
    return ((c >= "0") && (c <= "9"))
}

function isEmptyOrWhitespace (s) {   
	var i;
    if (isEmpty(s)) return true;
    for (i = 0; i < s.length; i++) {   
        var c = s.charAt(i);
        if (whitespace.indexOf(c) == -1) return false;
    }
    return true;
}

function isRadioSelected(radiofield) {   
	for (var i = 0; i < radiofield.length; i++) {   
		if (radiofield[i].checked) return true
    }
    return false
}

function isValidPhoneNumber(s) {
	var temp = s.replace(/\D/g, "")
	return temp.length > 9 && temp.length < 26
}

function isNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
 }

 function isInteger(s) {
     var i;

     if (isEmpty(s))
         if (isInteger.arguments.length == 1) return 0;
     else return (isInteger.arguments[1] == true);

     for (i = 0; i < s.length; i++) {
         var c = s.charAt(i);

         if (!isDigit(c)) return false;
     }

     return true;
 }
 function getCheckedValue(radioObj) {
     if (!radioObj)
         return "";
     var radioLength = radioObj.length;
     if (radioLength == undefined)
         if (radioObj.checked)
         return radioObj.value;
     else
         return "";
     for (var i = 0; i < radioLength; i++) {
         if (radioObj[i].checked) {
             return radioObj[i].value;
         }
     }
     return "";
 }
 function setCheckedValue(radioObj, newValue) {
     if (!radioObj)
         return;
     var radioLength = radioObj.length;
     if (radioLength == undefined) {
         radioObj.checked = (radioObj.value == newValue.toString());
         return;
     }
     for (var i = 0; i < radioLength; i++) {
         radioObj[i].checked = false;
         if (radioObj[i].value == newValue.toString()) {
             radioObj[i].checked = true;
         }
     }
 }

 function getElementRef(id) {
     if (dom1) return document.getElementById(id);
     else if (ie4plus) return document.all[id];
     else if (ns4) return document.layers[id];
     else return null;
 }
 ///////////////////////////////////////////////////
 //function to control active/inactive fields
 function activeField(f) {
     var x = document.getElementById(f).style;
     x.background = '#ffffcc'
     x.border = 'solid 1px #000';
 }

 function inactiveField(f) {
     var x = document.getElementById(f).style;
     x.background = '#fff'
     x.border = 'solid 1px #999';
 }
 //////////////////////////////////////////////////
 ///////////////////////////////////////////////////////
 // remove IE square border around check/radio buttons
 function addEvent(elm, evType, fn, useCapture) {
     if (elm.addEventListener) {
         elm.addEventListener(evType, fn, useCapture);
         return true;
     }
     else if (elm.attachEvent) {
         var r = elm.attachEvent('on' + evType, fn);
         return r;
     }
     else {
         elm['on' + evType] = fn;
     }
 }
 function removeCheckBoxBorders() {
     var el = document.getElementsByTagName("input");
     for (i = 0; i < el.length; i++) {
         var type = el[i].getAttribute("type");
         if ((type == "checkbox") || (type == "radio")) {
             el[i].style.border = "none";
         }
     }
 }
 addEvent(window, 'load', removeCheckBoxBorders, false);