function validateSuggestion() {
	
	//if(isAlphabet(document.getElementById('FirstName'),"Please Enter a First Name."))
	//  if(isAlphabet(document.getElementById('LastName'),"Please Enter a Last Name."))
	//    if(madeSelection(document.getElementById('Country'),"Please Select a Country."))
	//      if(emailValidator(document.getElementById('Email'),"Please Enter a Valid Email Address."))
	        if(lengthRestriction(document.getElementById('Comments'),1,10000))
	          return true;

	
	return false;
	
}

function isEmpty(elem, helperMsg){
	if(elem.value.length == 0){
		document.getElementById('suggestionReturn').innerHTML = "<font color=red>" + helperMsg + "<br /><br /></font>";
		elem.focus(); // set the focus to this input
		return true;
	}
	return false;
}

function isNumeric(elem, helperMsg){
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function isAlphabet(elem, helperMsg){
	var alphaExp = /^[a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		document.getElementById('suggestionReturn').innerHTML = "<font color=red>" + helperMsg + "<br /><br /></font>";
		elem.focus();
		return false;
	}
}

function isAlphanumeric(elem, helperMsg){
	var alphaExp = /^[0-9a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		document.getElementById('suggestionReturn').innerHTML = "<font color=red>" + helperMsg + "<br /><br /></font>";
		elem.focus();
		return false;
	}
}

function lengthRestriction(elem, min, max){
	var uInput = elem.value;
	if(uInput.length >= min && uInput.length <= max){
		return true;
	}else{
		document.getElementById('suggestionReturn').innerHTML = "<font color=red><b>Please Enter a Question or Comment.</b><br /></font>";
		elem.focus();
		return false;
	}
}

function madeSelection(elem, helperMsg){
	if(elem.value == ""){
		document.getElementById('suggestionReturn').innerHTML = "<font color=red>" + helperMsg + "<br /><br /></font>";
		elem.focus();
		return false;
	}else{
		return true;
	}
}

function emailValidator(elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		document.getElementById('suggestionReturn').innerHTML = "<font color=red>" + helperMsg + "<br /><br /></font>";
		elem.focus();
		return false;
	}
}


   var http_request = false;
function makePOSTRequest(url, parameters) {


      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('suggestionReturn').innerHTML = result;            
         } else {
            alert('There was a problem with the request. '+http_request.status);
         }
      }
   }
   
function getSuggestion(obj) {
	

         var poststr = "FirstName=" + escape(encodeURI( document.getElementById("FirstName").value )) + 
		    "&LastName=" + escape(encodeURI( document.getElementById("LastName").value )) +
		    //"&Country=" + escape(encodeURI( document.getElementById("Country").value )) +
		    "&Email=" + escape(encodeURI( document.getElementById("Email").value )) +
		    //"&Skype=" + escape(encodeURI( document.getElementById("Skype").value )) +
		    //"&Phone=" + escape(encodeURI( document.getElementById("Phone").value )) +
		    //"&BestTime=" + escape(encodeURI( document.getElementById("BestTime").value )) +
		    //"&TimeZone=" + escape(encodeURI( document.getElementById("TimeZone").value )) +
		    //"&Source=" + escape(encodeURI( document.getElementById("Source").value )) +
		    "&Date=" + escape(encodeURI( document.getElementById("Date").value )) +
		    "&Browser=" + escape(encodeURI( document.getElementById("Browser").value )) +
		    "&Page=" + escape(encodeURI( document.getElementById("Cur_Page").value )) +
		    "&Uid=" + escape(encodeURI( document.getElementById("Cur_Uid").value )) +
		    "&Aid=" + escape(encodeURI( document.getElementById("Cur_Aid").value )) +
		    "&Comments=" + escape(encodeURI( document.getElementById("Comments").value ));
         document.getElementById('suggestionReturn').innerHTML = "<font color=red><b>Please wait while we process your request.</b></font>";
         makePOSTRequest('http://www.findacode.com/suggestion.php', poststr);
	
   }
   
function popupQuestion() {
  var blanket_div  = "blanket_contact";
  var popup_div    = "popUpDiv_contact";
  var popup_width  = 400;
  var popup_height = 255;
  div_loc(blanket_div,0,0);
  div_center_loc(popup_div,popup_width,popup_height);
  div_relative_size(blanket_div,null);
	div_size(popup_div,popup_width,popup_height);
	toggle_div(blanket_div);
	toggle_div(popup_div);
  document.suggestions2.Comments.focus();
  return false;
}

function popupCheck() {
  if (document.suggestions2.Comments.value.length<1) {
    document.getElementById("suggestionReturn2").innerHTML = "<font color=red><b>Please enter a comment or question.</b></font>";
    return false;
  }
  return true;
}


