/*************************
Author:    nis@nozebra.dk
Date:      March 2, 2011
Last edit: March 10, 2011
*************************/

$(document).ready(function() {
	//Cufon.replace('h1, h1.h1, #casesBoxMiddle h3', {fontFamily:'GillSans'});
	
	/*Cufon.replace('header nav a', { fontFamily: 'GillSans' });
	Cufon.replace('#toolsNavigation a', { hover: true });*/

	//Activate slideshow!
	slideSwitch();
});

// Fancybox... ACTIVATE!
/*$(function () {
	$('a#mediaLink').fancybox({
		'hideOnContentClick': false
	});
*/

function playVideo(video){
	if(video.match('youtube.com')!=null){
		$.fancybox({
			'autoScale'     : false,
			'overlayColor'	:'#000',
			'titleShow'     : false,
			'width'         : 458,
			'height'        : 321,
			'href'          : video.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'      	: 'swf',
			'swf'       	: {'wmode':'transparent','allowfullscreen':'true'}
		});
	}
	else{
		$.fancybox({
			'autoScale'     : false,
			'overlayColor'	:'#000',
			'titleShow'     : false,
			'width'         : 458,
			'height'        : 321,
			'href'          : '/files/Templates/Designs/Enkotec/flash/VideoPlayer.swf',
			'type'      	: 'swf',
			'swf'       	: {'wmode':'transparent','allowfullscreen':'true','flashvars':'videoPath=/'+video}
		});
	}
};


// Slideshowsjov
$(function() {
   $('#slideBox div:first').addClass('active')
});
	
	var vSpeed = 600; // Hastigheden på animationen
	var vInterval = vSpeed + 5000; // Tiden hver slide bliver hængende
	
function slideSwitch() {
    var $active = $('#slideBox div.active');
	var count = $('#slideBox div').length;
	
	if (count > 1) { // Slideshowet skal ikke køre, hvis der kun er et billede (eller nul)
		if ( $active.length == 0 ) $active = $('#slideBox div:last');
		var $next =  $active.next().length ? $active.next(): $('#slideBox div:first');
		
		$active.addClass('last-active');
		$next.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, vSpeed, 
			function() {
				$active.removeClass('active last-active');
			});
		}
	}
	$(function() {
		setInterval( "slideSwitch()", vInterval ); // <--- Tiden hver slide bliver hængende
	});	


/*Product page tabs*/
$(function() {
		var tabContainers = $( "div.tabs > div" );
		tabContainers.hide().filter(':first').show();
		
		$("div#productSubMenuWrapper a").click(function(){
				tabContainers.hide();
				tabContainers.filter(this.hash).show();
				
				$("div#productSubMenuWrapper a").removeClass('selected');
				$(this).addClass('selected');
				
				return false;
			}).filter(':first').click();
	});


/*Auto-Focus Form Elements with JavaScript*/
  function formfocus() {
      document.getElementById('nameInputSignup').focus();
   }
   window.onload = formfocus;
 
