// function to open links in new window and still validate xhtml
// http://articles.sitepoint.com/article/standards-compliant-world
// usage: <a href="http://www.example.com/" rel="external">, add rel="external" to outside links
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;

// jquery tabs
$(document).ready(function() {
	$('.tabs a').click(function(){
		switch_tabs($(this));
	}); 
	switch_tabs($('.defaulttab'));
});
 
function switch_tabs(obj) {
	$('.tab-content').hide();
	$('.tabs a').removeClass("selected");
	var id = obj.attr("rel");
 
	$('#'+id).show();
	obj.addClass("selected");
}

// teaser nivoslider
$(window).load(function() {
    $('#slider').nivoSlider({
	effect: 'random',
	slices: 15,
	animSpeed: 250,
	pauseTime: 7500,
	directionNav: false
	});
});

// product slider --- http://www.baijs.nl/tinycarousel/
$(document).ready(function(){
	$('#prod_slider').tinycarousel({
	display: 3
	});	
});


// slide sidebar --- http://css-tricks.com/examples/ScrollingSidebar/index.php
/*
$(function() {
    var offset = $("#sidebar").offset();
    var topPadding = 15;
    $(window).scroll(function() {
        if ($(window).scrollTop() > offset.top) {
            $("#sidebar").stop().animate({
                marginTop: $(window).scrollTop() - offset.top + topPadding
            });
        } else {
            $("#sidebar").stop().animate({
                marginTop: 0
            });
        };
    });
});
*/
