$(document).ready(function()
{
	
	/*$('#menu li').hover(
	  function (e) 
	  {
			var storeHighestHeight = 0;
			for(var i=0; i<$(this).find('.subMenuHolder blockquote').children().length; i++)
			{
				if(storeHighestHeight < $('.subMenuHolder blockquote div.subMenuBlocks').eq(i).height())
				{storeHighestHeight = $('.subMenuHolder blockquote div.subMenuBlocks').eq(i).height();}
			}
			$(this).find('.subMenuHolder blockquote div.subMenuBlocks').height(storeHighestHeight);
	  }, 
	  function (e) 
	  {
		  
	  }
	)*/
	
	/* Sub Option Modal */
	
	var storeNormalPath;
	$('a[name=subOptionModal]').toggle(
		function (e) 
		{
			e.preventDefault();
			
			var id = $(this).attr('href');
			 
		 
			var maskHeight = $('.contentTopBoxTopL').outerHeight()-60;
			var maskWidth = 992; 
			 
			$('#otherPageOptionmask').css({'width':maskWidth,'height':maskHeight});
			 
			$('#otherPageOptionmask').fadeIn(1000);   
			$('#otherPageOptionmask').fadeTo("slow",0.8); 
			 
			$(id).fadeIn(2000);
			
		},
		function (e) 
		{
			$('#otherPageOptionmask, .windowOtherPg').fadeOut(500);
		}
	).hover(
	  function (e) 
	  {
			storeNormalPath = $(this).find('img').attr('src');
			var imgArray = $(this).find('img').attr('src').split('.');
			$(this).find('img').attr('src', imgArray[0]+'Hover.'+imgArray[1]);
	  }, 
	  function (e) 
	  {
			$(this).find('img').attr('src', storeNormalPath);
			storeNormalPath ='';
	  });
	
	
	/* For Product Detail Page's small top thumbs */
	var parentHolderWidth = $('.productList ul').parent().width(); // ul holder width
	var liWidth = $('.productList ul li').width(); // individual LI width
	var liCount = $('.productList ul').children().length; // total LI count
	var totalLILength = liWidth*liCount; // total value
	$('.productList ul').css('width',totalLILength);  // UL width
	
	var iterator = liCount/3;
	
	$('#leftArrow').click(function(event)
	{
		var j =1;
		j--;
		$('.productList ul').animate({"left": -(j/parentHolderWidth)}, "slow");
	});
	
	$('#rightArrow').click(function(event)
	{
		var i=1;
		if(i<iterator)
		{
			$('.productList ul').animate({"left": -(parentHolderWidth*i)}, "slow");
			i++;
		}
	});
	
	$('.productList ul li img').hover(
	  function (e) 
	  {
			var p = $(this);
			var position = p.position();
			var offset = $(this).offset();
			$('.tooltip').css('top', offset.top-($('.tooltip').height()+3));
			$('.tooltip').css('left', offset.left-12);
			$('.tooltip').append('<img src="'+$(this).attr("src")+'" />');
			$('.tooltip').append('<span>'+$(this).attr("name")+'</span>');
			$('.tooltip').fadeIn(400);
	  }, 
	  function (e) 
	  {
			$('.tooltip').children().remove();
			$('.tooltip').css('top', -1000);
			$('.tooltip').css('left', -1000);
			$('.tooltip').hide();
	  }
	);
	
	
	/* For Product Browse 1 Page's small bottom thumbs */
	var pBrowse1parentHolderWidth = $('.microScroller blockquote ul').parent().width(); // ul holder width
	var pBrowse1liWidth = $('.microScroller blockquote ul li').width(); // individual LI width
	var pBrowse1liCount = $('.microScroller blockquote ul').children().length; // total LI count
	var pBrowse1totalLILength = pBrowse1liWidth*pBrowse1liCount; // total value
	$('.microScroller blockquote ul').css('width',pBrowse1totalLILength);  // UL width
	
	var pb1iterator = pBrowse1liCount/3;
	
	$('#pb1leftArrow').click(function(event)
	{
		var j =1;
		j--;
		$('.microScroller blockquote ul').animate({"left": -(j/pBrowse1parentHolderWidth)}, "slow");
	});
	
	$('#pb1rightArrow').click(function(event)
	{
		var i=1;
		if(i<pb1iterator)
		{
			$('.microScroller blockquote ul').animate({"left": -(pBrowse1parentHolderWidth*i)}, "slow");
			i++;
		}
	});
	
	
	/* For Product Browse 1 Page's Big Blocks */
	var pBrowse1BigparentHolderWidth = $('.displayItemScrollHolder ul').parent().width(); // ul holder width
	var pBrowse1BigliWidth = $('.displayItemScrollHolder ul li').width(); // individual LI width
	var pBrowse1BigliCount = $('.displayItemScrollHolder ul').children().length; // total LI count
	var pBrowse1BigtotalLILength = (pBrowse1BigliWidth*pBrowse1BigliCount)+400; // total value
	$('.displayItemScrollHolder ul').css('width',pBrowse1BigtotalLILength);  // UL width
	
	$('.displayItemScrollHolder ul li:nth-child(4n) blockquote').addClass('left');
	
	var zIndexNumber = 1000;
	$('.displayItemScrollHolder ul li').each(function(index)
	{
		$('.displayItemScrollHolder ul li').eq(index).css('zIndex', zIndexNumber);
		zIndexNumber -= 10;
	});
	
	
	
	var storOrgInd = $('.displayItemScrollHolder ul li:nth-child(4n-1)').css('zIndex');
	$('.displayItemScrollHolder ul li:nth-child(4n)').hover(
	  function (e) 
	  {
			$('.displayItemScrollHolder ul li:nth-child(4n-1)').css('zIndex', ($(this).css('zIndex')-1));
	  }, 
	  function (e) 
	  {
		  	$('.displayItemScrollHolder ul li:nth-child(4n-1)').css('zIndex', storOrgInd);
	  }
	);
	
	
	var pb1Bigiterator = pBrowse1BigliCount/2;
	
	$('#pb1BigleftArrow').click(function(event)
	{
		var j =1;
		j--;
		$('.displayItemScrollHolder ul').animate({"left": -(j/pBrowse1BigparentHolderWidth)}, "slow");
	});
	
	$('#pb1BigrightArrow').click(function(event)
	{
		var i=1;
		if(i<pb1Bigiterator)
		{
			$('.displayItemScrollHolder ul').animate({"left": -(pBrowse1BigparentHolderWidth*i)}, "slow");
			i++;
		}
	});
	
	
	
});





