// JavaScript Document
var last_show_id = 'page1';
var last_td_show = 'td_page1';

var last_rd_show = null;
var active_tele = 0;

function showList(show_id,td_show)
{		
	if(last_show_id!=show_id&&last_td_show!=td_show)
	{			
		$('#' +last_show_id).hide();   
		$('#' + show_id).show();
		$('#' + td_show).addClass('client_menu_active').removeClass('client_menu');
		$('#' + last_td_show).addClass('client_menu').removeClass('client_menu_active');
	}
	last_show_id = show_id;
	last_td_show = td_show;
}


function showText(text_id)
{		
	if($('#' + text_id).attr("status")=='hide')
	{				
		$('#' + text_id).show();
		$('#rd_' + text_id).attr('checked',true);
		$('#' + text_id).attr("status",'show');
	}
	else
	{
		$('#' + text_id).hide();
		$('#rd_' + text_id).attr('checked',false);
		$('#' + text_id).attr("status",'hide');
	}
}


function showTextReason(show_id)
{		
	if(last_rd_show == null)
	{				
		$('#' + show_id).show();
		$('#rd_' + show_id).attr('checked','checked');
	}
	if(show_id != last_rd_show )
	{				

		$('#' + show_id).show();
		$('#rd_' + show_id).attr('checked','checked');
		$('#' + last_rd_show).hide();
		$('#in_' + last_rd_show).val('');
		$('#rd_' + last_rd_show).attr('checked','');
	}
	if(show_id=='rd_telephone')
	{
		$('#' + last_rd_show).hide();
		$('#rd_' + last_rd_show).removeAttr("checked");
		$('#' + last_rd_show).attr("status",'hide');	
	}
	if(show_id=='for_calulating')
	{
		$('#' + last_rd_show).hide();
		$('#rd_' + last_rd_show).attr('checked','');
	}
	last_rd_show = show_id;
}

function uncheck_ch_info_reload()
{
	for(i=1;i<=22;i++)
	{
		$('#ch_info_'+i).each(function(){
				$(this).attr('checked', false);
		});
	}
	n=0;
}


function countChecked(id) 
{
	
	if($('#ch_info_'+id).attr('checked')==true)
	{
		n++;
			}
	else
	{
		n--;
	}
	if($('#check_page1').attr('checked')==true)
	{
		$('#check_page1').attr('checked',false);
		$('#check_page1').attr('status','uncheck');
	}
	if($('#check_page2').attr('checked')==true)
	{
		$('#check_page2').attr('checked',false);
		$('#check_page2').attr('status','uncheck');
	}

}
function show_telephone(show_id,status) 
{
	if(status==1){
		$('#' + show_id).show();
		active_tele =1;
	}else{
		$('#' + show_id).hide();
		active_tele =status;
	}
}

function select_country()
{
	$phone_code = $('#country').val();
	$phone = $('#client_phone').val();
	$status =$phone.indexOf($phone_code);
	if($phone.indexOf($phone_code)!=-1)
	{
		$phone = $phone;
	}
	else
	{
		$phone = $phone_code;
	}
	
	$('#client_phone').val($phone);
}

