function checkCountry() {
  var cntryValue = document.address_info.country.value;
	if ((cntryValue == 'US') || (cntryValue == 'CA')) document.address_info.state.focus();
    else document.address_info.state.options[0].selected = true;
  if (cntryValue == 'ZZ') document.images['flag'].src = 'http://www2l.incredimail.com/ssl/images/flags/0.gif';
    else document.images['flag'].src = 'http://www2l.incredimail.com/ssl/images/flags/' + cntryValue.toLowerCase() + '.gif';
	obj = document.getElementById('actecashRadio');
	if (obj != null) {
    if (cntryValue == 'BR') {
      obj.style.visibility='visible';
      document.address_info.order_by[0].checked = true;
    } else {
        obj.style.visibility='hidden';
        if (document.getElementById('order_by') != null) {
          for (var i=0;i<document.address_info.order_by.length;i++) {
            if (document.address_info.order_by[i].value == 'online') {
              document.address_info.order_by[i].checked = true;
            }
          }
        }											    
      }  
  }
  return true;
}

function checkEmail(emailObj) {
  if (document.address_info.email.value != null) emailObj.value = trim(emailObj).toLowerCase()
  return true
}


function checkForm() {
  btnHide();
  
  var billing_country

	if (document.address_info.email.value == '') {
		document.address_info.email.focus()
		alert(alertMessageAarry[0]);
    btnShow();
		return false
	}
	
	if ((document.address_info.email_confirm.value == '') ||
			(document.address_info.email.value != document.address_info.email_confirm.value)){
		document.address_info.email.focus()
		alert(alertMessageAarry[2]);
    btnShow();
		return false
	}
	
	var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var emailAddr = document.address_info.email.value;
	if (!emailAddr.match(emailRegEx))
	{
		document.address_info.email.focus()
		alert(alertMessageAarry[1]);
		btnShow();
		return false
	}

    if ((document.address_info.purchase_first_name.value == '')) {
			document.address_info.purchase_first_name.focus()
			alert(alertMessageAarry[3]);
    		btnShow();
			return false
	}
	
	 if ((document.address_info.purchase_last_name.value == '')) {
    		document.address_info.purchase_last_name.focus()
		alert(alertMessageAarry[4]);
    	btnShow();
		return false
	}
	
	if ((document.address_info.street_address1.value == '') && (document.address_info.street_address2.value == '')) {
		document.address_info.street_address1.focus()
		alert(alertMessageAarry[5]);
    btnShow();
		return false
	}
	if (document.address_info.city.value == '') {
		document.address_info.city.focus()
		alert(alertMessageAarry[6]);
    btnShow();
		return false
	}
	if (document.address_info.zip.value == '') {
		address_info.zip.value = 'NA';
//		alert(alertMessageAarry[7]);
//	    btnShow();
//		return false
	}

  var cntryValue = document.address_info.country.value;
	billing_country=cntryValue;
	if ( ((billing_country == 'US') && (document.address_info.state.selectedIndex >= 52)) 
        || ((billing_country == 'CA') && (document.address_info.state.selectedIndex <= 52))
        || ((billing_country == 'US') && (document.address_info.state.selectedIndex == 0)) ) {
    document.address_info.state.focus();
		alert(alertMessageAarry[8]);
    btnShow();
		return false
  } 

  //if (document.getElementById('order_by') != null) {
 
    //for (var i=0; i<document.address_info.order_by.length; i++) {
      //if ( document.address_info.order_by[i].checked 
      //      && (document.address_info.order_by[i].value != 'online')
	  //  && (document.address_info.phone.value == '')
      //      && (billing_country == 'US') ) {
      //	document.address_info.phone.focus()
      //  alert(alertMessageAarry[10]);
      //  btnShow();
      //  return false
    //  }
    //}
 // }				    
					  
	if (document.address_info.coupon.length > 0) {
	  document.address_info.coupon.value=document.address_info.coupon.value.toUpperCase();
	}

	return true
}
