<?php

/*

 osCommerce, Open Source E-Commerce Solutions 
http://www.oscommerce.com 

Copyright (c) 2003 osCommerce 

osCommRes, Services Oline 
http://www.oscommres.com 
Copyright (c) 2005 osCommRes 

Freeway eCommerce 
http://www.zac-ware.com/freeway 
Copyright (c) 2007 ZacWare

Released under the GNU General Public License
*/
// Set flag that this is a parent file
	define( '_FEXEC', 1 );
	require('includes/application_top.php');
	tep_get_last_access_file();
	require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CREATE_ACCOUNT); 
	$command=isset($HTTP_GET_VARS['command'])?$HTTP_GET_VARS['command']:'';
	$country=isset($HTTP_GET_VARS['country_id'])?(int)$HTTP_GET_VARS['country_id']:0;
	 //ajax start
	if($command=='show_state'){
		 	$zone_ids="";
		 	$zone_name="";
	      $zones_query = tep_db_query("select zone_id,zone_name from " . TABLE_ZONES . " where zone_country_id = '" . tep_db_input($country) . "' order by zone_name");
	      while ($zones_values = tep_db_fetch_array($zones_query)) {
	         $zone_ids.=$zones_values['zone_id'].",";
	         $zone_name.=$zones_values['zone_name'].",";
	      }
	   $content='show_state'.substr($zone_ids,0,-1)."^".tep_output_string(substr($zone_name,0,-1))."^".$zone;    
	   echo $content; 
	   exit;
	}  
 //ajax end 
?> 
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/date-picker.js"></script>
<script language="javascript" src="includes/general.js"></script>
<script language="javascript" src="includes/http.js"></script>

<?php require('includes/password_strength.js.php'); ?>
<script language="javascript">
	function show_state(){
		var this_=document.account_edit.country;
		id=this_.options[this_.selectedIndex].value;
		if(id){
			command="<?php echo tep_href_link(FILENAME_CREATE_ACCOUNT,'command=show_state');?>&country_id="+id;
			do_get_command(command);
			if(document.getElementById("entry_state"))document.getElementById("entry_state").innerHTML="Loading...";
		}else{
			element=document.getElementById("entry_state").innerHTML="";
		}
	}
	function do_result(result){
		if(result!='' && result.substr(result.indexOf('show_state'),10)=='show_state'){
			result=result.substr(result.indexOf('show_state')+10,result.length);
			var textArr=new Array();
			var valueArr=new Array();
			splt=result.split("^");
			valueArr=splt[1].split(",");		
			textArr=splt[1].split(",");
			sel_zone=splt[2];
			var sel=document.getElementById("state");
			if(valueArr.length==1) {
				if(document.getElementById("state1")) document.getElementById("state1").style.display="";
				if(sel)	sel.style.display="none";
				
			}else if(valueArr.length>1){
				document.getElementById("state1").value="";
				document.getElementById("state1").style.display="none";
				sel.style.display="";
				optionElement=sel;
				// clear the previous details
				while(optionElement.options.length>0){
					optionElement.remove(optionElement.options.length - 1);
				}
				//create the new details
				for (icnt=0;icnt<textArr.length;icnt++){
				  var option = document.createElement('option');
				  option.text = textArr[icnt];
				  option.value = valueArr[icnt];
				  try {
					optionElement.add(option, null); // standards compliant; doesn't work in IE
				  }
				  catch(ex) {
					optionElement.add(option); // IE only
				  }
			}
			if(typeof(default_zone) != "undefined")
			for(i=0;i<optionElement.options.length;i++){
				if(optionElement.options[i].value==default_zone)
					optionElement.options[i].selected = true;
			}
			if(document.getElementById("state1") && typeof(default_country) != "undefined")
			if(default_country!=document.getElementById("country"))
				document.getElementById("state1").value="";
		}
	  }
	}
</script>
<?php 
	include('includes/date_format_js.php');
	require('includes/form_check.js.php');
?>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php
  require(DIR_WS_INCLUDES . 'header.php');
?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr> 
  
<!-- body_text //-->
<?php $add_option="";
		if (isset($HTTP_POST_VARS["param_event"]) && isset($HTTP_POST_VARS["param_session"])){
			$add_option.="&param_1=" . $HTTP_POST_VARS["param_event"];
			$add_option.="&param_2=" . $HTTP_POST_VARS["param_session"];
		}?>
		
    <td width="100%" valign="top"><form name="account_edit" method="post" <?php echo 'action="' . tep_href_link(FILENAME_CREATE_ACCOUNT_PROCESS, $add_option , 'SSL') . '"'; ?> onSubmit="return check_form();"><input type="hidden" name="action" value="process">
	<?php if (isset($HTTP_POST_VARS["param_event"]) && isset($HTTP_POST_VARS["param_session"])){
				echo '<input type="hidden" name="param_event" value="' . $HTTP_POST_VARS["param_event"] .'">';
				echo '<input type="hidden" name="param_session" value="' . $HTTP_POST_VARS["param_session"] .'">';
			}?><table border="0" width="100%" cellspacing="0" cellpadding="0">
       <!--<tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
            <td class="pageHeading"><?php //echo HEADING_TITLE; ?></td>
          </tr>
        </table></td>
      </tr> !-->
<?php
  if (sizeof($navigation->snapshot) > 0) {
?>
      <tr>
        <td class="smallText"><br><?php echo sprintf(TEXT_ORIGIN_LOGIN, tep_href_link(FILENAME_LOGIN, tep_get_all_get_params(), 'SSL')); ?></td>
      </tr>
<?php
  }
?>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
      <tr>
        <td>
<?php
  //$email_address = tep_db_prepare_input($HTTP_GET_VARS['email_address']);
  $account['entry_country_id'] = STORE_COUNTRY;
  $account['entry_zone_id'] = STORE_ZONE;
  $account['entry_city']=STORE_CITY;
  require(DIR_WS_MODULES . 'account_details.php');
?>
        </td>
      </tr>
      <tr>
        <td align="right" class="main" valign="middle"><br>
		<?php   echo tep_draw_checkbox_field("create_order",'Y') . '&nbsp;' . TEXT_CREATE_ORDER . '&nbsp;';
				
				echo tep_image_submit('button_confirm.gif', IMAGE_CONTINUE,'align=absmiddle'); ?>
		</td>
      </tr>
    </table></form></td>
<!-- body_text_eof //-->
    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
    </table></td>
  </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php
    require(DIR_WS_INCLUDES . 'footer.php');
?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>