/*  ---------------------------- */
/*  SCROLLER
/*  ---------------------------- */
/*$(window).load(function() {

sliderLeft=$('#thumbScroller .container').position().left;
padding=$('#outer_container').css('paddingRight').replace("px", "");
sliderWidth=$(window).width()-padding;
$('#thumbScroller').css('width',sliderWidth);

var totalContent=0;
$('#thumbScroller .content').each(function () {
		totalContent+=$(this).innerWidth();
		$('#thumbScroller .container').css('width',totalContent);
});

$('#thumbScroller').mousemove(function(e){
	if($('#thumbScroller  .container').width()>sliderWidth){
	  var mouseCoords=(e.pageX - this.offsetLeft);
	  var mousePercentX=mouseCoords/sliderWidth;
	  var destX=-(((totalContent-(sliderWidth))-sliderWidth)*(mousePercentX));
	  var thePosA=mouseCoords-destX;
	  var thePosB=destX-mouseCoords;
	  var animSpeed=600; //ease amount
	  var easeType='easeOutCirc';
	  if(mouseCoords==destX){
		  $('#thumbScroller .container').stop();
	  }
	  else if(mouseCoords>destX){
		  //$('#thumbScroller .container').css('left',-thePosA); //without easing
		  $('#thumbScroller .container').stop().animate({left: -thePosA}, animSpeed,easeType); //with easing
	  }
	  else if(mouseCoords<destX){
		  //$('#thumbScroller .container').css('left',thePosB); //without easing
		  $('#thumbScroller .container').stop().animate({left: thePosB}, animSpeed,easeType); //with easing
	  }
	}
});

$('#thumbScroller  .thumb').each(function () {
		$(this).fadeTo(fadeSpeed, 0.8);
});

var fadeSpeed=200;
	$('#thumbScroller .thumb').hover(
		function(){ //mouse over
			$(this).fadeTo(fadeSpeed, 1);
		},
		function(){ //mouse out
			$(this).fadeTo(fadeSpeed, 0.8);
		}
	);
});

$(window).resize(function() {
	//$('#thumbScroller .container').css('left',sliderLeft); //without easing
	$('#thumbScroller .container').stop().animate({left: sliderLeft}, 400,'easeOutCirc'); //with easing
	$('#thumbScroller').css('width',$(window).width()-padding);
	sliderWidth=$(window).width()-padding;
});*/

/*  ---------------------------- */
/*  LARGEIMAGE HOVERTEXT
/*  ---------------------------- */
$(document).ready(function(){
	$('.thumb').hover(
		function(){ //mouse over
		var largeAlt = $(this).attr("title");
		$(this).parent().append('<div class="thumb-text"><p></p></div>')
		$(".thumb-text p").html( largeAlt ); return false;		
		},
		function(){ //mouse out
		$('.thumb-text').remove();
	});					   
});

/*  ---------------------------- */
/*  IMAGE REPLACE
/*  ---------------------------- */
$(document).ready(function(){

	$(".thumbs a").click(function(){

		$("#loader").empty(); 
		$("#loader").addClass("loading"); 
//		$("#spinner").addClass("loading");

		var largePath = $(this).attr("href");
		var largeAlt = $(this).attr("title");
		var textdesc = $(this).find('img').attr('alt');
		var textlink = $(this).next('#pf').html(); // get the text

if (largePath != $("#largeImg").attr("src")){
	
	var img = new Image();
  
  // wrap our new image in jQuery, then:
  $(img)
    // once the image has loaded, execute this code
    .load(function () {
      // set the image hidden by default    
      $(this).hide();
	
		$("#loader").empty(); 
		
      // with the holding div #loader, apply:
      $('#loader')
        // remove the loading class (so no background spinner), 
        .removeClass('loading')
        // then insert our image
        .append(this);
	    
//		$('#spinner').removeClass('loading');
		
      // fade our image in to create a nice effect
      $(this).fadeIn();
    })
    
    // if there was an error loading the image, react accordingly
    .error(function () {
      // notify the user that the image could not be loaded
    })
    
    // *finally*, set the src attribute of the new image to our image
	.attr({ src: largePath, alt: largeAlt, title: largeAlt }).load(function (){ }); //load images

//	$('#largeImg').hide()
//    .load(function () {
//      $(this).fadeIn(600);
//    })
//    .attr({ src:largePath });
  
//	cvi_edge.remove(document.getElementById("largeImg")); // remove mask
//	$("#largeImg").attr({ src: largePath, alt: largeAlt, title: largeAlt }).load(function (){ }); //load images
//	cvi_edge.add(document.getElementById("largeImg"), { mask: 0, inbuilt: false }); //set mask
	$('.desc').html(textlink); // textoverlay
  }
	return false;
	});
});



/*  ---------------------------- */
/*  THUMB OPACITY
/*  ---------------------------- */
$(document).ready(function(){
						   
	$('.thumbs a').hover(
		function () {
			var $this = $(this);
			$this.find('img')
			.stop()
			.animate({'opacity':'1.0'},400);
		},
		function () {
			var $this = $(this);
			$this.find('img')
			.stop()
			.animate({'opacity':'0.6'},400);
		}
	);
});

/*  ---------------------------- */
/*  THUMB TOOLTIP
/*  ---------------------------- */
$().ready(function() {  
	//applies to all elements with title attribute. Change to ".class[title]" to select only elements with specific .class and title
	$(".wp-post-image[title]").style_my_tooltips({ 
		tip_follows_cursor: "on", //on/off
		tip_delay_time: 0 //milliseconds
	});  
});  

/*  ---------------------------- */
/*  SLIDER HOMEPAGE
/*  ---------------------------- */
		$(function(){
			$('#slides').slides({
				preload: true,
				preloadImage: 'img/ajax-loader.gif',
				play: 5000,
				pause: 2500,
				generatePagination: true,
				pagination: true,
				effect: 'fade',
				fadeSpeed: 350,
				hoverPause: true
			});
		});
