function comCheck(smes) {
	var mes = 'Please click "OK" to submit.';

	if(smes)
		mes += "(" + smes + ")";

	var rtn = confirm(mes);
    
	if(rtn)
		return true;
	else
		return false;
}


function _inquiry(bol) {
	var err="";


	o = document.getElementById('email');

	if(o.value=="") {
		o.style.backgroundColor = "#FFDAB9";
		o.focus();
		err +="<br />E-mail";
	} else if(!o.value.match(/.+@.+\..+/)) {
		o.style.backgroundColor = "#FFDAB9";
		o.focus();
		err +="<br />E-mail(Invalid)";
	} else{o.style.backgroundColor =""}



	o = document.getElementById('country');

	if(o.value=="") {
		o.style.backgroundColor = "#FFDAB9";
		o.focus();
		err +="<br />Country";
	} else{o.style.backgroundColor =""}

	o = document.getElementById('fst_name');

	if(o.value=="") {
		o.style.backgroundColor = "#FFDAB9";
		o.focus();
		err +="<br />First Name";
	} else{o.style.backgroundColor =""}


	o = document.getElementById('lst_name');

	if(o.value=="") {
		o.style.backgroundColor = "#FFDAB9";
		o.focus();
		err +="<br />Last Name";
	} else{o.style.backgroundColor =""}

	if(bol) {
		o = document.getElementById('comment');

		if(o.value=="") {
			o.style.backgroundColor = "#FFDAB9";
			o.focus();
			err +="<br />Message";
		} else{o.style.backgroundColor =""}
	}


	o = document.getElementById('agree');

	if(! o.checked) {
		o.style.backgroundColor = "#FFDAB9";
		o.focus();
		err +="<br />Terms of Use ";
	} else{o.style.backgroundColor =""}
    
    
    return checkCaptcha(err);
    
    /*
	if(err=="") {
		return comCheck();
	} else {
	 	errer = "Please fill the following required fields. " + err + "";
		o.innerHTML=errer;
		return false;
	}
    */
    
}

function checkCaptcha(err){
    // Check captcha
    o = document.getElementById('message');
    var $jx = jQuery.noConflict();
    var m = $jx("input[name=captcha]");
    
    $jx.ajax({
      type: 'POST',
      url: "/inc/securimage/check.php",
      async: false,
      data: { "captcha": m.val() },
      success: function(msg){
               // error
               if(msg.type == 2){
                   m.css("background-color","#FFDAB9");                  
                   err +="<br />Enter valid captcha ";
                   //errer = "Please fill the following required fields. " + err + "";
                   o.innerHTML=err;
                   return false;
               }else if(msg.type == 1){
                   m.css("background-color","");
                   if(err != "") {
                      o.innerHTML=err;
                      return false;
                   }else{
                      if(comCheck()){
                        $("#inquiry").trigger("submit");
                      }
                   }
               }
           },
      dataType: "json"
    });
    return false;
}

function _agree() {
	var err="";

	o = document.getElementById('agree');

	if(! o.checked) {
		o.style.backgroundColor = "#FFDAB9";
		o.focus();
		err +="Terms of Use. ";
	} else{o.style.backgroundColor =""}


	o = document.getElementById('message');

	if(err=="") {
		return true;
	 } else {
	 	errer = "Please accept " + err + "";
		o.innerHTML=errer;
		return false;
	}
}