function radio_button_checker(){
	// set var radio_choice to false
	var radio_choice = false;
	// Loop from zero to the one minus the number of radio button selections
	for (counter = 0; counter < radio_form.radio_button.length; counter++){
		// If a radio button has been selected it will return true
		// (If not it will return false)
		if (radio_form.radio_button[counter].checked)
			radio_choice = true; 
	}

	if (!radio_choice){
		// If there were no selections made display an alert box 
		alert("Please select a letter.")
		return (false);
	}
	return (true);
}	
	
	///////////////////////////////////////////////////
	
function valButton(btn) {
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) return btn[cnt].value;
    else return null;
}               
	
	
	
	
	
	
	
	
	
	
	
	
	
	
function IsNumeric(sText){
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
   
   function ValidateEmail(email){
		var atCharPresent = false;
		var dotPresent = false;
		
		for ( var Idx = 0; Idx < email.value.length; Idx++ ){
			if ( email.value.charAt ( Idx ) == '@' )
				atCharPresent = true;
			if ( email.value.charAt ( Idx ) == '.' )
				dotPresent = true;
		}
		if ( !atCharPresent || !dotPresent ){
			//alert( formName + "\nEmail address not looks valid !");
			email.focus();
			return false;
		}else{
			return true;
		}
}

function ValidateEmail6(email, formName){
		var atCharPresent = false;
		var dotPresent = false;
		
		for ( var Idx = 0; Idx < email.value.length; Idx++ ){
			if ( email.value.charAt ( Idx ) == '@' )
				atCharPresent = true;
			if ( email.value.charAt ( Idx ) == '.' )
				dotPresent = true;
		}
		if ( !atCharPresent || !dotPresent ){
			alert( formName + "\nEmail address not looks valid !");
			email.focus();
			return false;
			}
	return true;
}
function LTrimAll(str){
	if(str==null){
		return str;
	}
	for(var i=0;str.charAt(i)==" " || str.charAt(i)=="\n" || str.charAt(i)=="\t";i++);
		return str.substring(i,str.length);
}

function RTrimAll(str){
	if(str==null){
		return str;
	}
	for(var i=str.length-1;str.charAt(i)==" " || str.charAt(i)=="\n" || str.charAt(i)=="\t";i--);
		return str.substring(0,i+1);
}

function TrimAll(str){
	return LTrimAll(RTrimAll(str));
}

function changeBackgroundColor( current , condition ){
	if( condition == 'over' ){
		current.style.backgroundColor='#CCCC66';
	} else if( condition == 'out' ) {
		current.style.backgroundColor='#3EAFFE';
	}
}

function mailingListValidate( check ){
	if(TrimAll(check.name.value) == ""){
		alert("Mailing List:\nPlease fill in your Name !");
		check.name.value = "";
		check.name.focus();
		return false;
	}
	if(TrimAll(check.country.value) == ""){
		alert("Mailing List:\nPlease fill in your Country !");
		check.country.value = "";
		check.country.focus();
		return false;
	}

	return ValidateEmail(check.email, 'Mailing List:');
}

function searchValidate( check ){
	if(TrimAll(check.keywords.value) == "" ){
		alert("Please fill in the Search Keywords !");
		check.keywords.focus();
		return false;
	}
	if(TrimAll(check.search_in.value) == "" ){
		alert("Please select the Category to Search !");
		check.search_in.focus();
		return false;
	}
}
