/* Author: Brett Bowlin

*/


$(document).ready( function (){
	/*$('#main').noisy({
	    'intensity' : 1,
	    'size' : 200,
	    'opacity' : 0.06,
	    'fallback' : '../img/fallback_noise_bg.jpg',
	    'monochrome' : true
	}).css('background-color', '#EDEBDE');*/

	

	$("#subjects a[title], #action-bar a[title]").qtip();


	$("#overview-features .feature").bind( 'mouseenter', function (){
		//move in
		var feature = $(this).attr('id');
		$('.feature-content .' + feature).fadeIn(300);
	}).bind( 'mouseleave', function () {
		//on out
		var feature = $(this).attr('id');
		$('.feature-content .' + feature).fadeOut(300);
	});


	$(".media-thumbs li a").click( function (e){
		e.preventDefault();
		
		//FLVs are proportioned differently. Can't resize after loading.
		var width = 520, height, prop, offset;
		if( $(this).parents('.math .media-thumbs').length > 0 ){
			prop = 1.3101449;
			offset = 8;
		} else {
			prop = 1.2405797;
			offset = 5;
		}
		height = ( width / prop ) | 0;
		height -= offset;
		
		$.fancybox({
         'autoscale' : false,
         'transitionIn' : 'none',
         'transitionOut': 'none',
         'padding' 		: 0,
         'title'  		: this.title,
         'width'  		: width,
         'height' 		: height,
         'type'    		: 'swf',
         'href'    		: this.href,
         'swf'   		: { 'wmode':'transparent', 'allowfullscreen':'true' },
         'onComplete'	: function () {
         	$.fancybox.resize();
         }
       });
       return false;
	});

	$(".screenshots li a").fancybox();

	//testimonials ticker


	var content = $('.testimonial');

	var count = $('.testimonial').length;
	console.log(count);

	var currentItem = 0;

	tickTicker = function() {
		if (currentItem == 0 && count == 1)
			return false;
	    if (currentItem == count - 1) {   
	        content.eq(count - 1).hide();
	        currentItem = 0;
	        content.eq(0).fadeIn("slow");
	    }
	    else {        
	        content.eq(currentItem).hide();
	        currentItem = currentItem + 1;
	        content.eq(currentItem).fadeIn("slow");
	    }        
	}

	setInterval("tickTicker()", 5000 );

});























