// Site-specific Javascript file
function doCufon() 
{
  Cufon.replace("#nav a", { hover: true, fontFamily: 'Avenir 700' });
//  Cufon.replace("#product-nav a", { hover: true, fontFamily: 'Avenir 600' });
  Cufon.replace("#feature h1", { fontFamily: 'Clarendon LT Std' });
  Cufon.replace("#content h1", { fontFamily: 'Clarendon LT Std' });
}

function firstLast()  
{  
  $('ul li:first-child').addClass('first');  
  $('ul li:last-child').addClass('last');  
}

function initGallery()
{
	var i=0;
	$('#gallery ul').each(
		function() {
			i++;
			var galleryList = $(this);
			galleryList.find('li').not(':first-child').hide();
			var galleryLinks = galleryList.find('a');
			galleryLinks.attr('rel', 'gallery-'+i);
			galleryLinks.each(
				function() {
					$(this).attr('title', $(this).html());
				}
			);
			galleryLinks.fancybox({
				'padding' : 2,
				'zoomOpacity' : true,
				'overlayOpacity' : 0.5,
				'zoomSpeedIn' : 500,
				'zoomSpeedOut' : 500,
				'imageScale' : true
  		});
			var firstLink = galleryList.find('li:first-child a');
			var thumb = '<img src="/media/gallery/thumbs/'+galleryList.attr('id')+'.jpg" width="186" height="116" />';
			firstLink.html(thumb);
		}
	);
}

function initApplicationGallery()
{
		$('#images').galleria({
			history   : false // deactivates the history object for bookmarking, back-button etc.
		});
		var firstThumb = $('#images li:first-child');
		$.galleria.activate(firstThumb.find($('img')).attr('src'));
		firstThumb.addClass('active');
}

function initLightbox(selectr)
{
  $(selectr).lightBox({
	  imageLoading:  '/img/lightbox/lightbox-ico-loading.gif',
	  imageBlank:    '/img/lightbox/lightbox-blank.gif',
	  imageBtnClose: '/img/lightbox/lightbox-btn-close.gif',
	  imageBtnNext:  '/img/lightbox/lightbox-btn-next.gif',
	  imageBtnPrev:  '/img/lightbox/lightbox-btn-prev.gif'
  });
}

function initFancybox(selectr, group)
{
	var links = $(selectr);
	if(group) {
		links.attr('rel', group);
	}
	links.fancybox({
		'padding' : 2,
		'zoomOpacity' : true,
		'overlayOpacity' : 0.5,
		'zoomSpeedIn' : 500,
		'zoomSpeedOut' : 500,
		'imageScale' : true
	});
}

function initFancyboxVideo(selectr)
{
	var link = $(selectr);
	link.fancybox({
		'padding' : 10,
		'overlayOpacity' : 0.5,
//		'zoomSpeedIn' : 500,
//		'zoomSpeedOut' : 500,
		'frameWidth' : 426,
		'frameHeight' : 278,
		'hideOnContentClick' : false
	});
}

function removeContents()
{
	var iframe = $('#fancy_frame');
	iframe.find('head').html('');
	iframe.find('body').html('');
}

function initDiyVideo(swfobject)
{
	swfobject.registerObject("diy-video-player", "9.0.28", "/flash/expressInstall.swf");
}

jQuery(function() { $('html').addClass('js'); });
jQuery(firstLast); 
jQuery(doCufon);