<?php 
/*
##################################################################
#                       PHP 4&5 MySQL 4&5                        #
##################################################################
#           Copyright (c) 2004-2008 Armia Systems Inc            #
##################################################################
#               This file is part of Cybermatch site             #
##################################################################
#    Developed By: simi (simi@armia.com)                         #

##################################################################
#               Developed On:   03-04-2008                       #
##################################################################
#               Modified By:                                     #
##################################################################
#               Modified On:                                     #
##################################################################
# This script may not be distributed, sold, given away for free  #
# to third party, or used as a part of any internet services 	 #
# such as webdesign etc.                                         #
##################################################################
*/

require_once ("config.inc.php");
require_once ("includes/userlogincheck.inc.php");
require_once ("includes/mysql.inc.php");
require_once ("includes/arrays.inc.php");
require_once ("classes/settings.class.php");
require_once ("classes/userside.class.php");
require_once ("classes/misc.class.php");

$objC		= new check();
if (!$objDB) {
	$message	= "Unable to Locate Database Server.";
} else {
	$objU			= new userside($objDB);
	$objS			= new settings($objDB);
	$objM			= new misc($objDB);
	$objS->set_variables();

	$arrCountry	= $objU->get_country_list();
	
	if (isset($_POST['CON1'])) {
		$objU->set_values($_POST);
		$message	= $objU->update_primaries($_SESSION['user_id']);
		$arrState	= $objU->get_state_list($objU->vCountry);
		$arrCounty	= $objU->get_county_list($objU->vState);
	} else {
		$array	= $objU->select($_SESSION['user_id']);
                
		/*
                $arrDob=explode("-",$array['dDob']);
		list($year,$month,$date)=$arrDob;
		$dob=$month."-".$date."-".$year;
		$objU->dDob=$dob;
                */
		$objU->set_values($array);
		$arrState	= $objU->get_state_list($objU->vCountry);
		$arrCounty	= $objU->get_county_list($objU->vState);
	}

	/*$country	= "";
	if (!empty($arrCountry))
		foreach ($arrCountry as $key=>$value)
			$country	= $value;
	$arrState	= $objU->get_state_list($country);
	$state		= "";
	if (!empty($arrState))
		foreach ($arrState as $key=>$value)
			$state	= $value;
	$arrCounty	= $objU->get_county_list($state);*/

        if($array['dDob']!='')
        {
                $arrDob=explode("-",$array['dDob']);
                list($year,$month,$date)=$arrDob;
                $objU->dDob=$month."/".$date."/".$year;
        }//end if
        else
        {
                $array	= $objU->select($_SESSION['user_id']);
                $arrDob=explode("-",$array['dDob']);
                list($year,$month,$date)=$arrDob;
                if($year<0)
{
    $year='0000';
}
                
                $objU->dDob=$month."/".$date."/".$year;
        }//end else

	$script		= $objM->get_script($message);
	$message	= $objM->remove_script($message);
}
include_once ("title.inc.php");
include_once ("tophtml.inc.php");
?>

<link rel="stylesheet" type="text/css" media="all" href="styles/dhtmlgoodies_calendar.css?random=20051112" />
<script type="text/javascript" src="js/dhtmlgoodies_calendar.js?random=20060118"></script>
<style type="text/css">
  div.calendar_widget { position: absolute; top: 0px; left: 0px; width:140px; height: 200px; display: none; }

</style>
<script type="text/javascript"  src="js/googlefix.js"></script>
<script language="javascript" type="text/javascript">
function changeCSS(obj, type)
{
	if (type == 'text') {
		obj.className = 'textbox';
	} else if (type == 'textarea') {
		obj.className = 'textbox_textarea';
	} else if (type == 'select') {
		obj.className = 'textbox';
	} else {
		obj.className = 'textbox';
	}
}
function validate2()
{
	var frm	= document.frmStep1;
	if (frm.dDob.value == "") {
		alert("Please select date of birth.");
		frm.dDob.focus();
		frm.dDob.className ='errorinput';
		return false;
	}

	//if (frm.vCity.value == "") {
	//	alert("Please enter city of user.");
	//	frm.vCity.focus();
	//	frm.vCity.className ='errorinput';
	//	return false;
	//}
	return true;
}
</script>
<script type="text/javascript"  src="js/ajax.js"></script>
<script type="text/javascript" language="javascript">
var ajax = new Array();
var sajax = new Array();

function getStateList(sel)
{      $('#girish_state_cont').html('<select name="vState" class="textbox3 txt-bx01" id="girish_state"></select>');
	var stateCode = sel;
	document.getElementById('girish_state').options.length = 0;	// Empty city select box
	if(stateCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = 'get_state_list.php?id='+stateCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createStateList(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}
function createStateList(index)
{
	var obj = document.getElementById('girish_state');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}

function getCountyList(sel)
{       
	var countryCode = sel.options[sel.selectedIndex].value;
	document.getElementById('girish_county').options.length = 0;	// Empty city select box
	if(countryCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = 'get_county_list.php?id='+countryCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createCountyList(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createCountyList(index)
{
	var obj = document.getElementById('girish_county');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}
function showstatetext() 
{
    
    
            
            $('#girish_state_cont').html("<input type='text' name='vState' class='textbox' value='<?php echo $objU->vState;?>' size='40' maxlength='100'>")
        
}


$(window).load(function(){
   
   <?php if(!$arrState){ ?>
           
       //var obj = document.getElementById('girish_county');  
   getStateList('<?php echo $objU->vCountry;?>');
    <?php } ?>
});

</script>

<div class="row">
	<div class="eight columns">
		<div class="search-rslts">
			<div class="row"><div class="inenr-hd"><h2>My Primaries</h2></div></div>
			<div class="row">
				<h2 class="headings2">Primaries</h2>
			</div>
			<div class="row">
				<form name="frmStep1" method="post" action="<?php echo $_SERVER['PHP_SELF']?>" onSubmit="return validate2();">
					<div class="newdesignforinput maintext1">
						<?php if(isset($message) && trim($message)!='')
							  { ?>
						<div class="full_row">
							<div class="maintext1 warning"><?php echo $message;?></div>
						</div>
						<?php }//end if?>

						<div class="full_row">
							<div class="three columns">Profile Display Type</div>
							<div class="five columns margin_R_200">
								<select name="vProfileType" class="textbox txt-bx01" >
									<?php foreach ($arrProfileType as $key => $value) { ?>
									<option value="<?php echo stripslashes($key)?>" <?php echo $objU->vProfileType == stripslashes($key) ? "selected" : ""?>>
									<?php echo stripslashes($value)?>
									</option>
									<?php } ?>
								</select>
							</div>
						</div>
						
						<div class="full_row">
							<div class="twelve">Note: If you want to change your Profile Display Type as 'Professional', you have to buy one of profile writing product; this will come in effect only if the Administrator has written a profile for you.</div>
						</div>

						<div class="full_row">
							<div class="three columns">Birthdate (mm/dd/yyyy)</div>
							<div class="five columns margin_R_200">
								<input id='dDob' onClick="javascript:void(0);" name="dDob" value="<?php echo date('m/d/Y',strtotime($objU->dDob))?>" class="textbox txt-bx01" readonly style="width:87%; ">
                         		<img src="images/cal.gif" value="Cal" onclick="displayCalendar(document.forms[0].dDob,'mm/dd/yyyy',this)"/>
							</div>
						</div>

						<div class="full_row">
							<div class="three columns">Country</div>
							<div class="five columns margin_R_200">
								<select name="vCountry" class="textbox3 txt-bx01" id="girish_country" onchange="getStateList(this.value)";>
									<?php foreach ($arrCountry as $key => $value) { ?>
									<option value="<?php echo stripslashes($value)?>" <?php echo stripslashes($objU->vCountry) == stripslashes($value) ? "selected" : ""?>>
									<?php echo stripslashes($value)?>
									</option>
									<?php } ?>
								</select>
							</div>
						</div>

						<div class="full_row">
							<div class="three columns">State</div>
							<div class="five columns margin_R_200" id="girish_state_cont">
								<select name="vState" class="textbox3 txt-bx01" id="girish_state">
									<?php foreach ($arrState as $key => $value) { ?>
									<option value="<?php echo stripslashes($value)?>" <?php echo $objU->vState == stripslashes($value) ? "selected" : ""?>>
									<?php echo stripslashes($value)?>
									</option>
									<?php } ?>
								</select>
							</div>
						</div>

						<div class="full_row">
							<div class="three columns">&nbsp;</div>
							<div class="five columns margin_R_200">
								<input name="CON1" type="submit" class="loginbutton" value="Save"><input type="hidden" name="step" value="3">
							</div>
						</div>
					</div>
				</form>
			</div>
			<div id="hide"><?php echo $script?></div>
		</div>
	</div>
	<div class="four columns right search_result_R">
		<?php include_once ("left.inc.php");?>
	</div>
</div>



<div class="calendar_widget" id="calendar_widget" style="display:none "><iframe id='calendar_widget_iframe' name='calendar_widget_iframe' style="border: none;" width=100% height=100% src="date/calendar_widget.html" /></div>
<?php include_once('bottomhtml.inc.php');?>
