$(document).ready(function(){

//shows page elements when loaded in IE6

      		$('#productTabs').css('display','block');
			$('#productPage div#io_zone_1').css('display','block');


														
	$('#zoomLink').click(function(e) {
		e.preventDefault();
		var url2Convert = $(this).children('img').attr('src');
		var productTitle = $(this).attr('title');
		// console.info(url2Convert);
		var url2Zoom = convertToZoom(url2Convert);
		// console.info(url2Zoom);
	    $.nyroModalManual({
	    	forceType: 'image',
	    	url: url2Zoom,
	    	title: productTitle
		});
		return false;
	});
	  
	  $("#smallPhotos").jMyCarousel({
		visible: '3',
		eltByElt: true,
		evtStart: 'mousedown',
        evtStop: 'mouseup',
		circular: true,
		vertical: false,
		speed: 200,
		btnPrev: $('#prevBtn'),
		btnNext: $('#nextBtn')
	});
	
	//See More
	//	-requires an id and a rel to build selector
	//	-example: 	<div id="bulletedProductCopy" class="toggleRange" rel="ul li:gt(4)"><ul><li></li>...</ul></div>
	//				#bulletedProductCopy ul li:gt(4) points to li's in the div that have an idex greater than 4

	//initially hide based on class and rel and determine wether to display see more link
	$('.toggleRange').each(function (i) {
		if($(this).attr('rel').match(/gt\([1-9]+\)/) && (($(this).children().children().size()) > (parseInt($(this).attr('rel').match(/[1-9]+/)) + 2)))
		{
			var s = "#" + $(this).attr('id') + " " + $(this).attr('rel');
			$(s).toggle();
			
			var seeMoreLess = $('<a href="javascript:void(0)" class="seeMore"><span></span>See More</a>');
			$(this).after(seeMoreLess);
		}
	});


	//build the see more links and it's click event
	$('.seeMore').click(function(){
		($(this).text() == 'See More')? $(this).html('<span></span>See Less') : $(this).html('<span></span>See More');
		$(this).toggleClass('seeLess');
		var prevSibling = $(this).prev();
		var rangeSelector = "#" + prevSibling.attr('id') + " " + prevSibling.attr('rel');
		$(rangeSelector).slideToggle();
		$("#" + prevSibling.attr('id') + " div.clearFloat").css({display: 'block'});
	});
	$('.seeLess').click(function(){$(this).toggleClass('seeMore');});

	// styles the scrollbar on the merchandising associations
	$('#prodGroupContainer').jScrollPane({
		showArrows:true,
		scrollbarWidth:11,
		scrollbarMargin: 2
	});

	// hides the merchandising associations when the review tab is clicked

	
	$("#reviewsTab").click(function () {
		$("div#rhrBottom").addClass("hide");
	});
	$("#productDetailsTab, #techInfoTab").click(function () {
		$("div#rhrBottom").removeClass("hide");
	});

	// accordian for the merchandising associations
	$("#merchAssocAccordion").accordion({
		autoHeight: false,
		header: 'h6',
		icons: { 'header': 'ui-icon-plus', 'headerSelected': 'ui-icon-none' }
	});
	
	//move emailPrint under dash
	$('.emailPrint').appendTo('#dashboard').fadeIn();
	
	//moved below footer to load common.js fist this appends the sku selector when needed
	$('#skuSelector .skuSelectorAppendTarget').append($('#skuSelectorContainer').html());

	
	// video link
	$('#videos a.nmv').click(
			function(e)
			{
				var videoPageURL = $(this).attr('href');
				if(ieflag)
				{
					this.target = "_blank";
					return true;
					//location.href = videoPageURL;
				}
				else
				{
					e.preventDefault();
					$.nyroModalManual({
				      url: videoPageURL
				    });			
				}
			});
		
});

