$(document).ready(function() {
	
	$(function() {
		$('#nav').droppy({speed:100});
        $('#nav').show();
	});
	
	var nav_width = 0;
	$('#nav>li').each(function(){
		nav_width += $(this).width();
	});
	//$('#nav').css({width:nav_width, margin: '0px auto', clear:'both !important'});
	
	$("a.fancy_popup").fancybox({
		'hideOnContentClick': false
	}).click(function(){
         setTimeout(function() {
        $('body').trigger('mouseout');
        $('#nav').droppy({speed:100});
                 }, 1000);
    });
	
	$('#trade_products_horisontal .container').click(function(){
		location.href = $(this).attr('href');
	});
	
	$('#trade_products_vertical li').click(function(){
		location.href = $(this).attr('href');
	});
	
	
	if($('#trade_products_vertical_line') != undefined){
		var height = $('#trade_products_vertical').height();
		$('#trade_products_vertical_line').css({'top': -height, 'height': (height-25)+'px' });
	}
	
	$('#trade_products_horisontal .container').mouseover(function(){
		var color = $(this).css('background-image').split('_')[1];
		$(this).css({background:'url(/media/img/trade_'+color+'_circle_border.png) no-repeat center'});
	});
	$('#trade_products_horisontal .container').mouseout(function(){
		var color = $(this).css('background-image').split('_')[1];
		$(this).css({background:'url(/media/img/trade_'+color+'_circle.png) no-repeat center'});
	});
	
	
	
	$('#trade_products_vertical li').mouseover(function(){
		//alert('aaaa');
		var color = $(this).css('background-image').split('_')[1];
		$(this).css({background:'url(/media/img/trade_'+color+'_circle_small_border.png) no-repeat left'});
	});
	$('#trade_products_vertical li').mouseout(function(){
		var color = $(this).css('background-image').split('_')[1];
		$(this).css({background:'url(/media/img/trade_'+color+'_circle_small.png) no-repeat left'});
	});
	
	
	
	$('#cs').click(function(){
		location.href = $(this).attr('href');
	});
	$('#ts').click(function(){
		location.href = $(this).attr('href');
	});
	$('#tech').click(function(){
		location.href = $(this).attr('href');
	});
	
	$('#trade_order_submit').click(function(){
		$('#trade_order_f').submit();
	});
	
	$('#search_dealer').liveUpdate('dealers_list');
	$('#search_doctor').liveUpdate('doctors_list');
	
	if($.prototype['inFieldLabels'] != undefined){
		$("#trade_order_div label").inFieldLabels();
		$("#trade_order_div select").bind('change', function(){
			$('label[for='+$(this).attr('id')+']').hide();
		});
	}
});

