<?php
$default="select";
 $country=13;
 

 
 
 
function draw_dynamic_pull_down_menue($name,$table_name,$field_id,$field_text,$table_parameters,  $selected = '', $parameters = '',$PULL_DOWN_DEFAULT,$multiple='n') {
 $dropdown_array=array();
    if(tep_not_null($PULL_DOWN_DEFAULT)){
	$dropdown_array[] = array('id' => '', 'text' => $PULL_DOWN_DEFAULT);
	}else{
	//$dropdown_array = array(array('id' => '', 'text' =>'' ));
	}
  
  $db_query="SELECT  ".$field_id." , ". $field_text."	FROM  ".$table_name ;
  if (tep_not_null($table_parameters)) 
 	 $db_query .= " ".$table_parameters;
	//"."
	$result=tep_db_query($db_query);
	while($data=tep_db_fetch_array($result))
	{
	
	$id=$data[$field_id];
	$data_text=$data[$field_text];
     $dropdown_array[] = array('id' => $id ,
	 						 'text' =>$data_text
							 );
 	}


   return tep_draw_pull_down_menu($name, $dropdown_array, $selected,$multiple, $parameters);
}

function draw_dynamic_pull_down_menue_shipping($name,$table_name,$field_id,$field_text,$table_parameters,  $selected = '', $parameters = '',$PULL_DOWN_DEFAULT,$multiple='n') {
  $dropdown_array=array();
    if(tep_not_null($PULL_DOWN_DEFAULT)){
	$dropdown_array[] = array('id' => '', 'text' => $PULL_DOWN_DEFAULT);
	}else{
	//$dropdown_array = array(array('id' => '', 'text' =>'' ));
	}
  
  $db_query="SELECT  ".$field_id." , ". $field_text."	FROM  ".$table_name." WHERE country_code='AU'" ;
  if (tep_not_null($table_parameters)) 
 	 $db_query .= " ".$table_parameters;
	//"."
	$result=tep_db_query($db_query);
	while($data=tep_db_fetch_array($result))
	{
	
	$id=$data[$field_id];
	$data_text=$data[$field_text];
     $dropdown_array[] = array('id' => $id ,
	 						 'text' =>$data_text
							 );
 	}


   return tep_draw_pull_down_menu($name, $dropdown_array, $selected,$multiple, $parameters);
}


 function tep_draw_pull_down_menu($name, $values, $default = '',$multiple, $parameters = '') {
    
	$field = '<select name="' .$name . '"';

    if (tep_not_null($parameters)) $field .= ' ' . $parameters;

    $field .= '>';

   
    for ($i=0, $n=sizeof($values); $i<$n; $i++) {
      $field .= '<option value="' . $values[$i]['id'] . '"';
	  if($multiple=='n'){
      if ($default == $values[$i]['id']) {
        $field .= ' selected';
      }}else{
	  if(count($default)>0){
	  for($j=0;$j<count($default) ;$j++)
	  			{
	  		if($values[$i]['id']== $default[$j]) 
			{
       	 	$field .= ' selected';
      		}
	  }
	  }}

      $field .= '>' . $values[$i]['text'] . '</option>';
    }
    $field .= '</select>';

       return $field;
  }
function tep_not_null_old($parameters){
if(strlen($parameters)>0)
return true;
else 
return
false;
}

//for new random password
function get_random_password(){
$t1 = date("mdy");
srand ((float) microtime() * 10000000);
$input = array ("A", "a", "B", "b", "C", "c", "D", "d", "E", "e", "F", "f", "G", "g", "H", "h", "I", "i", "J", "j", "K", "k", "L", "l", "M", "m", "N", "n", "O", "o", "P", "p", "Q", "q", "R", "r", "S", "s", "T", "t", "U", "u", "V", "v", "W", "w", "X", "x", "Y", "y", "Z", "z");
$rand_keys = array_rand ($input, 3);
$l1 = $input[$rand_keys[0]];
$r1 = rand(0,9);
$l2 = $input[$rand_keys[1]];
$l3 = $input[$rand_keys[2]];
$r2 = rand(0,9);

$password = $l1.$r1.$l2.$l3.$r2;
return $password ;
}
?>