	

	$.fn.move = function(where) { 

		var y=$(this).css('background-position');
		y=y.replace('0px ','');
		y=y.replace('%','');
		var value=parseInt(y);
		if (where=='up')
			value=value-1;
		else
			value=value+2;
		
		if (value<=100)
			return 2;
		
		if (value>=140)
			return 1;
		
		var x='0 '+value+'%';
		$(this).stop().css('background-position',x);
		
		return value;
		//setTimeout("move_up("+item+","+value+")", 1);
	}
	
function move_it(item,where)
{
	var ret=item.move(where);
	if ((ret!=1)&&(ret!=2))
	{
		setTimeout(function(){move_it(item,where)}, 5);
	}
	else
	{
		$('.one_product').stop().css('background-position','0 140%');
		
		if (ret==2)
			item.stop().css('background-position','0 100%');
			
		
	}
}
	






function make_scroll()
{

$(function(){
	//Get our elements for faster access and set overlay width
	
	
	
	var div = $('div.sc_menu'),
	ul = $('ul.sc_menu'),
	ulPadding = 5;

//Get menu width
var divWidth = div.width();

//Remove scrollbars	
div.css({overflow: 'hidden'});

//Find last image container
var lastLi = ul.find('li:last-child');


//When user move mouse over menu
div.mousemove(function(e){
	//As images are loaded ul width increases,
	//so we recalculate it each time
	var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;	
	var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
	div.scrollLeft(left);
});

	
});

}
$(document).ready(function() {

	
	
	

	$('#new_category').hover(
			  function () {

				  $('#new_category_box').show();
				  $('#new_category_box').css({'z-index':'1000000',display:'block'});
				  $('#side_bar').css('position','relative');
				  $('#side_bar').css('top','-130px');
				  $('#content').css('position','relative');
				  $('#content').css('top','-130px');
				  $('#new_category').addClass('menu_item_a_hover');
				  make_scroll();
				  
			  },
			  function () {
				  $('#new_category_box').hide();
				  $('#side_bar').css('position','static');
				  $('#side_bar').css('top','0px');
				  $('#content').css('position','static');
				  $('#content').css('top','0px');
				  $('#new_category').removeClass('menu_item_a_hover');
			  }
			);

	$('#new_category_box').hover(
			  function () {
				  $('#new_category_box').show();
				  $('#new_category_box').css({'z-index':'1000000',display:'block'});
				  $('#side_bar').css('position','relative');
				  $('#side_bar').css('top','-130px');
				  $('#content').css('position','relative');
				  $('#content').css('top','-130px');
				  $('#new_category').addClass('menu_item_a_hover');
				  
				  
				  
				  make_scroll();
				  
				  
				  
				  
				  
				  
				  
				  
				  
				  
			  },
			  function () {
				  $('#new_category_box').hide();
				  $('#side_bar').css('position','static');
				  $('#side_bar').css('top','0px');
				  $('#content').css('position','static');
				  $('#content').css('top','0px');
				  $('#new_category').removeClass('menu_item_a_hover');

			  }
			);
		
	
	
	$('.one_product').hover(
			  function () {
				 var item=$(this);
				 move_it(item,'up');
			  },
			  function () {
					 var item=$(this);
					 move_it(item,'down');
			  }
			);
	
	
	
	$("#pdf").fancybox({
		'width'				: 960,
		'height'			: '90%',
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	}); 	
	
	$("a[rel=list]").fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic'
	});
	$(".single_window").fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'titlePosition' 	: 'over'
	});
	
	// contact form
	$('.whisper_box').children('.whisper_main').focus(function(){
		
		if ($(this).val()==$(this).parent().children('.whisper').val())
			$(this).val('');

		$(this).addClass('search_real')
	});

	$('.whisper_box').children('.whisper_main').focusout(function(){
		
		if($(this).val()=='')
		{
			$(this).val($(this).parent().children('.whisper').val());
			$(this).removeClass('search_real')
		}
	});
	
	
	

	$('#search_text').focus(function()
	{
		if($(this).val()=='')
		{
			$(this).val('');
			$(this).addClass('search_real')
		}
	});
	
	$('#search_text').focusout(function()
	{
		if($(this).val()=='')
		{
			$(this).val('');
			$(this).removeClass('search_real')
		}
	});

	
	$(".various").fancybox({
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});
	
	
	
	
	
	function go_large()
	{
		var img = $('#fancybox-img'); // Get my img elem
		var pic_real_width, pic_real_height;
		$("<img/>") // Make in memory copy of image to avoid css issues
		    .attr("src", $(img).attr("src"))
		    .load(function() {
		        pic_real_width = this.width;   // Note: $(this).width() will not
		        pic_real_height = this.height; // work for in memory images.
		        $('#fancybox-img').css('height',pic_real_height);
				$('#fancybox-img').css('width',pic_real_width);

				$('#fancybox-content').css('height',pic_real_height);
				$('#fancybox-content').css('width',pic_real_width);
				
				$('#fancybox-outer').css('height',parseInt(parseInt(pic_real_height)+20));
				$('#fancybox-outer').css('width',parseInt(parseInt(pic_real_width)+20));

				$('#fancybox-wrap').css('height',parseInt(parseInt(pic_real_height)+20));
				$('#fancybox-wrap').css('width',parseInt(parseInt(pic_real_width)+20));
	/*		   
		var lef=($('#fancybox-wrap').css('left'));
		var wid=($('body').css('width'));

		lef=Math.round(((parseInt(wid)-parseInt(parseInt(pic_real_height)+20))/2));
		$('#fancybox-wrap').css('left',lef);	
		
		*/
				$.fancybox.center();
		    });
	}
	
	var max_size=0;
	
	
	$('.enlarge').live('click', function() {


		go_large();
		//alert(lef);
		max_size=1;		
		   
						
		
	});	
	
	$('#fancybox-left').live('click', function() {
	if (max_size==1)
	{
		//console.log('aa');
		go_large();
		//console.log('bb');
	}
	});
	
	
	$('.one_video_in').click(function(){
		$(this).slideUp();
		$(this).parent().find('.youtube').delay(400).slideDown();
		
	
	});
	/*
	$('.product_link').each(function(){
		var h=$(this).height();
		var f;
		if (h>80)
		{
			for(var i=0;i<100;i++)
			{
				f=$(this).find('.standard_name').css('font-size');
				f.replace('px','');
				console.log(f);
				console.log(parseInt(f)-1);
				
				$(this).find('.standard_name').css('font-size',parseInt(f)-1+'px');
				
				if ($(this).height()<=60)
					break;
			}
		}
	});
*/
});
