// JavaScript Document


function toggle_display(element_id)
{
  if( !element_id )
    return false;



  var element_object = document.getElementById(element_id);
  var icon_object = document.getElementById('icon_'+ element_id);

  if( element_object.style.display == 'none' )
  {
    icon_object.src = "/images/icon-folder_status-open.gif";
    element_object.style.display = 'block';
  }
  else
  {
    icon_object.src = "/images/icon-folder_status-closed.gif";
    element_object.style.display = 'none';
  }
}

function featurepopup(feature){

	var popurl="usatelpop.php?pg=FEATURE_" + feature ;
	winpops=window.open(popurl,"","width=350,scrollbars=NO,height=155")
	
}


function openpopup(pop_page){

	var popurl="usatelpop.php?pg=" + pop_page ;
	if (pop_page == "int_rates"){
		p_width = 440;
	} else {
		p_width = 350;
	}
	
	winpops=window.open(popurl,"","width=" + p_width + ",scrollbars=YES,height=350")
	
}

function isValid(input,type) {
	
	var ValidChars;	
	
	if (type == "alpha"){
		ValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.,\'\ ";
	} else if (type == "num"){ 
		ValidChars = "0123456789";
	} else { 
		ValidChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*";
	}
	
	var IsTrue=true;
	var Char;
	
	for (i = 0; i < input.length && IsTrue == true; i++) { 
		Char = input.charAt(i); 
		if (ValidChars.indexOf(Char) == -1){
			IsTrue = false;
		}
	}
	
	if (input == ""){IsTrue = false;}
	return IsTrue;
}

function changeFocus(fField, nField){

		if (isValid(fField.value,"num") && fField.value.length == 3){
    		nField.focus();
			nField.select();
		}
}


function show_table(this_table)
{
	  if (document.getElementById(this_table).style.display == 'block'){	  
		  document.getElementById(this_table).style.display = 'none';
	  } else {
		  document.getElementById(this_table).style.display = 'block';	 	  	
	  }

}
