<?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.                                         #
##################################################################
*/
?>
<?php
require_once ("config.inc.php");
require_once ("includes/mysql.inc.php");
require_once ("classes/misc.class.php");
require_once ("classes/userside.class.php");
//require_once ("includes/userlogincheck.inc.php");
require_once ("includes/arrays.inc.php");

$message	= $_GET['message']!=''?$_GET['message']:"";
$script		= "";
$mail		= "";

if (!$objDB) {
	$message	= "Unable to Locate Database Server.";
} else {
	$objM		= new misc($objDB);
	$objU		= new userside($objDB);
	if (isset($_POST['LN'])) {
		$message	= $objM->login($_POST);
		if ($message == "") {
			header("Location: myprofile.php");
			exit;
		}
	}
	$script		= $objM->get_script($message);
	$message	= $objM->remove_script($message);
	$arrCountry	= $objU->get_country_list();
	foreach ($arrCountry as $key=>$value)
		$objU->vCountry	= $value;

	//$arrState	= $objU->get_state_list($objU->vCountry);
	$arrState	= $objU->get_state_list($objU->vCountry);
	foreach ($arrState as $key=>$value)
		$objU->vState	= $value;
	$arrCounty	= $objU->get_county_list('ALABAMA');

	if (isset($_SESSION['search_profile']) AND $_SESSION['search_profile'] <> "") {
		$objU->arrSearch	= unserialize($_SESSION['search_profile']);
		if (isset($objU->arrSearch['vCountry']) AND isset($objU->arrSearch['vState'])) {
			$objU->vCountry	= $objU->arrSearch['vCountry'];
			$objU->vState	= $objU->arrSearch['vState'];
			$arrCounty	= $objU->get_county_list($objU->vState);
		}
		$age_from	= $objU->arrSearch['vSAF'];
		$age_to		= $objU->arrSearch['vSAT'];
		
	} else {
		$age_from		= (isset($_SESSION['age_from'])&&$_SESSION['age_from']<>"")	?	$_SESSION['age_from']		:	"20";
		$age_to			= $age_from	+ 15;
		if ($age_to > 99) $age_to	= 99;
	}
	 $user_gender	= (isset($_SESSION['user_gender'])&&$_SESSION['user_gender']<>"")	?	$_SESSION['user_gender']	:	"Male";
}
include_once ("title.inc.php");
include_once ("tophtml.inc.php");
?>
<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';
	}
}

</script>
</script>
<script type="text/javascript"  src="js/ajax.js"></script>
<script type="text/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 getCountyList_First(sel)
{
//	var countryCode = sel;
//	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='txt-bx-big-search' value='<?php echo $objU->arrSearch['vState'];?>' size='40' maxlength='100'>")
        
}


$(window).load(function(){
   
   <?php if(count($arrState) == 0 ) { 
   	    $dummy = $arrCountry;
   	    $country = isset($objU->arrSearch['vCountry']) && $objU->arrSearch['vCountry'] != '' ? $objU->arrSearch['vCountry'] : array_shift($dummy);
   		
   	?>
           
       //var obj = document.getElementById('girish_county');  
   getStateList('<?php echo $country;?>');
    <?php } ?>
});

</script>

<div class="row">
	<div class="search-rslts01">
		<div class="row">
			<div class="inenr-hd"><h2>Advanced Search</h2></div>
		</div>
		
		<div class="full_row maintext1">
			<form name="frmSearch" method="post" action="search_profiles.php"> 
				<div class="full_row warning">
					<?php
						if (isset($message) && trim($message) != '') {
						echo $message;
						}//end if
					?>
				</div>
				
				<div class="full_row">
					<div class="three columns">I am a </div>
					<div class="five columns margin_R_390">
						<select name="vSG" class="select-big">
							<option value="Female" <?php echo ($user_gender == "Male") ? "selected" : "" ?>>Man looking for a Woman</option>
							<option value="Male" <?php echo ($user_gender == "Female") ? "selected" : "" ?>>Woman looking for a Man</option>
							<?php if($enable_same_sex_search == 'Y')
							{ ?>
							<option value="Females" <?php echo ($_SESSION['gender_search']=="Females") ? "selected" : ""?>>Women looking for a Woman</option>
							<option value="Males" <?php echo ($_SESSION['gender_search']=="Males") ? "selected" : ""?>>Man looking for a Man</option>
							<?php } ?>
						</select>
					</div>
				</div>
				<div class="full_row">
					<div class="three columns">Between ages</div>
					<div class="five columns margin_R_390">
						<div class="five columns">
							<select name="vSAF" class="select-small_1">
								<?php foreach ($arrPartnerAgeFrom as $key => $value) { ?>
									<option value="<?php echo $value ?>" <?php echo $age_from == $value ? "selected" : "" ?>>
										<?php echo $value ?>
									</option>
								<?php } ?>
							</select>
						</div>
						<div class="two columns" align="center">to</div>
						<div class="five columns">
							<select name="vSAT" class="select-small_1">
								<?php foreach ($arrPartnerAgeFrom as $key => $value) { ?>
									<option value="<?php echo $value ?>" <?php echo $age_to == $value ? "selected" : "" ?>>
										<?php echo $value ?>
									</option>
								<?php } ?>
							</select>
						</div>
					</div>
				</div>
				<div class="full_row margin_bottom_20">
					<div class="three columns">With photo</div>
					<div class="five columns margin_R_390">
						<input type="checkbox" name="vSP" value="Y" <?php echo isset($objU->arrSearch['vSP']) && $objU->arrSearch['vSP'] == "Y" ? "checked" : "" ?>>
					</div>
				</div>
				<div class="full_row">
					<div class="three columns">Country</div>
					<div class="five columns margin_R_390">
						<select name="vCountry" class="select-big" id="girish_country" onchange="getStateList(this.value)";>
							<?php foreach ($arrCountry as $key => $value) { ?>
							<option value="<?php echo stripslashes($value) ?>" <?php echo isset($objU->arrSearch['vCountry']) && $objU->arrSearch['vCountry'] == $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_390" id="girish_state_cont">
						<select name="vState" class="select-big" id="girish_state" onchange="getCountyList(this)";>
							<?php foreach ($arrState as $key => $value) { ?>
							
							<option value="<?php echo stripslashes($value) ?>" <?php echo isset($objU->arrSearch['vState']) && stripslashes($objU->arrSearch['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_390"><input name="SearchNow" type="submit" class="search-sml-btn" value="Search Now"></div>
				</div>
			</form>
		</div>
		
		<div class="clear"></div>
		
		<div class="row"><h2 class="headings2 border-bottom">Browse Profiles</h2></div>
		
		<div class="full_row maintext1">
			<form name="frmSearch" method="post" action="search_profiles.php">  
				<div class="full_row">
					<div class="three columns">Whose gender is</div>
					<div class="five columns margin_R_390">
						<select name="vSG" class="select-big">
							<option value="Male" <?php echo ($user_gender == "Female") ? "selected" : "" ?>>Male</option>
							<option value="Female" <?php echo ($user_gender == "Male") ? "selected" : "" ?>>Female</option>
						</select>
					</div>
				</div>
				<div class="full_row">
					<div class="three columns">&nbsp;</div>
					<div class="five columns margin_R_390">
						<input name="SearchNow" type="submit" class="search_sec_btt" value="Browse now">
					</div>
				</div>				
			</form>
		</div>
				
		<div class="clear"></div>
		
		<div class="row"><h2 class="headings2 border-bottom">View Profile</h2></div>
		
		<div class="full_row maintext1">
			<form name="frmView" method="post" action="search_profiles.php">
				<div class="full_row">
					<div class="three columns">Username</div>
					<div class="five columns margin_R_390">
						<input name="vUN" id="txtUsername" type="text" size="20" maxlength="100"  class="txt-bx-big-search" value="<?php echo $name ?>">
					</div>
				</div>
				<div class="full_row">
					<div class="three columns">&nbsp;</div>
					<div class="five columns margin_R_390">
						<input name="VP" type="submit" class="search_sec_btt" value="View Profile">
					</div>
				</div>
			</form>
		</div>

	</div>
	<div id="hide"><?php echo $script ?></div>
</div>

<?php //include_once("left.inc.php"); ?>



<?php include_once('bottomhtml.inc.php');?>
