<?


	

	$add_table = mysql_query("SELECT * FROM `user` WHERE `zags_user` = '1' LIMIT 1");
	if (mysql_num_rows($add_table)==0)
	mysql_query("
   CREATE TABLE IF NOT EXISTS `zags_user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `women` int(11) NOT NULL,
  `men` int(11) NOT NULL,
  `time` int(11) NOT NULL,
  `status` int(11) NOT NULL,
  `time_sv` int(11) NOT NULL,
  `feed` int(11) NOT NULL,
  `msg` varchar(9999) NOT NULL,
   PRIMARY KEY (`id`),
   KEY `women` (`women`,`men`)
   ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;
  ");
	
	
	if  (isset($_GET['razvod']) and $user['level'] > 0 and $user['level'] > $ank['level'] )
	mysql_query("DELETE FROM `zags_user` WHERE `men` = ".$ank['id']." or `women` = ".$ank['id']);
	
	
	
	$zags_st = mysql_fetch_array(mysql_query("SELECT * FROM `zags_user` 
	WHERE `men` = '".$ank['id']."' or `women` = '".$ank['id']."' LIMIT 1"));
	
	$men = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '". $zags_st['men'] ."' LIMIT 1"));
	$women = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '". $zags_st['women'] ."' LIMIT 1"));

	if ($zags_st != 0 and $zags_st['status'] == 1)
	echo "
	<div class='gmenu'><img src='/style/icons/zags.png'>	Брак
		<a href='/info.php?id=".$women['id']."'>
		<b>". $women['nick'] ."</b>
		</a> с  
		<a href='/info.php?id=".$men['id']."'>
		<b>". $men['nick'] ."</b> 
		</a>
		". ($ank['id'] == $user['id'] ? "
		[ :: <a href='/zags.php?ot=".$ank['id']."'>	развод 	</a> :: ]" : false )."
		
		
		". ($user['level'] > 0 && $user['level'] < $ank['level']  ? "
		[ :: <a href='?".$ank['id']."&razvod'>Расторгнуть свадьбу 	</a> :: ]" : false )."
		
		
		
		
		
	</div>";
	
	
	elseif( $ank['pol'] != $user['pol'] and  $user['pol'] == 1){
	if(mysql_result(mysql_query("SELECT COUNT(*) FROM `zags_user` WHERE `women` = '".$ank['id']."' and `status` = '0'"),0)!= 1 
	and $zags_st['women'] != 1)
	
	echo "<a href='/zags.php?zayavka=".$ank['id']."'><div class='nav2'>Предложить свадьбу </div></a>";
	
	}
	
	if(mysql_result(mysql_query("SELECT COUNT(*) FROM `zags_user` 
	WHERE `women` = '".$ank['id']."' and `status` = '0'"),0) != 0 
	and $ank['id'] == $user['id'])
	{
	echo "
		<div class='gmenu'>
			Вам предложений о свадьбе от
			<a href='/info.php?id=".$men['id']."'>
			". $men['nick'] ." 
			</a>
			<br/>
			<a href='/zags.php?pr=".$ank['id']."'>
			принять заявку 
			</a> :: 
	
			<a href='/zags.php?ot=".$ank['id']."'>
			отклонить
			</a>
		</div>
		";
	
	}
	
	
	