(function(){
//jQuery.noConflict();

var api = {
	init: function() {
		if ($('#product').length > 0)
		{
			$('#product ul.colors a').click(function(){
				$('#product .img img').attr({ src: this.href });
				return false;
			});
			$(window).bind('scroll', api.scroll);
			api.scroll();
		}
		$('.table1 td.col3 a').click(function(){
			var id = $(this).attr('href').substr(1);
			if (id.length)
			{
				$('.box2 .boxIn2 > div').hide();
				$('#' + id).show();
				$('.box2').show();
				$('.table1 td.col3 a').removeClass('active');
				$(this).addClass('active');
			}
			return false;
		});
//		if ($('.box4').length > 0)
//		{
//			$('.box4 > div').not('.content').pngfix({ sizingMethod: 'scale' }).not('.tr,.tl,.bl,.br').each(function(){
//				var p = $(this).parents('.box4');
//				if ((this.className == 't') || (this.className == 'b'))
//				{
//					var w = p.width() + parseInt(p.css('paddingLeft')) + parseInt(p.css('paddingRight'));
//					$(this).css({ width: (w - 50 - 25) + 'px' });
//				}
//				else
//				{
//					var h = p.height() + parseInt(p.css('paddingTop')) + parseInt(p.css('paddingBottom'));
//					$(this).css({ height: (h - 50 - 25) + 'px' });
//				}
//			});
//		}
	},
	scroll: function(){
		var tt = 0, dh = 0;
		if (document.documentElement && document.documentElement.scrollTop) { 
			tt = document.documentElement.scrollTop;
			dh = document.documentElement.clientHeight;
		} else if (document.body) { 
			tt = document.body.scrollTop;
			dh = document.body.clientHeight;
		}
		var h = $('#product').height();
		var c3 = $('#content3');
		var ch = c3.height() + parseInt(c3.css('paddingTop')) + parseInt(c3.css('paddingBottom'));
		var co = $('#content3').offset();
		t = tt - co.top;
		t += ((dh > h) ? Math.round((dh - h) / 2) : 0);
		if (t >= 140)
		{
			if (t > ch - h)
				t = ch - h;
			$('#product').css({ top: t + 'px' });
		}
		else
		{
			$('#product').css({ top: '122px' });
		}
	}
};

jQuery(document).ready(api.init);

})();