/*
	var bgArr = ["images/header1.jpg", "images/header2.jpg"]; 
	var i=0;

	// Start the slide show
	var interval = self.setInterval("swapBkgnd()", 3000)  

	function swapBkgnd() {
	 if (i>(bgArr.length-1) ) {
	  i=0
		 $("#innerHeaderSection").fadeTo("slow", 1.0);
		 $("#innerHeaderSection").css("background-image", "url("+bgArr[i]+")");
		 $("#innerHeaderSection").fadeTo("slow", 0.0);
	 }
	 else {
		  $("#innerHeaderSection").fadeTo("slow", 1.0);
		  $("#innerHeaderSection").css("background-image", "url("+bgArr[i]+")"); 
		  $("#innerHeaderSection").fadeTo("slow", 0.0);
	 } 
	 i++;
	};
*/
	
/* Header-background "Slideshow" */
function headerSlideSwitch() {
	var $active = $('#outerHeaderSection .headerContainer.active');

	if ( $active.length == 0 ) $active = $('#outerHeaderSection.headerContainer:last');

	// use this to pull the divs in the order they appear in the markup
	var $next = $active.next().length ? $active.next()
		: $('#outerHeaderSection .headerContainer:first');

	// uncomment below to pull the divs randomly
	// var $sibs  = $active.siblings();
	// var rndNum = Math.floor(Math.random() * $sibs.length );
	// var $next  = $( $sibs[ rndNum ] );

	$active.addClass('last-active');

	$next.css({opacity: 0.0})
		.addClass('active')
		.animate({opacity: 1.0}, 1500, function() {
			$active.removeClass('active last-active');
		});
}

$(function() {
	//setInterval( "headerSlideSwitch()", 8000 );
});
/* end Header-background "Slideshow" */


/*    BOX Slideshow */
function boxSlideSwitch() {
	var $active = $('#boxTotalContainer1 .boxInnerContainer.active');

	if ( $active.length == 0 ) $active = $('#boxTotalContainer1.boxInnerContainer:last');

	// use this to pull the divs in the order they appear in the markup
	var $next = $active.next().length ? $active.next()
		: $('#boxTotalContainer1 .boxInnerContainer:first');

	// uncomment below to pull the divs randomly
	// var $sibs  = $active.siblings();
	// var rndNum = Math.floor(Math.random() * $sibs.length );
	// var $next  = $( $sibs[ rndNum ] );

	$active.addClass('last-active');

	$next.css({opacity: 0.0})
		.addClass('active')
		.animate({opacity: 1.0}, 1000, function() {
			$active.removeClass('active last-active');
		});
}

$(function() {
	setInterval( "boxSlideSwitch()", 8000 );
});	


// Tooltips for productpage.
$(document).ready(function()
{
   // Use the each() method to gain access to each elements attributes
   $('.ProductListImage').each(function()
   {
	  $(this).css("cursor", "help");
	  
	  $(this).qtip(
	  {
		 content: $(this).attr('hovertext'), // Use the ALT attribute of the area map
		 position: {
			  target: 'mouse',
			  corner: {
					target: 'center',
					tooltip: 'bottomLeft'
			  }
		 },
		 adjust: {
			x: 0, y: 0,
			mouse: true,
			screen: true,
			scroll: true,
			resize: true
		},
		type: 'absolute',			 
		 style: {
			//name: 'dark', // Give it the preset dark style
			border: {
			   width: 0, 
			   radius: 4 
			}, 
			tip: true // Apply a tip at the default tooltip corner
		 }
	  });
   });
});
