{include file="$gentemplates/$header_tpl"}
{if !$edit}<script language="JavaScript" type="text/javascript" src="{$site_root}{$template_root}/js/location.js"></script>{/if}
<script language="JavaScript" type="text/javascript" src="{$site_root}{$template_root}/js/jquery.form.js"></script>
<div>  
	{if !$edit}
		<h2>{$lang.registration.top_header}</h2>
	{/if}
	{if $form.err || $nok}
		{*if $form.err}
			<p class="error_msg">*&nbsp;{$form.err}</p>
		{/if*}
		{if $nok}
			<p class="error_msg">*&nbsp;{$nok}</p>
		{/if}
	{/if}
	{if $changed_fields_str}
		<div class="error_msg">
			*&nbsp;{$lang_sharing_tools.proile_bad_notice1}:<br>
			{$changed_fields_str}
		</div>
	{/if}
	{if !$edit}
		<h3 class="p-b5" style="margin-top:0px;">{$lang.registration.step}&nbsp;{$page}:&nbsp;{$lang.users.page.$page}</h3>
	{else} 
		<h2>{$lang.users.page.$page}</h2>
	{/if}
	<form method="post" action="{$site_root}/{$seo.registration}" enctype="multipart/form-data" name="profile" id="profile">
		<input type="hidden" name="sel" value="ajax">
		<input type="hidden" name="edit" value="{$edit}">
		<input type="hidden" name="page" value="{$page}">
		<input type="hidden" id="pair" name="pair" value="{$pair}">
		{foreach item=item from=$elements name=elements}
				{if $item.couple}
					<table width="100%" cellspacing="0" cellpadding="0"><tr><td width="50%" class="no_couple">
				{/if}
				{assign var="background" value="1"}
				{assign var=elem_html value=$item.elem_html}
				{include file="$site_path/$template_root/registration_edit_element.tpl"}
				{if $item.couple}
					{assign var=elem_html value=$item.couple_elem_html}
                    {assign var=couple value=1}
						</td>
						<td width="50%" class="for_couple" style="{if !$pair}display:none;{/if}">
	<!------------------------->
							{include file="$site_path/$template_root/registration_edit_element.tpl"}
	<!------------------------->
						</td>
                        {assign var=couple value=0}
					</tr>
					</table>
					{if $edit eq 0}

					{/if}
				{/if}
			{*/if*}
		{/foreach}
		
		<script>
			{if !$edit}
			{literal}
				$('.for_couple').find('input, select, textarea').each(function(){
					$(this).attr('name', 'couple_'+$(this).attr('name'));
				});
			{/literal}
			{/if}
		</script>
		
		<div style="margin: 0px; height: 43px;">
			{if $edit}
				<input type="button" class="big_button" onclick="javascript: document.location.href='{$site_root}/{$seo.myprofile}?edit=1';" value="{$lang.button.back}">&nbsp;&nbsp;
				<input type="submit" class="big_button" value="{$lang.registration.save}">
			{else}
				{if $form.num eq 1}
				<input type="submit" class="big_button" value="{$lang.registration.signup}">
				{else}
				  {if $next_page}
					<input type="submit" class="big_button" value="{$lang.registration.next}">
				  {else}
					<input type="submit" class="big_button" value="{$lang.registration.profile}">
					{/if}
				{/if}
			{/if}
		</div>
	</form>
	<div id="divToUpdate"></div>
	<div onclick="scrollmain();" id="divToScroll"></div>
</div>
	{* {if $banner.right}<div style="float: left;">{$banner.right}</div>{/if}	*}	  							

{literal}
<script language="JavaScript" type="text/javascript">

$('.for_couple').find('#region_div').attr('id','couple_region_div');
$('.for_couple').find('#city_div').attr('id','couple_city_div');

function scrollmain(){
    var offset = $('.error_input:first').offset();
    if(offset){
        var mini = offset.top;
        $('.error_input').each(function(){
            tmp = $(this).offset();
            if(mini > tmp.top){
                mini = tmp.top;
            }
        });
        if(mini < 15) mini = 0;
        parent.window.scroll(0,mini-15);
    }
}
{/literal}
{if $form.num eq 1 && $edit eq 0}
	{literal}
	try{
		SelectUserTypes('rpt','{/literal}{$no_pair}{literal}', document.getElementById('user_subtype_div'));
	}catch(e){};

	try{
		SelectUserTypes('rptc','{/literal}{$no_pair_for}{literal}', document.getElementById('looking_user_subtype_div'));
	}catch(e){};
	{/literal}
{/if}
{literal}


function checkall(obj){
	if($(obj).attr('checked'))
	{
		$('.id_relationship_uniq').attr('disabled', 'true');
		$('.id_relationship_uniq').attr('checked', '');
	}else{
		$('.id_relationship_uniq').attr('disabled', '');
	}
}

span_all();
function span_all(){
	$('.name_for_lang').each(function(){
        if($(this).attr('mandatory') == 1){
            if($(this).find('.mandatory').html() == null){
                if($(this).find('p').html() != null)
                    $(this).find('p:last').append(' <span class="mandatory"><font class="error_msg">*</font></span>');
                else
                    $(this).append(' <span class="mandatory"><font class="error_msg">*</font></span>');
            }
        }
	});
}

function before_submit(){
    $('.for_couple').find('#couple_region_div').find('select[name=id_region]').attr('name', 'couple_id_region');
    $('.for_couple').find('#couple_city_div').find('select[name=id_city]').attr('name', 'couple_id_city');
}

function send_regreq(edit){

}

$(document).ready(function() {
	var options = {
		target: '#divToUpdate',
		beforeSubmit:  before_submit,
		success: function(data){
            data;
        }
	};
	$('#profile').ajaxForm(options);

	$('#div_id_relationship').find('.all').click(function(){
		if($('#div_id_relationship').find('.all').is(':checked')){
			$('#div_id_relationship').find('input[type="checkbox"]').attr('checked', 'checked');
			$('#div_id_relationship').find('input[type="checkbox"][class!="all"]').attr('disabled','disabled');
		}else{
			$('#div_id_relationship').find('input[type="checkbox"]').removeAttr('checked');
			$('#div_id_relationship').find('input[type="checkbox"][class!="all"]').removeAttr('disabled');
		}
	});
	if($('#div_id_relationship').find('.all').is(':checked')){
		$('#div_id_relationship').find('input[type="checkbox"]').attr('checked', 'checked');
		$('#div_id_relationship').find('input[type="checkbox"][class!="all"]').attr('disabled','disabled');
	}
	$('#div_couple_id_relationship').find('.all').click(function(){
		if($('#div_couple_id_relationship').find('.all').is(':checked')){
			$('#div_couple_id_relationship').find('input[type="checkbox"]').attr('checked', 'checked');
			$('#div_couple_id_relationship').find('input[type="checkbox"][class!="all"]').attr('disabled','disabled');
		}else{
			$('#div_couple_id_relationship').find('input[type="checkbox"]').removeAttr('checked');
			$('#div_couple_id_relationship').find('input[type="checkbox"][class!="all"]').removeAttr('disabled');
		}
    });
    if($('#div_couple_id_relationship').find('.all').is(':checked')){
        $('#div_couple_id_relationship').find('input[type="checkbox"]').attr('checked', 'checked');
		$('#div_couple_id_relationship').find('input[type="checkbox"][class!="all"]').attr('disabled','disabled');
    }
});


function CharCountChecker(obj){
	if(obj.value.length>=165)
	  return false;
	else
	  return true;
}


function ErrorBorder(field) {
	field.style.border = "1px solid #ff0000";
	return;
}

function NoBorder(field) {
	field.style.border = "1px solid #7f9db9";
	return;
}

function showcouple()
  {
	 couple=document.forms.profile.elements.couple;
	 couple_show=true;
	 for (i=0;i<couple.length;i++)
	  {
		if ((couple[i].checked)&&(couple[i].value=="0"))
		 {
		   couple_show=false;
		   break;
		 }
	  }
	 if (couple_show)
	  {
		document.getElementById('couple_user_form').style.display="block";
	  }
	 else
	  {
		document.getElementById('couple_user_form').style.display="none";
	  }
	 return false;
}


function Change(par) {

	if (par == 'N') {
		$(".for_couple").hide();
		document.getElementById('pair').value = '0';
	} else if (par == 'Y') {
		$(".for_couple").show();
		document.getElementById('pair').value = '1';
	} else {
		document.getElementById('pair').value = '0';
	}
}

function SelectUserTypes (section, id_usertypes, destination) {
        $.ajax({
		url: SEO_SITE_ROOT+'/location.php',
		data: {sec:section, sel: "usertypes", id_usertypes: id_usertypes},

		success: function (data, textStatus) {
				$(destination).html(data);
			}
	});
}

function Clear() {

}

function Check() {
	for ( var i=1; i<={/literal}{$user_types|@sizeof}{literal};i++) {
		if ( (document.getElementById('user_type_'+i).checked == true) && (document.getElementById('im_'+i).value == 'N') ) {
			if (!CheckValue()) return false;
		}
		if ( (document.getElementById('user_type_'+i).checked == true) && (document.getElementById('im_'+i).value == 'Y') ) {
			if (!CheckValuePair()) return false;
		}
	}
	return true;
}

function CheckValue(){};
function CheckValuePair(){};

function ChangeAgreed(par) {
	if (par == '0') {
		document.getElementById('error_agreed').style.display = 'none';
	}
	if (par == '1') {
		document.getElementById('error_agreed_1').style.display = 'none';
	}
}
{/literal}
var resize=0;
</script>
{include file="$site_path$index_theme_path/like.tpl"}
{include file="$gentemplates/$footer_tpl"}