var compareItems;

function omnitureCompare()
{
    s.linkTrackVars= 'event6';
    s.event6 =  'GLOBAL:Compare-Products Added';
    s.tl(this,'o', 'compare_products.jsp');
 }
function confirm_clear() {
   if (confirm("Are you sure you wish to delete all products from your Compare?"))
       document.clearAll.submit();
}
function viewLargerImage ( imageName,  descriptionDetail, parentItemNumber ){
      $("#contentContainer").css("display", "none");
      $("#wrapperEnlargeImage").css("display", "block");
      $("#enlargeHeader").html( parentItemNumber + "<br />" + descriptionDetail);
      $("#photo").html( "<img src='/onlinecatalog/images/600wide/" + imageName + "' alt='"+ descriptionDetail + "' />");
}

$(document).ready(function() {

    $("#returnEnlargeImage").click(function() {
              $("#contentContainer").css("display", "block");
              $("#wrapperEnlargeImage").css("display", "none");
       });
});

function updateCompareSize() {
    var compareArLen = compareItems;
    compare_size = 205 * compareArLen;
    if (compareArLen > 0) {
        if (compareArLen > 3) {
            compare_size -= 19; 
            $('div.compare-productInfo:last').css("margin-right", 0);    
        }
        $('#compare-setWidth').css("width", compare_size + "px");
    } else {
        $('#compare-setWidth').css("width", "596px");
    }

    // remove scroll arrows if 3 items left
    if (compareArLen == 3) {
        $('#scroll-left').hide();
        $('#scroll-right').hide();
    }
}

function calculateHeight() {
	var tallestPhoto = 0;
	var tallestDescrip = 0;
	$('.prodPhoto').each(
		function() {
			if($(this).height() > tallestPhoto) {
				tallestPhoto = $(this).height();
			}
		}
	);
	tallestPhoto = eval(tallestPhoto + 12);
	$('.prodPhoto').css("height", tallestPhoto + "px");
	
	$('.descrip').each(
		function() {
			if($(this).height() > tallestDescrip) {
				tallestDescrip = $(this).height();
			}
		}
	);
	$('.descrip').css("height", tallestDescrip + "px");
}

$(function() {
	$('#compare').serialScroll({
	    items:'div.compare-productInfo', //selector to the items
	    prev:'#scroll-left',//selector to the 'prev' button
	    next:'#scroll-right',//selector to the 'next' button
	    axis:'x', //the default is 'y'
	    cycle: false,
	    duration:700 // ,
	    // onBefore: digit
	
	});

    $(document).ready(function() {

    $("#returnEnlargeImage").click(function() {
              $("#contentContainer").css("display", "block");
              $("#wrapperEnlargeImage").css("display", "none");
       });
      });

   // if (compareItems != null && compareItems != '' )
   // {
        updateCompareSize();
	    copyScript();
   // }
});

$(window).load(function () {
      calculateHeight();
    });