$(document).ready(function()
{
	if ($('#content-banner').size())
	{
		swfobject.embedSWF("/swf/atc.swf", "content-banner", "960", "360", "9.0.0", "", {}, {wmode:'transparent'});
	}
	if ($('#banner-catalog-1').size())
	{
		swfobject.embedSWF("/swf/960-100.swf", "banner-catalog-1", "960", "100", "9.0.0", "", {}, {wmode:'transparent'});
	}
	/*
	if ($('#content-banner').size())
	{
		$('#content-banner').loopedSlider();

	}
	*/
	if ($('#photo-sortable').size())
	{
		$('#photo-sortable ul').sortable(
		{
			cursor: 'move'
		});

	}
});
function tabSwitch (type, index, obj)
{
	$('.tab-'+type+' li a').removeClass('active');
	$(obj).addClass('active');
	$('.tab-'+type+'-div').addClass('hidden');
	$('#tab-'+type+'-'+index).removeClass('hidden');
}
function carsAddBrand ()
{
	if ($('#brand').val())
	{
		$('#model').load('/cars/get_model/'+$('#brand').val());
		$('#modify').html('<option></option>');
	}
}
function carsAddModel ()
{
	if ($('#model').val())
	{
		$('#modify').load('/cars/get_modify/'+$('#model').val());
	}
}
function popUp(url, width, height, bar, top, left){
	if(bar){bar=', scrollbars=1';}
	if(!width){width=730;}
	if(!height){height=485;}
	if(!top){top=Math.ceil(($(window).height()/2-height/2));}
	if(!left){left=Math.ceil(($(window).width()/2-width/2));}
	name='new_window';
	return window.open(url, name, 'width='+width+',height='+height+bar);
}
function inputImage(id, image, type)
{
	$('#'+id).attr('src', '/img/data/'+Math.ceil(image/1000)+'/'+image+'/'+type+'.jpg');
	if ($('#'+id+'-input').size())
	{
		$('#'+id+'-input').val(image);
	}
}
function inputImages(id, image, type)
{
	$('<div class="image"><a href="javascript:void(0);" onclick="$(this).parent().remove();" class="del"></a><input type="hidden" name="photo[]" value="'+image+'" /><img src="/img/data/'+Math.ceil(image/1000)+'/'+image+'/'+type+'.jpg" /></div>').insertBefore($('#'+id));
}
function searchForm (obj)
{
	if ($('#search .data').size())
	{
		if ($('#search .data').hasClass('hidden'))
		{
			$('span', $(obj)).html('Скрыть фильтр');
			$('#search .data').removeClass('hidden');
		}
		else
		{
			$('span', $(obj)).html('Показать фильтр');
			$('#search .data').addClass('hidden');
		}
	}
}
