<?php

if ( !defined( 'SMARTY_DIR' ) ) {

	include_once( 'init.php' );

}


$_SESSION['from'] = $countrycode = ($_SESSION['from']!= '') ? $_SESSION['from'] : $config['default_country'];

$lang['states'] = getStates($countrycode,'N');

if (count($lang['states']) == 1) {
	foreach ($lang['states'] as $key => $val) {
		$_SESSION['stateprovince'] = $key;
	}
} 

$_SESSION['stateprovince'] = ($_SESSION['stateprovince']!= '') ? $_SESSION['stateprovince'] : $config['default_state'];

if ($_SESSION['stateprovince'] != '') {

	$lang['counties'] = getCounties($countrycode, $_SESSION['stateprovince'], 'N');

	if (count($lang['counties']) == 1) {
		foreach ($lang['counties'] as $key => $val) {
			$_SESSION['countycode'] = $key;
		}
	}
	$_SESSION['countycode'] = ($_SESSION['countycode']!= '') ? $_SESSION['countycode'] : $config['default_county'];

	if ($_SESSION['countycode'] != '') {

		$lang['cities'] = getCities($countrycode, $_SESSION['stateprovince'], $_SESSION['countycode'], 'N');

		if (count($lang['cities']) == 1) {
			foreach($lang['cities'] as $key => $val) {
				$_SESSION['citycode'] = $key;
			}
		}

		$_SESSION['citycode'] = ($_SESSION['citycode']!= '') ? $_SESSION['citycode'] : $config['default_city'];

		if ($_SESSION['citycode'] != '') {

			$lang['zipcodes'] = getZipcodes($countrycode, $_SESSION['stateprovince'], $_SESSION['countycode'], $_SESSION['citycode'], 'N');
		}
		$_SESSION['zip'] = ($_SESSION['zip']!= '') ? $_SESSION['zip'] : $config['default_zipcode'];

	}
}

$_SESSION['lookfrom'] = $lookcountrycode = ($_SESSION['lookfrom']!= '') ?

$_SESSION['lookfrom'] : $config['default_country'];
/*
$_SESSION['timezone'] = '-25';
*/

$lang['lookstates'] = getStates($lookcountrycode,'Y');

$lang['signup_gender_values'] = get_lang_values('signup_gender_values');

$lang['signup_gender_look'] = get_lang_values('signup_gender_look');

$lang['tz'] = get_lang_values('tz');

$t->assign('zipsavailable',$osDB->getOne('select count(*) from ! where countrycode=?', array(ZIPCODES_TABLE, $lookcountrycode) ) );

if ($_SESSION['lookstateprovince'] != '') {

	$lang['lookcounties'] = getCounties($lookcountrycode, $_SESSION['lookstateprovince'], 'Y');

	if (count($lang['lookcounties']) == 1) {
		foreach ($lang['lookcounties'] as $key => $val) {
			$_SESSION['lookcounty'] = $key;
		}
	}

	if ($_SESSION['lookcounty'] != '') {

		$lang['lookcities'] = getCities($lookcountrycode, $_SESSION['lookstateprovince'], $_SESSION['lookcounty'], 'Y');

		if (count($lang['lookcities']) == 1) {
			foreach($lang['lookcities'] as $key => $val) {
				$_SESSION['lookcity'] = $key;
			}
		}

		if ($_SESSION['lookcity'] != '') {

			$lang['lookzipcodes'] = getZipcodes($lookcountrycode, $_SESSION['lookstateprovince'], $_SESSION['lookcounty'], $_SESSION['lookcity'], 'Y');
		}
	}
}

$_SESSION['radiustype'] = 'kms';

if ($lookcountrycode == 'US') {$_SESSION['radiustype'] = 'miles';}

$t->assign('password',$_SESSION['password'] );

$t->assign('password2',$_SESSION['password2'] );

$_SESSION['txtlookagestart'] = ($_SESSION['txtlookagestart'] > 0)? $_SESSION['txtlookagestart']:($config['end_year']*-1);

$_SESSION['txtlookageend'] = ($_SESSION['txtlookageend'] > 0)? $_SESSION['txtlookageend']:($config['start_year']*-1);

$t->assign ( 'signup_error',get_lang('errormsgs',$_GET['errid']) );

if ($_SESSION['selectedtime'] != '') {

	$t->assign('selectedtime', $_SESSION['selectedtime']);
	$_SESSION['selectedtime'] = '';

} else {

	$t->assign( 'selectedtime' , date( 'Y-m-d', mktime( 0, 0, 0, date('m'), date('d'), date('Y')-25)) );
}

$t->assign("promocnt", $osDB->getOne("select count(*) from ! where active=1", array(PROMO_TABLE) ) );

$t->assign('lang', $lang);

if ( $_GET['errid'] != '') {
	$t->assign("error_message", get_lang('errormsgs', $_GET['errid']) );
}

$t->assign('rendered_page',$t->fetch('signup.tpl'));

$t->display( 'index.tpl' );

?>
