$(function(){
	
	$('#products ul li #thm_box a').hover(function(){
		$(this).parent().parent().find('.view_product').addClass('underline');
	}, function(){
		$(this).parent().parent().find('.view_product').removeClass('underline');
	});
	
	$('#bin_preview').dialog({
		modal: true,
		autoOpen: false,
		draggable: true,
		width: '600px',
		buttons: {
			"Close": function() { $(this).dialog("close"); },
			"Request a Quote": function() { document.location.href = "/quote-request.html"; }
		}
	});
	
	$('#searchterm').focus(function(){
		if ($(this).val() == 'Search by Product Name or Model Number')
			$(this).val('');
	});
	$('#searchterm').blur(function(){
		if ($(this).val() == '')
			$(this).val('Search by Product Name or Model Number');
	});
	
	$.binAddSuccess = function(title){
		$('#success').text('You added '+title+' to your Quote Bin.').fadeIn(500).fadeTo(500, 0.9).fadeOut(500);
	}

	$.binAddError = function(title){
		$('#error').text('You already have '+title+' in your Quote Bin.').fadeIn(500).fadeTo(500, 0.9).fadeOut(500);
	}
	
	$.removePreviewBinItem = function(id)
	{
		$('#preview_line #product_'+id).slideUp(function(){
			$(this).remove();
			if ($('#preview_line').children().size() == 0)
				$('#preview_line').append("<li>You have not added any products to your Quote Bin.</li>");
		});
		return false;
	}

	$.removeBinItem = function(id)
	{
		$('#quote_request #product_'+id).slideUp();
		
		return false;
	}

    var gallery = $('#gallery').galleriffic('#thumbs', {
        delay:                  6000, // in milliseconds
        numThumbs:              4, // The number of thumbnails to show page
        preloadAhead:           40, // Set to -1 to preload all images
        enableTopPager:         false,
        enableBottomPager:      true,
        imageContainerSel:      '#slideshow', // The CSS selector for the element within which the main slideshow image should be rendered
        controlsContainerSel:   '#controls', // The CSS selector for the element within which the slideshow controls should be rendered
        captionContainerSel:    '', // The CSS selector for the element within which the captions should be rendered
        loadingContainerSel:    '', // The CSS selector for the element within which should be shown when an image is loading
        renderSSControls:       true, // Specifies whether the slideshow's Play and Pause links should be rendered
        renderNavControls:      true, // Specifies whether the slideshow's Next and Previous links should be rendered
        playLinkText:           'Play',
        pauseLinkText:          'Pause',
        prevLinkText:           'Previous',
        nextLinkText:           'Next',
        nextPageLinkText:       'Next &rsaquo;',
        prevPageLinkText:       '&lsaquo; Prev',
        enableHistory:          false, // Specifies whether the url's hash and the browser's history cache should update when the current slideshow image changes 
        autoStart:              true, // Specifies whether the slideshow should be playing or paused when the page first loads 
        onChange:               undefined, // accepts a delegate like such: function(prevIndex, nextIndex) { ... }
        onTransitionOut:        undefined, // accepts a delegate like such: function(callback) { ... }
        onTransitionIn:         undefined, // accepts a delegate like such: function() { ... }
        onPageTransitionOut:    undefined, // accepts a delegate like such: function(callback) { ... }
        onPageTransitionIn:     undefined  // accepts a delegate like such: function() { ... }
    });

	$('a.add_to_bin').click(function(){
		$(this).after('<img src="/images/btn-addbin-disabled.png" "class=disabledimg" />');
		$(this).hide();
	});

});
