<?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 ervices such #
# as webdesign etc.                                              #
##################################################################
*/
require_once ("../config.inc.php");
require_once ("../includes/mysql_mobile.inc.php");
require_once ("../classes/misc.class.php");
require_once ("../classes/userside.class.php");
require_once ("../includes/userlogincheck.mobile.inc.php");
require_once ("../includes/arrays.inc.php");

$message	= "";
$script		= "";
$mail		= "";

if (!$objDB) {
	$message	= "Unable to Locate Database Server.";
} else {
	$objM		= new misc($objDB);
	$objU		= new userside($objDB);
	$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);
	foreach ($arrState as $key=>$value)
		$objU->vState	= $value;
	$arrCounty	= $objU->get_county_list($objU->vState);
	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";
}
?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head><title>Cybermatch</title>
<link href="images/mobile.css" rel="stylesheet" type="text/css" />
<script type="text/javascript"  src="images/ajax.js"></script>
<script type="text/javascript">
var ajax = new Array();
var sajax = new Array();

function getStateList(sel)
{
	var stateCode = sel.options[sel.selectedIndex].value;
	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	
}
</script>

</head>
<body>
<div xmlns="http://www.w3.org/1999/xhtml">
<?php include_once('title.inc.php');?>
<div>&nbsp;</div>
    <div>
       <div> <i>+</i> <a href="index.php">Home</a></div>
       <div>  <i>+</i> <a href="search.php">Search</a></div>
<?php if (!isset($_SESSION['userlogged']) OR $_SESSION['userlogged'] == "") {?>
        <div><i>+</i> <a href="login.php">Login</a> </div>
<?php } ?>		
	   
    </div>
<div>&nbsp;</div>
<?php if (isset($_SESSION['userlogged']) AND $_SESSION['userlogged'] == "YES") {?>
<div class="body">
    <div>
        <div><i>+</i> <a href="logout.php" accesskey="1">Logout&nbsp;&nbsp;&nbsp;</a> </div>
        <div><i>+</i> <a href="dashbox.php" accesskey="2">Account</a> </div>
    </div>
</div>
<div>&nbsp;</div>
<?php } ?>

<a name="search"></a><strong>Search Now</strong>
<div>&nbsp;</div>
<div class="message"><?php echo $message?></div>
<div>&nbsp;</div>
<form name="frmSearch" method="post" action="search_profiles.php">
<div>I am a:
<select name="vSG" class="selectbox">
                                      <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>
                          </select>
</div>
<div></div>
<div>Between ages : <select name="vSAF" class="inputel">
                                      <?php foreach ($arrPartnerAgeFrom as $key => $value) { ?>
                                      <option value="<?php echo $value?>" <?php echo $age_from==$value?"selected":""?>>
                                      <?php echo $value?>
                                      </option>
                                      <?php } ?>
                                    </select>
to
<select name="vSAT" class="inputel">
  <?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 align="left">With photo : <input name="vSP" type="checkbox" class="inputel" value="Y" <?php echo isset($objU->arrSearch['vSP'])&& $objU->arrSearch['vSP'] == "Y" ?"checked":""?> /></div>
<div>Country : 
  <select name="vCountry" class="inputel" id="girish_country" onchange="getStateList(this)";>
                                                                <?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>State :
 <select name="vState" class="inputel" 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>County : 
 <select name="vCounty" class="selectbox" id="girish_county" onChange="changeCSS(this, 'select');">
								  								<option value="">All</option>
                                    <?php foreach ($arrCounty as $key => $value) { ?>
                                    <option value="<?php echo stripslashes($value)?>" <?php echo isset($objU->arrSearch['vCounty'])&& stripslashes($objU->arrSearch['vCounty']) == stripslashes($value) ?"selected":""?>>
                                    <?php echo stripslashes($value)?>
                                    </option>
                                    <?php } ?>
                                  </select>
</div>

<div>&nbsp;</div>
<input value="   Search   " class="inputb" type="submit" name="SearchNow" />
</form>
<div><table width="100%"  border="0" cellspacing="0" cellpadding="10">
                      <tr>
                        <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td align="left"><table width="100%"  border="0" cellspacing="0" cellpadding="5">
                                  <tr>
                                    <td align="left" ><strong>Browse Profiles </strong></td>
                                  </tr>
                                </table>
                                </td>
                            </tr>
                          </table>
                            <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                              <form name="frmSearch" method="post" action="search_profiles.php">
                                <tr class="maintextCopy">
                                  <td align="center"><div class="message">
                                      <?php echo $message?>
                                  </div></td>
                                </tr>
                                <tr>
                                  <td align="center">
                                      <table width="90%"  border="0" cellpadding="3" cellspacing="0">
                                        <tr class="maintextCopy">
                                          <td width="44%" align="left">whose gender is </td>
                                          <td width="56%" colspan="2" align="left" class="sidelinks"><select name="vSG" class="selectbox">
                                              <option value="Male" <?php echo ($user_gender=="Female") ? "selected" : ""?>>man</option>
                                              <option value="Female" <?php echo ($user_gender=="Male") ? "selected" : ""?>>woman</option>
                                            </select>
</td>
                                        </tr>
                                        <tr align="left">
                                          <td colspan="2"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                                              <tr>
                                                <td class="underline"><strong><img src="images/spacer.gif" width="1" height="1"></strong></td>
                                              </tr>
                                          </table></td>
                                        </tr>
                                        <tr class="sidelinks">
                                          <td align="left">&nbsp;</td>
                                          <td colspan="2" align="left" class="sidelinks">&nbsp;</td>
                                        </tr>
                                    </table></td>
                                </tr>
                                <tr class="maintextCopy">
                                  <td><table width="100%" height="40"  border="0" cellpadding="0" cellspacing="0">
                                      <tr>
                                        <td width="38%" height="40">&nbsp;</td>
                                        <td width="36%"><span class="sidelinks">
                                          </span>
                                          <table class='DownloadButton' cellpadding='0' cellspacing='0' border='0' >
                                            <tr>
                                              <td class='ButtonLeft ButtonLeftBlue' />                                          
                                              <td class='ButtonMiddle MediumBuffer' />                                          
                                              <td class='ButtonMiddle Medium Bold'>
                                                <input value="   Browse Now   " class="LastButton" type="submit" name="SearchNow">
                                              </td>
                                              <td class='ButtonMiddle MediumBuffer' />                                          
                                              <td class='ButtonRight ButtonRightBlue' />                                          
                                            </tr>
                                          </table>
                                          <span class="sidelinks">                                          </span></td>
                                        <td width="26%" class="maintextCopy">&nbsp;</td>
                                      </tr>
                                  </table></td>
                                </tr>
                              </form>
                            </table>
                            <div id="hide" >
                              <?php echo $script?>
                          </div></td>
                      </tr>
                    </table></div>
<?php include_once('footer.inc.php');?>