
function fConfirm(href)
{
	if (confirm("Вы действительно хотите провести операцию удаления?"))
		location.href = href;
}

var input = new Array();

function fCheckBoxForm(id,type) // For @type=checkbox
{
	if (type==1)
	{
		if ($('#input'+id).attr('checked'))
		{
			input[id] = 1;
			$('#table'+id).show();
			$('#span'+id).html('-');
			$('#input'+id).attr('checked',true);
			$('#table'+id).find('input').attr('checked',true);
		}
		else
		{
			input[id] = 0;
			$('#table'+id).hide();
			$('#span'+id).html('+');
			$('#input'+id).attr('checked',false);
			$('#table'+id).find('input').attr('checked',false);			
		}	
	}
	else
	{
		if (!input[id])
		{
			input[id] = 1;
			$('#table'+id).show();
			$('#span'+id).html('-');
		}
		else
		{
			input[id] = 0;
			$('#table'+id).hide(); 
			$('#span'+id).html('+');
		}	
	}
}

var newForm = 1;

function fCheckLogin(oncl)
{
	if (oncl && newForm)
	{
		$('#iLogin').val('');
		txt = '';
		newForm = 0;
	}
	else
		txt = $('#iLogin').val();
	
	if (6>txt.length)
	{
		$('#tLogin').removeClass('okk');
		$('#tLogin').addClass('err');
		$('#dLogin').find('span').css('height','30px');
		$('#dLogin').find('span').html('Поле "<strong>Логин</strong>" не может быть менее "<strong>6</strong>" символов');
	}
	else if (txt.length>5)
	{
		$('#dLogin').find('span').html('<img src="/im/load.gif" alt="Загрузка"/>');
		$.ajax({
			type: 'GET',
			url: 'g_checklogin.php?login='+txt,
			data: {_ajax : 'ajax'},
			dataType: 'json',
			success: function(result)
					{
						if (result.ok==1)
						{
							$('#tLogin').removeClass('err');
							$('#tLogin').addClass('okk');		
						}
						else
						{
							$('#tLogin').removeClass('okk');
							$('#tLogin').addClass('err');		
						}						
						$('#dLogin').find('span').html(result.txt);
					}
		});
	}
}

function fClearErr(name)
{
    $('#'+name).removeClass('err');
    $('#'+name).find('div').find('span').html('');
}

function fPcBut(type)
{	
	if ($('#pcbut').html()=='Добавить!')
	{		
		if (type=='prod') // Обнуляем форму добавления каталога
		{ 
			$('#sctl').val(0); 
			$('#spricetype').val(0);
			$('#iprice').val('');
			fUploadCtl('');
		}
		$('#form2').show();
		$('#hiddenid').val(0);
		$('#pcbut').html('Скрыть!');
	}
	else
	{
		$('#form2').hide();
		$('#pcbut').html('Добавить!');
	}	
}

function fChPage(id)
{
	for (i=1;i<7;i++) 
		if (i==id) { $('#t'+id).show(); $('#d'+id).addClass('sel'); }
		else { $('#t'+i).hide(); $('#d'+i).removeClass('sel'); }
}

function fUploadCtl(requri)
{
	if (requri=='' && $('#sctl').val()!=0) requri = 'ctl='+$('#sctl').val();	
	if (requri!='')
	{
		$('#ctlblock').html('<dd class="load"> <img src="/im/load.gif" align="left" alt="Загрузка"/> Идет загрузка... </dd>');
		$.ajax({
			type: 'GET',
			url: 'g_ctlupload.php?'+requri,
			data: {_ajax : 'ajax'},
			dataType: 'json',
			success: function(result) 
			{ 
				$('#ctlblock').html(result.txt);
				if (result.unit) 
				{
					if ($('#hiddenid').val()==0)
					{
						$('#spricetype').val(0);
						$('#iprice').val('');
					}
					$('#priceunit').html(result.unit); 
				}
			}
		});
	}
}

timer = new Array(); 

function fShowHelp(id,off)
{
	if (timer[id]) clearTimeout(timer[id])
	if (off==1) timer[id] = setTimeout('fShowHelp('+id+',2)',100);
	else if (off==2) $('#si'+id).css('display','none'); 
	else $('#si'+id).css('display','block');
}

function fShowprodPic(id,off)
{
	if (timer[id]) clearTimeout(timer[id])
	if (off==1) timer[id] = setTimeout('fShowprodPic('+id+',2)',100);
	else if (off==2) $('#prod'+id).css('display','none'); 
	else $('#prod'+id).css('display','block');
}



function fShowWin(id)
{
	for (i=1;i<6;i++)
		if (id==i) $('#sublist'+i).css('display','block');
		else 
		{
			$('#sublist'+i).css('display','none');
			$('#sublist'+i).find('input').attr('checked',false);
		}
}

function fQuest()
{
	
	if($('#frm_form').hasClass('hide'))
	{
		$('#frm_form').removeClass('hide');
		$('#req').removeClass('reqer');
		$('#req').addClass('req');
	}
	else
	{
		$('#frm_form').addClass('hide');
		$('#frm_mess').html('');
	}	
}

$(document).ready(function()
{
	var max = $('#link1').height();
	var v2 = $('#link2').height();
	var v3 = $('#link3').height();
	var v4 = $('#link4').height();
	
	if (max<v2) max = v2;
	if (max<v3) max = v3;
	if (max<v4) max = v4;
	
	$('#link1').height(max);
	$('#link2').height(max);
	$('#link3').height(max);
	$('#link4').height(max);
});

