/* Author: 

*/

// Anything Slider
$(function(){
	$('#slider').anythingSlider();
});

// Superfish Menu
jQuery(function(){
	jQuery('ul.sf-menu').superfish();
});

// Pixastic
jQuery(document).ready(function() {	
	$('.red-hover').each(function(index) {
		var clone = $(this).find('img').clone();//.removeClass('red-hover').addClass('red-hover-color').css('opacity',.25);
		$(this).find('img').addClass('hidden');
		$(clone).insertAfter($(this).find('img')).addClass('red-hover-clone');
	});

	$('.red-hover-clone').live('mouseenter', function() {
		var img = new Image();
		img.onload = function() {
			var blendImg = new Image();
			blendImg.onload = function() {
				Pixastic.process(img, "blend", 
					{
						amount : 1, 
						mode : "multiply", 
						image : blendImg
					}
				);
			}
			blendImg.src = "/img/red.gif";
		}
		img.src = $(this).attr('src');
		$(this).css({ display: 'none' });
		jQuery(img).insertAfter($(this));
    }); 

	$('.red-hover').live('mouseleave', function() {
		$(this).find('.red-hover-clone').css({ display: 'block' });
		$(this).find('canvas').remove();
    });
});

// Fancybox
$(document).ready(function() {
	/*
	*   Examples - images
	*/

	$("a#example1").fancybox();

	$("a#example2").fancybox({
		'overlayShow'	: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});

	$("a#example3").fancybox({
		'transitionIn'	: 'none',
		'transitionOut'	: 'none'	
	});

	$("a#example4").fancybox({
		'opacity'		: true,
		'overlayShow'	: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'none'
	});

	$("a#example5").fancybox();

	$("a#example6").fancybox({
		'titlePosition'		: 'outside',
		'overlayColor'		: '#000',
		'overlayOpacity'	: 0.9
	});

	$("a#example7").fancybox({
		'titlePosition'	: 'inside'
	});

	$("a#example8").fancybox({
		'titlePosition'	: 'over'
	});

	$("a[rel=example_group]").fancybox({
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});

});

//Switch Stylesheet
$(document).ready(function(){
	$(".changecolor").switchstylesheet( { seperator:"color"} );
});

//Dincus Slider
$("#dincus-denim-button").click(function () {
   $("#dincus-denim").slideToggle("slow");
});

//My Slider
$(document).ready(function (){
	$('#button a').click(function(){
		var integer = $(this).attr('rel');
		$('#myslide .cover').animate({left:-960*(parseInt(integer)-1)})  /*----- Width of div mystuff (here 160) ------ */
		$('#button a').each(function(){
		$(this).removeClass('active');
			if($(this).hasClass('button'+integer)){
				$(this).addClass('active')}
		});
	});	
});

//Scroller
$(document).ready(function(){
	$(".scroll").click(function(event){
		//prevent the default action for the click event
		event.preventDefault();

		//get the full url - like mysitecom/index.htm#home
		var full_url = this.href;

		//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
		var parts = full_url.split("#");
		var trgt = parts[1];

		//get the top offset of the target anchor
		var target_offset = $("#"+trgt).offset();
		var target_top = target_offset.top;

		//goto that anchor by setting the body scroll top to anchor top
		$('html, body').animate({scrollTop:target_top}, 500,'easeInOutExpo');
	});
});

