$(document).ready(function()
{
  Cufon.replace('.socialNetwork, .greenText, .greenPrice, .langSel, h1, h3, #config th, #config .th, .orderText, .orderAmount');
	Cufon.replace('.greenButton, .greenSmallButton, .stripe h2, .greenSubmitButton, .wideSubmitButton', {textShadow: '#6c9411 1px 0px'});
	Cufon.replace('.redButton', {textShadow: '#a9181e 1px 0px',  color: '-linear-gradient(#fff, #e7e7e7'});
	Cufon.replace('.silverGradient', { color: '-linear-gradient(#fff, #e7e7e7'});
	Cufon.now()

  var thumbs = $('#thumbs');
  if (thumbs.length)
  {
    thumbs.galleriffic({
	    imageContainerSel:        '#slideshow',
  		controlsContainerSel:     '#controls',
	  	nextLinkText:             '&raquo;',
		  prevLinkText:             '&laquo;',
  		renderSSControls:         false,
	  	enableKeyboardNavigation: false,
		  autoStart:                false,
  		syncTransitions:          false,
	  	captionContainerSel:      '#slideshow_desc',
	  	onSlideChange: function(curIndex, index)
	  	{
			  var btn = $('#orderButton')
			  var baseHref = btn.data('baseHref');
			  if (!baseHref)
			  {
				  baseHref = btn.attr('href');
				  btn.data('baseHref', baseHref);
				}
				btn.attr('href', baseHref + '?photoId=' + $('#galleriffic li a.thumb:eq(' + index + ') img').attr('rel'));
			}
    });
  }

  $('a.thumb, #galleriffic a.more').qtip({
	  position: {
		  my: 'bottom center',  // Position my top left...
			at: 'top center', // at the bottom right of...
			adjust: {
			  y: -6,
				x: 4
			}
		},
		style: {
		  classes: 'ui-tooltip-dark',
			tip: {
			  corner: false
			}
		},
		show: {
			effect: false
		},
    hide: {
			effect: false
		}
	});
	
	$('img.authorPhoto').wrap('<span class="authorPhoto" />').parent().append('<span class="mask">&nbsp;</span>');
	
	if ($('#headPhoto img').length > 1)
	{
	  window.setInterval(function()
		{
		  var lastImg = $('#headPhoto img:last');
		  lastImg.fadeOut(600, function()
			{
			  lastImg.remove();
			  $('#headPhoto').prepend(lastImg);
			  lastImg.show();
			});
		}, 5000);
	}
});
