var aMenuImages = Array();

$(document).ready(function() {
	
	$('.tooltip .h2').hide();
	$('.tooltip span').css('visibility', 'hidden');
	
	$('.tooltip .h').mouseover(function () {
		$(this).parent().find('span').css('visibility', 'visible');
	});
	
	/*$('.tooltip .h').mouseout(function () {
		$(this).parent().find('span').css('visibility', 'hidden');
	});*/
	
	$('div.pbtd').each(function(i) {
		/*$(this).mousemove(function() {
			$(this).removeClass('parentcat').addClass('parentcat_current');
		});
		$(this).mouseout(function() {
			$(this).removeClass('parentcat_current').addClass('parentcat');
		});*/
		$(this).click(function() {
			if ($(this).next().css('display') == 'none') {
				$(this).next().slideDown(200).addClass('childcats_show');
			} else {
				$(this).next().slideUp(300);
			}
		});
	});
	$('select.product_option').each(function(i) {
		$(this).change(function(){
			if(this.options[this.selectedIndex].text == 'Свой вариант')
				$('.ntxt').removeClass('txthide');
			else
				$('.ntxt').addClass('txthide');
		});
	});
	
	
	
	$('div.childcats ul li').hover(
		function() {
            $(this).find('ul:first').stop(true, true);
            $(this).find('ul:first').slideDown(200);
        },
        function() {            
            $(this).find('ul:first').slideUp(300); 
        }
    );    
    $('div.childcats li:has(ul)').find('a:first').append('&raquo;');
    
    
    preloadMenuImages();
    
    //div.pbtd .parentcat
    
    $('.parentcat').css('backgroundImage', 'url(' + aMenuImages[0].src + ')');
    
    $('.parentcat').mouseover(function () {
    	$(this).css('backgroundImage', 'url(' + aMenuImages[1].src + ')');
    });
    
    $('.parentcat').mouseout(function () {
    	$(this).css('backgroundImage', 'url(' + aMenuImages[0].src + ')');
    });
    
    $('.right_menu1').css('backgroundImage', 'url(' + aMenuImages[0].src + ')');
    
    $('.right_menu1').mouseover(function () {
    	$(this).css('backgroundImage', 'url(' + aMenuImages[1].src + ')');
    });
    
    $('.right_menu1').mouseout(function () {
    	$(this).css('backgroundImage', 'url(' + aMenuImages[0].src + ')');
    });
	
});

function topselect(i) {
	var tp = document.getElementById('tp0'+i);
	tp.className = "tp_button_current";
//*/
}

function topdeselect(i) {
	var tp = document.getElementById('tp0'+i);
	tp.className = "tp_button";
//*/
}

function preloadMenuImages()
{
	var image = false;
	
	image = new Image;
	image.src = 'img/btn_defoult.png';
	
	aMenuImages[0] = image;
	
	image = new Image;
	image.src = 'img/btn_onmouse.png';
	
	aMenuImages[1] = image;
	
	return true;
}
