/* Author:*/



// Start Functions 
$(document).ready(function() {



$(function() {
    $('img[data-hover]').hover(function() {
        $(this).attr('tmp', $(this).attr('src')).attr('src', $(this).attr('data-hover')).attr('data-hover', $(this).attr('tmp')).removeAttr('tmp');
    }).each(function() {
        $('<img />').attr('src', $(this).attr('data-hover'));
    });
});

	$(function(){
		$("a[rel^='prettyPhoto']").prettyPhoto({
			slideshow: false, /* false OR interval time in ms */
			animation_speed: 'normal', /* fast/slow/normal */
			opacity: 0.80, /* Value between 0 and 1 */
			show_title: false, /* true/false */
			default_width:640,
			default_height:360,
			theme: 'light_rounded', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
			hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
			modal: false, /* If set to true, only the close button will close the window */
			deeplinking: true, /* Allow prettyPhoto to update the url to enable deeplinking. */
			callback: function(){}, /* Called when prettyPhoto is closed */
			ie6_fallback: true	
			
		});
	});



// Custom sorting plugin
(function($) {
  $.fn.sorted = function(customOptions) {
    var options = {
      reversed: false,
      by: function(a) { return a.text(); }
    };
    $.extend(options, customOptions);
    $data = $(this);
    arr = $data.get();
    arr.sort(function(a, b) {
      var valA = options.by($(a));
      var valB = options.by($(b));
      if (options.reversed) {
        return (valA < valB) ? 1 : (valA > valB) ? -1 : 0;				
      } else {		
        return (valA < valB) ? -1 : (valA > valB) ? 1 : 0;	
      }
    });
    return $(arr);
  };
})(jQuery);

// DOMContentLoaded
$(function() {

  // bind radiobuttons in the form
  var $filterType = $('#filter input[name="type"]');
  var $filterSort = $('#filter input[name="sort"]');

  // get the first collection
  var $applications = $('#applications');

  // clone applications to get a second collection
  var $data = $applications.clone();

  // attempt to call Quicksand on every form change
  $filterType.add($filterSort).change(function(e) {
    if ($($filterType+':checked').val() == 'all') {
      var $filteredData = $data.find('li');
    } else {
      var $filteredData = $data.find('li[data-type=' + $($filterType+":checked").val() + ']');
    }

    // if sorted by size
    if ($('#filter input[name="sort"]:checked').val() == "size") {
      var $sortedData = $filteredData.sorted({
        by: function(v) {
          return parseFloat($(v).find('span[data-type=size]').text());
        }
      });
    } else {
      // if sorted by name
      var $sortedData = $filteredData.sorted({
        by: function(v) {
          return $(v).find('strong').text().toLowerCase();
        }
      });
    }   

    // finally, call quicksand
    $applications.quicksand($sortedData, {
      duration: 800,
      easing: 'easeInOutQuad'
    });

  });

});


 //Product Page Tabs
$(function () {
    var tabContainers = $('div.tabs > div');
    
    $('div.tabs ul.tabNavigation a').click(function () {
        tabContainers.hide().filter(this.hash).show();
        
        $('div.tabs ul.tabNavigation a').removeClass('selected');
        $(this).addClass('selected');
        
        return false;
    }).filter(':first').click();
});


 //support Page Tabs
$(function () {
    var tabContainers = $('div.supportTabs > div');
    
    $('div.supportTabs ul.supportTabNavigation a').click(function () {
        tabContainers.hide().filter(this.hash).show();
        
        $('div.supportTabs ul.supportTabNavigation a').removeClass('selected');
        $(this).addClass('selected');
        
        return false;
    }).filter(':first').click();
});

 //where to buy Page Tabs
$(function () {
    var tabContainers = $('div.buyTabs > div');
    
    $('div.buyTabs ul.buyTabNavigation a').click(function () {
        tabContainers.hide().filter(this.hash).show();
        
        $('div.buyTabs ul.buyTabNavigation a').removeClass('selected');
        $(this).addClass('selected');
        
        return false;
    }).filter(':first').click();
});


//$(document).ready(function() {
$('form#filter label').click(
	function() 
	{	
		$(this).css('outline','none');
		$('form#filter .current').removeClass('current');
		$(this).parent().addClass('current');

		var filterVal = $(this).text().toLowerCase().replace(/ /g,'-').replace('.','-');
		
		

		if(filterVal == 'all') 
		{
			$('section#portfolio').fadeOut('fast',function()
			{
				$('section#portfolio article.hidden').removeClass('hidden');
				$('section#portfolio').fadeIn('normal');
			});
		}
		else 
		{
			$('section#portfolio').fadeOut('fast',function()
			{
				$('section#portfolio article').each(function() 
				{
					if(!$(this).hasClass(filterVal)) 
					{
						$(this).addClass('hidden');
					}
					else
					{
						$(this).removeClass('hidden');
					}
		
					$('section#portfolio').fadeIn('normal');
				});
			});
		}
  
        return true;  
	});
//});

//================================================================
// Change Nivo Slider Parameters { ]
//================================================================
$(window).load(function() {
    $('#slider').nivoSlider({
        effect:'boxRainGrow', // Specify sets like: 'fold,fade,sliceDown'
        slices:15, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed:500, // Slide transition speed
        pauseTime:4000, // How long each slide will show
        startSlide:0, // Set starting Slide (0 index)
        directionNav:true, // Next & Prev navigation
        directionNavHide:true, // Only show on hover
        controlNav:true, // 1,2,3... navigation
        controlNavThumbs:false, // Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
        keyboardNav:true, // Use left & right arrows
        pauseOnHover:true, // Stop animation while hovering
        manualAdvance:false, // Force manual transitions
        captionOpacity:0.8, // Universal caption opacity
        prevText: 'Prev', // Prev directionNav text
        nextText: 'Next', // Next directionNav text
        beforeChange: function(){}, // Triggers before a slide transition
        afterChange: function(){}, // Triggers after a slide transition
        slideshowEnd: function(){}, // Triggers after all slides have been shown
        lastSlide: function(){}, // Triggers when last slide is shown
        afterLoad: function(){} // Triggers when slider has loaded
    });
});

//===========================================
//TransitionNames
//===========================================

//sliceDown
//sliceDownLeft
//sliceUp
//sliceUpLeft
//sliceUpDown
//sliceUpDownLeft
//fold
//fade
//random
//slideInRight
//slideInLeft
//boxRandom
//boxRain
//boxRainReverse
//boxRainGrow
//boxRainGrowReverse



//================================================================
// End document.ready functions [$(document).ready(function() { ]
//================================================================
});




//   $(function(){
//      $(".tweet").tweet({
//        join_text: "auto",
//        username: "TrittonUsa",
//        avatar_size: 24,
//        count: 5,
//        auto_join_text_default: "we said,",
//        auto_join_text_ed: "we",
//        auto_join_text_ing: "we were",
//        auto_join_text_reply: "we replied",
//        auto_join_text_url: "we were checking out",
//        loading_text: "loading tweets..."
//      });
//    });
