
// Cufon: font replacement
// http://cufon.shoqolate.com/

// Check for google translate cookie, to wait with cufon until translated.
if (document.cookie && document.cookie.indexOf('googtrans') > -1) {
	setTimeout(function(){
		Cufon.replace('#content h1, .boxes h4, .boxes .title, .boxes li a, .cart h3, .box h3, #left h2, .products .name, .products .price');
		Cufon.replace('.nav > li > a', { hover: true });
	}, 3000);
} else {
	Cufon.replace('#content h1, .boxes h4, .boxes .title, .boxes li a, .cart h3, .box h3, #left h2, .products .name, .products .price');
	Cufon.replace('.nav > li > a', { hover: true });
}


$(function(){


	// InnerFade: Header image rotator
	// http://medienfreunde.com/lab/innerfade/
	$('#header ul').innerfade({
		animationtype: 'fade', // fade or slide
		speed: 500, // animation speed in milliseconds
		timeout: 5000, // time between animations in milliseconds
		type: 'random', // sequence, random, or random_start
		containerheight: '222px' // height of the containing element
	});


	// jCarousellite
	// http://www.gmarwaha.com/jquery/jcarousellite/
	$('#right .carousel').jCarouselLite({
		auto: 3000,
		speed: 3000,
		visible: 1,
		scroll: 1,
		easing: "easeInOutBack"
	});


	// Product images hover
	// Put url of larger version in rel attribute of the thumbnail image tag.
	$('.images .small a').hover(function(){
		$('.images .large img').attr('src', $(this).find('img').attr('rel'));
	});


	// Cufon refresh on translate
	$('.goog-te-combo').live('change', function(){
		$('cufon:first-child').each(function(){
			var text = '';
			$(this).parent().find('cufontext').each(function(){
				text += $(this).html();
			});
			$(this).parent().html(text);
		});
		setTimeout(function(){ Cufon.refresh(); }, 3000);
	});


});

function externalLinks() {
    if (!document.getElementsByTagName) return;
        var anchors = document.getElementsByTagName("a");
        for (var i=0; i<anchors.length; i++) {
        var anchor = anchors[i];
        if (anchor.getAttribute("href") &&
            anchor.getAttribute("rel") == "external")
            anchor.target = "_blank";
        }
    }
window.onload = externalLinks;
