	var is_nav4up;
	var is_ie4up;
	
	function detectBrowser() 
	{
		var agt=navigator.userAgent.toLowerCase();
		var is_major = parseInt(navigator.appVersion);
		var is_minor = parseFloat(navigator.appVersion);
		var is_ie   = (agt.indexOf("msie") != -1);
		is_ie4up  = (is_ie  && (is_major >= 4) && (navigator.appVersion.indexOf("PPC") == -1) );
	}
	
	
	function show_picture(picture, id, height) 
	{
		detectBrowser();
				
				
		var html = '<img src=\"/pictures/big/' + picture + '\" width=\"300\" height=\"' + height + '\">';
		
		if (is_ie4up) 
		{
			eval("document.all.show_picture" + id + ".style.height = 0");
				
			eval("picture = document.all.picture" + id );
			
			alert
			
			var left_position = GetX(picture);
			var top_position = GetY(picture);
										
			eval("document.all.show_picture" + id + ".innerHTML = html");
					
			eval("window_height = document.all.show_picture" + id + ".clientHeight");
			eval("document.all.show_picture" + id + ".style.height = height");
			eval("document.all.show_picture" + id + ".style.top = top_position - height - 10");
			eval("document.all.show_picture" + id + ".style.left = left_position");
			//document.all.show_picture.style.left = window.event.clientX;
			//document.all.show_picture.style.top = window.event.clientY + document.body.scrollTop;
					
			eval("document.all.show_picture" + id + ".style.visibility = 'visible'");
		}
		else 
		{
			elm = document.getElementById('show_picture' + id);
			elm_picture = document.getElementById('picture' +id);
				
			var left_position = GetX(elm_picture);
			var top_position = GetY(elm_picture);
					
			elm.style.height = null;
			elm.innerHTML = html;
					
			window_height = elm.offsetHeight-2;
			elm.style.height = window_height;
			elm.style.left = left_position;
			elm.style.top = top_position - window_height - 10;
			elm.style.visibility = "visible";
			//elm.style.left = event.clientX;
			//elm.style.top = event.clientY + document.body.scrollTop;
		}
	}

	function hide_picture(id) 
	{
		if(is_ie4up)
		{
			eval("document.all.show_picture" + id + ".style.visibility = 'hidden'");
		}
		else
		{
			elm = document.getElementById('show_picture' + id);
			elm.style.visibility = "hidden";
		}
	}
	
	
	
			
			
	function GetX(item) 
	{
		xPos = item.offsetLeft;
		tempEl = item.offsetParent;
				
		while(tempEl != null) 
		{
			xPos += tempEl.offsetLeft;
			tempEl = tempEl.offsetParent;
		}
				
		return xPos;
	} 


	function GetY(item)
	{
		yPos = item.offsetTop;
		tempEl = item.offsetParent;
				
		while(tempEl != null)
		{
			yPos += tempEl.offsetTop;
			tempEl = tempEl.offsetParent;
		}
				
		return yPos;
	}
	
	
	function window_open(url, target)
	{
		if(target == 'self')
		{
			location.href = url;
		}
		else
		{
			window.open(url);
		}	
	}
	
jQuery(document).ready(function()
{	
	/* Галерея дополнительных изображений товара */
	jQuery("a[rel=thumbnail]").fancybox(
	{
		'titlePosition':'inside',
		'titleFormat':function(title, currentArray, currentIndex, currentOpts)
		{
			return '<span id="fancybox-title-over">' +  (currentIndex + 1) + '/' + currentArray.length + ' &nbsp;&nbsp; ' + title + '</span>';
		}
	});
	
	/*Галерея для остальных изображений*/
	jQuery(".fancybox").fancybox(
	{
		'titlePosition':'inside'
	});
	
	
/* циркулирующая карусель
auto: 5, 
wrap: 'circular'*/
	
	jQuery("#carousel").jcarousel({
		scroll: 1, 
		visible: 3,
		wrap: 'circular' 
	});
	jQuery(".carousel").css({visibility: 'visible'});
		
	$(".jcarousel-next").hover(
		function(){
    		$(this).addClass("jcarousel-next-hover");
		}, 
  		function(){
    		$(this).removeClass("jcarousel-next-hover");
		}
	);
		
	$(".jcarousel-prev").hover(
		function(){
    		$(this).addClass("jcarousel-prev-hover");
		}, 
  		function(){
    		$(this).removeClass("jcarousel-prev-hover");
		}
	);
	
	
	$(function()
	{
		/* для внутренних страниц скрытая карусель */
		if($('#mainpage').length == 0)
		{
			$('#carousel').parent().height(42);
			$('.jcarousel-prev').height(42);
			$('.jcarousel-next').height(42);
			$('#carousel_switcher').addClass('closed')
		}
		
		$('#carousel_switcher').click(function()
		{
			if($(this).hasClass('closed'))
			{
				$('.jcarousel-prev').animate({height:200}, 300);
				$('.jcarousel-next').animate({height:200}, 300);
				$('#carousel').parent().animate({height:200}, 300, function()
				{
					$('#carousel_switcher').removeClass('closed')
				});
			}
			else
			{
				$('.jcarousel-prev').animate({height:42}, 300);
				$('.jcarousel-next').animate({height:42}, 300);
				$('#carousel').parent().animate({height:42}, 300, function()
				{
					$('#carousel_switcher').addClass('closed')
				});
			}
		});
	});
	
	if(jQuery.browser.opera)
	{
		jQuery('.main_table').css('padding-top', '1px');
	}

}); 

